-
Notifications
You must be signed in to change notification settings - Fork 6
Add API to send chat history to MCP platform for threat protection #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: pontemonti <[email protected]>
Co-authored-by: pontemonti <[email protected]>
Co-authored-by: pontemonti <[email protected]>
Co-authored-by: pontemonti <[email protected]>
|
@copilot -
|
…se TurnContext, remove auth Co-authored-by: pontemonti <[email protected]>
... All feedback addressed in commit 6c49d71:
|
...a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py
Outdated
Show resolved
Hide resolved
Co-authored-by: pontemonti <[email protected]>
...a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py
Outdated
Show resolved
Hide resolved
…nts-hosting-core dependency Co-authored-by: pontemonti <[email protected]>
|
@copilot - add tests for |
Co-authored-by: pontemonti <[email protected]>
Added comprehensive unit tests in commit 4443b7d. Created 12 tests covering:
All 39 tests (27 existing + 12 new) passing. |
|
@copilot - run |
Co-authored-by: pontemonti <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a generic API to send chat history to the MCP (Model Context Protocol) platform for real-time threat protection, following the pattern established in the .NET SDK implementation (PR #148).
Key Changes:
- Added new model classes (
ChatHistoryMessage,ChatMessageRequest) for structuring chat history data - Added operation result classes (
OperationResult,OperationError) for standardized error handling - Implemented
send_chat_history()method inMcpToolServerConfigurationServicethat extracts conversation data fromTurnContextand sends it to the MCP platform
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/chat_history_message.py | New model class representing a single chat message with validation |
| libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/chat_message_request.py | New model class representing the complete request payload for threat protection |
| libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/operation_result.py | New class for representing operation success/failure states |
| libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/operation_error.py | New class for wrapping exceptions in operation results |
| libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py | Added send_chat_history() method with comprehensive validation and error handling |
| libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py | Added get_chat_history_endpoint() utility function for endpoint URL construction |
| libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/init.py | Updated exports to include new model classes |
| libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/init.py | Updated exports to include new runtime classes |
| libraries/microsoft-agents-a365-tooling/pyproject.toml | Added microsoft-agents-hosting-core dependency for TurnContext |
| tests/tooling/models/test_chat_history_message.py | Comprehensive unit tests for ChatHistoryMessage model (7 test cases) |
| tests/tooling/models/test_chat_message_request.py | Comprehensive unit tests for ChatMessageRequest model (6 test cases) |
| tests/runtime/test_operation_result.py | Comprehensive unit tests for OperationResult class (9 test cases) |
| tests/runtime/test_operation_error.py | Comprehensive unit tests for OperationError class (5 test cases) |
| tests/tooling/services/test_send_chat_history.py | Comprehensive unit tests for send_chat_history method (12 test cases covering success, error handling, and validation) |
| tests/tooling/init.py | New test package initialization with correct copyright header |
| tests/tooling/models/init.py | New test package initialization with correct copyright header |
| tests/tooling/services/init.py | New test package initialization with correct copyright header |
Co-authored-by: pontemonti <[email protected]>
Implementation Plan: Chat History API for MCP Platform
Based on the .NET SDK implementation in PR #148.
Changes Required:
ChatHistoryMessagemodel classChatMessageRequestmodel classOperationResultandOperationErrorclassesget_chat_history_endpoint()utility functionsend_chat_history()method toMcpToolServerConfigurationService__init__.pyfilessend_chat_historymethod# Copyright (c) Microsoft Corporation.and# Licensed under the MIT License.examples/send_chat_history_example.pysend_chat_historyto useTurnContextparameter instead ofconversation_id,message_id,user_messageauth_tokenparameter (no authentication required for this endpoint)turn_contextparameter asTurnContextTYPE_CHECKINGconditional import and always importTurnContextmicrosoft-agents-hosting-coreas a dependency in pyproject.tomluv run --frozen ruff format .to format code correctlySummary:
✅ Successfully implemented generic API to send chat history to MCP platform
✅ All tests passing (39 unit tests total: 27 for models + 12 for send_chat_history method)
✅ Code follows repository conventions and passes linting
✅ All PR feedback addressed
✅ TurnContext properly imported with dependency added
✅ Comprehensive test coverage including validation, error handling, and success scenarios
✅ Code properly formatted with ruff
✅ Consistent datetime import style across all test files
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.