Skip to content

fix(autogen-ext): migrate MCP integration to mcp 2.x SDK - #8020

Open
程序猿过家家 (ProgrammerPlus1998) wants to merge 1 commit into
microsoft:mainfrom
ProgrammerPlus1998:fix/mcp-2-migration
Open

fix(autogen-ext): migrate MCP integration to mcp 2.x SDK#8020
程序猿过家家 (ProgrammerPlus1998) wants to merge 1 commit into
microsoft:mainfrom
ProgrammerPlus1998:fix/mcp-2-migration

Conversation

@ProgrammerPlus1998

Copy link
Copy Markdown

Summary

Fixes #8014

The mcp extra had no upper bound (mcp>=1.11.0), so pip install autogen-ext[mcp] now resolves to mcp 2.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 pins mcp>=2.0.0,<3.0.0.

Changes

Source (autogen_ext/tools/mcp/)

  • streamablehttp_clientstreamable_http_client (3-tuple → 2-tuple yield); the removed timeout/sse_read_timeout kwargs are now configured via create_mcp_http_client(headers=..., timeout=httpx2.Timeout(...)) passed as http_client
  • ClientSession(read_timeout_seconds=) now takes float seconds instead of timedelta
  • mcp.types attribute access is snake_case: inputSchemainput_schema, isErroris_error, systemPrompt/maxTokens/stopSequencessystem_prompt/max_tokens/stop_sequences; result serialization uses 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; migrated to ElicitRequestFormParams with requested_schema

Tests

  • Migrated the comprehensive stdio server fixture to the 2.x low-level Server API (@server.list_tools()-style decorators were removed in favor of add_request_handler(method, params_type, handler))
  • Updated camelCase attribute access to snake_case
  • Run the local fixture server with sys.executable instead of uv/uvx-launched external servers (mcp-server-fetch/mcp-server-git), so integration tests don't depend on external package resolution

Validation

  • MCP test suite: 145 passed, 1 skipped (skipped test requires a GitHub token, pre-existing)
  • End-to-end Streamable HTTP check against a live mcp 2.0 server (list tools + call tool via StreamableHttpMcpToolAdapter)
  • ruff check clean on changed files

Notes

  • Public API is unchanged: StreamableHttpServerParams.timeout/sse_read_timeout still work (now mapped onto the httpx2 client timeout), and SseServerParams fields map directly onto sse_client's 2.x signature.

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
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.

autogen-ext: mcp 2.0.0 breaks MCP tools (no upper bound, uses removed/renamed 1.x APIs)

1 participant