Python: Add MCP hosting adapter package#351
Open
hashwnath wants to merge 1 commit intomicrosoft:mainfrom
Open
Conversation
Introduce a new hosting adapter that exposes an M365 Agent as an MCP server using the mcp Python SDK (FastMCP). This enables MCP clients to discover and invoke agent capabilities through the standard MCP protocol. The adapter follows the existing hosting adapter pattern: - Subclasses ChannelAdapter and implements send_activities - Translates MCP tool calls into Activity-based turns - Routes turns through the standard middleware → agent pipeline - Buffers agent responses and returns them as MCP tool results Package includes: - MCPAdapter with built-in "message" tool and custom tool support - Streamable HTTP transport via FastMCP - Middleware pipeline integration - 14 unit tests covering init, turn processing, middleware, and edge cases Addresses microsoft#321 Fixes microsoft#321
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #321
Introduces a new
microsoft-agents-hosting-mcppackage that exposes an M365 Agent as an MCP (Model Context Protocol) server, enabling MCP clients to discover and invoke agent capabilities through the standard MCP protocol.Architecture
The adapter follows the established hosting adapter pattern used by
hosting-aiohttpandhosting-fastapi:ChannelAdapterand implementssend_activitiesto buffer responsesFastMCPfrom themcpPython SDK for protocol handling and transportKey Components
MCPAdapter— Core adapter bridging MCP protocol to the Agents SDK pipelinemessagetool for text-based agent interactionTurnContext.turn_stateMCP_CHANNEL_ID— Channel identifier ("mcp") for MCP-originated activitiesUsage
Test plan
send_activitiesresponse bufferingupdate_activity,delete_activity)🤖 Generated with Claude Code