Skip to content

[Python] Support MCP protocol 2026-07-28 via mcp 2.x, dual-major (no breaking changes) #634

Description

@cornelcroi

Problem

Same as the TypeScript counterpart (#633): MCP 2026-07-28 support only exists in mcp 2.x. On Python the situation is sharper because 2.x shipped under the same PyPI name as a breaking release (camelCase → snake_case attributes) — #631 caps us to <2 as a hotfix, which also locks us out of the new protocol until this issue is done.

Proposal

Dual-major, auto-detected, additive:

  • Detect the installed major at import/connect time (importlib.metadata.version("mcp")).
  • 1.x installed → existing ClientSession + initialize() path, byte-identical to today.
  • 2.x installed → new mcp.client.Client(server, mode="auto") path: the SDK probes server/discover and falls back to the legacy handshake, so modern and legacy servers both work. Headers and ttlMs caching are SDK-internal.
  • Small attribute-normalization helper so shared code reads both shapes (inputSchema/input_schema, isError/is_error, structuredContent/structured_content).
  • Then lift the <2 cap from [Python] agent-squad[mcp] broken by mcp 2.0.0 release — cap dependency to <2 #631: mcp>=1.0.0 works again on both majors.
  • Public API unchanged: MCPToolProvider, MCPServerConfig, format methods, tool_handler, disconnect keep their exact signatures and behavior.
  • Existing tests (patched against 1.x-shaped mocks) stay green untouched; new tests cover the 2.x path.
  • Docs: version-support matrix shared with the TS page.

Out of scope: Tasks extension (not implemented in mcp 2.0.0 at all), OAuth/CIMD, MRTR elicitation/sampling callbacks (separate issue if users ask).

Depends on #631 and #632.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions