Skip to content

refactor(mcp): migrate from MCP SDK v1 to v2.0.0b1#112

Open
jonpspri wants to merge 1 commit into
0.1.xfrom
0.1.x-mcp-2.0.0
Open

refactor(mcp): migrate from MCP SDK v1 to v2.0.0b1#112
jonpspri wants to merge 1 commit into
0.1.xfrom
0.1.x-mcp-2.0.0

Conversation

@jonpspri

@jonpspri jonpspri commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates all MCP client and server code from MCP Python SDK v1 → v2.0.0b1, applying every breaking API change.

Breaking Changes Applied

v1 v2
streamablehttp_client streamable_http_client
McpError MCPError
mcp.types mcp_types (separate package)
FastMCP MCPServer
SSLCapableFastMCP SSLCapableMCPServer
MCPServer(host=..., port=...) host/port passed to run methods only
streamable_http_client returns (read, write, get_session_id) returns (read, write)

Behavioral Changes

  • Session termination: removed manual __terminate_http_session(); v2 SDK handles DELETE via terminate_on_close=True
  • HTTP client: replaced _http_client_factory pattern with pre-built httpx.AsyncClient
  • Transport security: transport_security now stored as instance attr and passed to streamable_http_app() instead of __init__
  • Config access: self.settings.host/portself.server_config.host/port

Removed

  • _session_id, _get_session_id, _http_client_factory, __terminate_http_session
  • Obsolete test classes (TestTerminateHTTPSession, TestTerminateHTTPSessionErrors, TestHTTPClientFactory)

Tests

All 190 MCP unit tests pass.

Dependencies

  • mcp == 2.0.0b1
  • mcp-types == 2.0.0b1

Migration guide reference

https://py.sdk.modelcontextprotocol.io/v2/migration/

Breaking changes applied:
- streamablehttp_client → streamable_http_client (renamed import)
- McpError → MCPError (exception renamed)
- mcp.types → mcp_types (split into separate package)
- FastMCP → MCPServer (base class renamed)
- SSLCapableFastMCP → SSLCapableMCPServer
- MCPServer.__init__ no longer accepts host/port/transport_security;
  these are passed to run methods and streamable_http_app() instead
- streamable_http_client returns 2-tuple (read, write) instead of 3-tuple;
  session ID tracking and manual termination removed (terminate_on_close=True)
- Remove _http_client_factory; use pre-built httpx.AsyncClient directly
- Replace self.settings.host/port with self.server_config.host/port

Deprecations removed:
- __terminate_http_session(), _session_id, _get_session_id, _http_client_factory

Tests: 190 passing
@jonpspri jonpspri requested review from araujof and terylt as code owners July 3, 2026 23:43
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.

1 participant