KEMBAR78
feat: Support the Streamable HTTP transport for MCP by withsmilo · Pull Request #6615 · microsoft/autogen · GitHub
Skip to content

Conversation

@withsmilo
Copy link
Contributor

Why are these changes needed?

MCP Python-sdk has started to support a new transport protocol named Streamble HTTP since 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

@victordibia
Copy link
Collaborator

Thanks @withsmilo ,

This is looking good.
Do you have a minimum reproducible live test sample that you can add to the readme (this will make it easier for others to review).

Also you might need to run uv sync and commit the uv.lock file.

https://github.com/microsoft/autogen/tree/main/python#virtual-environment

@victordibia victordibia self-assigned this Jun 2, 2025
@withsmilo
Copy link
Contributor Author

withsmilo commented Jun 3, 2025

Thanks for quick feedback, @victordibia .
I have one private streamable_http mcp sample, which couldn't be published because it's only for in-house use. But I have confirmed that a new AutoGen StreamableHttpMcpToolAdapter works well with it on my local environment. I just added a sample for reviewers and users to 21fabe6#diff-c5d388ea4867efa2fe3a065150cf1b38386e6d9d7d9e1306db8d8bea7945e9c0R45-R89.

Also I changed the mcp version to 1.8.1 within pyproject.toml and the uv.lock file is not updating well. I hope you can help me if possible. Thanks.

@victordibia
Copy link
Collaborator

Thanks
Working on the uv.lock update.
In the mean time, here is a sample I am using to test

# 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()))
Test Workbench Tools: [{'name': 'error_agent', 'description': 'An agent that raises an error', 'parameters': {'type': 'object', 'properties': {'task': {'title': 'Task', 'type': 'string'}}, 'required': ['task'], 'additionalProperties': False}}, {'name': 'weather_tool', 'description': 'An agent that provides weather information', 'parameters': {'type': 'object', 'properties': {'location': {'title': 'Location', 'type': 'string'}}, 'required': ['location'], 'additionalProperties': False}}]
---------- TextMessage (user) ----------
 What is the weather in Seattle today? 
---------- ToolCallRequestEvent (fetcher) ----------
[FunctionCall(id='call_UxCIOXy6ezVkXq68dVd77FBK', arguments='{"location":"Seattle"}', name='weather_tool')]
---------- ToolCallExecutionEvent (fetcher) ----------
[FunctionExecutionResult(content='The weather in Seattle is 73°F sunny with a chance of rain.', name='weather_tool', call_id='call_UxCIOXy6ezVkXq68dVd77FBK', is_error=False)]
---------- TextMessage (fetcher) ----------
The weather in Seattle today is 73°F and sunny, with a chance of rain. TERMINATE

@codecov
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 85.10638% with 7 lines in your changes missing coverage. Please review.

Project coverage is 79.69%. Comparing base (1858799) to head (339d06a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../autogen-ext/src/autogen_ext/tools/mcp/_session.py 28.57% 5 Missing ⚠️
.../autogen-ext/src/autogen_ext/tools/mcp/_factory.py 50.00% 2 Missing ⚠️
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     
Flag Coverage Δ
unittests 79.69% <85.10%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@victordibia victordibia merged commit 9065c6f into microsoft:main Jun 3, 2025
64 checks passed
@withsmilo withsmilo deleted the support-streamable-http-transport branch June 3, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants