fix(autogen-ext): migrate MCP integration to mcp 2.x SDK - #8020
Open
程序猿过家家 (ProgrammerPlus1998) wants to merge 1 commit into
Open
fix(autogen-ext): migrate MCP integration to mcp 2.x SDK#8020程序猿过家家 (ProgrammerPlus1998) wants to merge 1 commit into
程序猿过家家 (ProgrammerPlus1998) wants to merge 1 commit into
Conversation
The mcp extra had no upper bound (mcp>=1.11.0), so installing autogen-ext[mcp] now resolves to mcp 2.0.0, which removed or renamed several 1.x client APIs the integration relied on. Migrate to the 2.x APIs and pin mcp>=2.0.0,<3.0.0: - streamablehttp_client -> streamable_http_client (2-tuple yield); timeout/sse_read_timeout kwargs were removed, so HTTP timeouts and headers are now configured via create_mcp_http_client + httpx2.Timeout passed as http_client - ClientSession(read_timeout_seconds=) now takes float seconds, not timedelta - mcp.types attribute access is snake_case: inputSchema -> input_schema, isError -> is_error, systemPrompt/maxTokens/stopSequences -> system_prompt/max_tokens/stop_sequences; serialize results with model_dump(by_alias=True) to keep the camelCase wire format - RequestContext moved to mcp.client.session.ClientRequestContext - ElicitRequestParams is now a Form/URL union; use ElicitRequestFormParams and requested_schema Tests: migrate the comprehensive stdio server fixture to the 2.x low-level Server API (decorators removed in favor of add_request_handler), update camelCase attribute access, and run the local fixture server with sys.executable instead of uv/uvx so integration tests don't depend on external package resolution. Fixes microsoft#8014
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
Fixes #8014
The
mcpextra had no upper bound (mcp>=1.11.0), sopip install autogen-ext[mcp]now resolves tomcp2.0.0 (released 2026-07-28), which removed or renamed several 1.x client APIs the integration relied on. This migrates the integration to the 2.x APIs and pinsmcp>=2.0.0,<3.0.0.Changes
Source (
autogen_ext/tools/mcp/)streamablehttp_client→streamable_http_client(3-tuple → 2-tuple yield); the removedtimeout/sse_read_timeoutkwargs are now configured viacreate_mcp_http_client(headers=..., timeout=httpx2.Timeout(...))passed ashttp_clientClientSession(read_timeout_seconds=)now takes float seconds instead oftimedeltamcp.typesattribute access is snake_case:inputSchema→input_schema,isError→is_error,systemPrompt/maxTokens/stopSequences→system_prompt/max_tokens/stop_sequences; result serialization usesmodel_dump(by_alias=True)to keep the camelCase wire formatRequestContextmoved tomcp.client.session.ClientRequestContextElicitRequestParamsis now a Form/URL union; migrated toElicitRequestFormParamswithrequested_schemaTests
ServerAPI (@server.list_tools()-style decorators were removed in favor ofadd_request_handler(method, params_type, handler))sys.executableinstead ofuv/uvx-launched external servers (mcp-server-fetch/mcp-server-git), so integration tests don't depend on external package resolutionValidation
mcp2.0 server (list tools + call tool viaStreamableHttpMcpToolAdapter)ruff checkclean on changed filesNotes
StreamableHttpServerParams.timeout/sse_read_timeoutstill work (now mapped onto the httpx2 client timeout), andSseServerParamsfields map directly ontosse_client's 2.x signature.