feat: Support the Streamable HTTP transport for MCP#6615
Conversation
|
Thanks @withsmilo , This is looking good. Also you might need to run uv sync and commit the uv.lock file. |
|
Thanks for quick feedback, @victordibia . Also I changed the |
|
Thanks # server.py
from mcp.server.fastmcp import FastMCP
# Create an MCP server
mcp = FastMCP("Demo", host="localhost", port=8005)
@mcp.tool()
async def weather_tool(location: str) -> str:
"""An agent that provides weather information"""
return f"The weather in {location} is 73°F sunny with a chance of rain."
if __name__ == "__main__":
mcp.run(transport="streamable-http")
run the Streamable server above and connect to it in AutoGen from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StreamableHttpServerParams, McpWorkbench
from autogen_agentchat.agents import AssistantAgent
from autogen_core import CancellationToken
from autogen_agentchat.ui import Console
test_tool= StreamableHttpServerParams(
url="http://localhost:8005/mcp",
)
test_workbench = McpWorkbench(server_params=test_tool)
print("Test Workbench Tools:", await test_workbench.list_tools())
# # Create an agent that can use the fetch tool.
model_client = OpenAIChatCompletionClient(model="gpt-4o")
agent = AssistantAgent(name="fetcher", model_client=model_client, workbench=[test_workbench], reflect_on_tool_use=True)
await Console(agent.run_stream(task=" What is the weather in Seattle today? ", cancellation_token=CancellationToken())) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6615 +/- ##
=======================================
Coverage 79.68% 79.69%
=======================================
Files 227 228 +1
Lines 16989 17025 +36
=======================================
+ Hits 13538 13568 +30
- Misses 3451 3457 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ilo/autogen into support-streamable-http-transport
Why are these changes needed?
MCP Python-sdk has started to support a new transport protocol named
Streamble HTTPsince v1.8.0 last month. I heard it supersedes the SSE transport. Therefore, AutoGen have to support it as soon as possible.Related issue number
#6517
Checks