refactor(mcp): migrate from MCP SDK v1 to v2.0.0b1#112
Open
jonpspri wants to merge 1 commit into
Open
Conversation
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
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
Migrates all MCP client and server code from MCP Python SDK v1 → v2.0.0b1, applying every breaking API change.
Breaking Changes Applied
streamablehttp_clientstreamable_http_clientMcpErrorMCPErrormcp.typesmcp_types(separate package)FastMCPMCPServerSSLCapableFastMCPSSLCapableMCPServerMCPServer(host=..., port=...)host/portpassed to run methods onlystreamable_http_clientreturns(read, write, get_session_id)(read, write)Behavioral Changes
__terminate_http_session(); v2 SDK handles DELETE viaterminate_on_close=True_http_client_factorypattern with pre-builthttpx.AsyncClienttransport_securitynow stored as instance attr and passed tostreamable_http_app()instead of__init__self.settings.host/port→self.server_config.host/portRemoved
_session_id,_get_session_id,_http_client_factory,__terminate_http_sessionTestTerminateHTTPSession,TestTerminateHTTPSessionErrors,TestHTTPClientFactory)Tests
All 190 MCP unit tests pass.
Dependencies
mcp == 2.0.0b1mcp-types == 2.0.0b1Migration guide reference
https://py.sdk.modelcontextprotocol.io/v2/migration/