Python: Introducing Local MCP Servers - #389
Python: Introducing Local MCP Servers#389Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds MCP (Model Context Protocol) tools integration to the Agent Framework, enabling agents to connect to and use MCP servers for extended functionality. The implementation provides multiple connection types (stdio, SSE, websocket, and streamable HTTP) and seamlessly integrates MCP tools with existing agent capabilities.
- Adds comprehensive MCP server integration with support for multiple transport protocols
- Extends ChatClientAgent to accept and manage MCP tools alongside traditional tools
- Includes sample implementations demonstrating MCP usage with both OpenAI chat and responses clients
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/main/agent_framework/_mcp.py | Core MCP implementation with server classes and protocol conversion utilities |
| python/packages/main/agent_framework/_agents.py | Extended ChatClientAgent to support MCP tools with proper context management |
| python/packages/main/agent_framework/init.py | Exported MCP classes for public API |
| python/packages/main/pyproject.toml | Added mcp>=1.12 dependency |
| python/packages/main/tests/main/test_mcp.py | Comprehensive test suite for MCP functionality |
| python/samples/getting_started/agents/openai_chat_client/openai_chat_client_with_local_mcp.py | Sample showing MCP usage with OpenAI chat client |
| python/samples/getting_started/agents/openai_responses_client/openai_responses_client_with_local_mcp.py | Sample showing MCP usage with OpenAI responses client |
| python/pyproject.toml | Updated install command to include all extras |
| python/.vscode/launch.json | Added justMyCode: false for debugging |
| .github/workflows/python-merge-tests.yml | Added LOCAL_MCP_URL environment variable for CI |
Eric Zhu (ekzhu)
left a comment
There was a problem hiding this comment.
Looks great!
Are we planning to also include the sampling and elicitation features of MCP used currently?
See the AG branch that uses them to drive the agent actions: microsoft/autogen#6833
|
Eric Zhu (@ekzhu) sampling already works, you can pass a ChatClient to the constructor of the McpServer and that is used to do sampling if requested. I have not looked at elicitation, but I will, thanks for pointing to that |
|
added a issue to track elicitation #398 |
|
This looks great Eduard van Valkenburg (@eavanvalkenburg) One future thing to track is our thinking on how to “pipe” in streamed updates from tools. Many tools have agentic behaviors (long running) can send notifications (resource updates, progress notifications, logging ). These may include useful information or even partial results which the rest of the application can benefit from (as well as UI updates). Might be worth exploring a setup where devs can pass in a message handler callback for these scenarios. related post on long runnning tools here. |
|
thanks Victor Dibia (@victordibia), peterychang is working on broader support for long-running things, and I think this might fit in there. we do already have a message handler in here, so that can easily be extended to handle other updates, and elicitation depends on broader user request structures we are working on, as noted, already a issue created for tracking that. |
…s AITool and running samples
* mcp parts * mcp parts 2 * removed structured output in favor of handling in chatresponse, mcp as AITool and running samples * updated naming * fixed test
* mcp parts * mcp parts 2 * removed structured output in favor of handling in chatresponse, mcp as AITool and running samples * updated naming * fixed test
Motivation and Context
Adds MCP tools to AF
Closes #292
Description
Contribution Checklist