feat(core): add support for MCP 2026 stateless draft and auto-negotiation fallback#703
Open
anubhav756 wants to merge 10 commits into
Open
feat(core): add support for MCP 2026 stateless draft and auto-negotiation fallback#703anubhav756 wants to merge 10 commits into
anubhav756 wants to merge 10 commits into
Conversation
802cb5e to
bc8837b
Compare
Contributor
Author
5a88785 to
fc0c7cd
Compare
e41ec74 to
eb3cf50
Compare
Yuan325
approved these changes
Jul 1, 2026
Yuan325
left a comment
Contributor
There was a problem hiding this comment.
Approve with a comment for clarification~
…tion fallback (#704) * feat(core): add support for MCP 2026 stateless draft and auto-negotiation fallback * fix: Keep the MCP_LATEST to stable version but point MCP_DRAFT to 2026 draft * chore: fix integration tests * chore: delint * chore: fix tests * test: increase integration test coverage * chore: delint * test: integrate the draft build with dual testing modes * fix(tests): correct pytest async fixtures and auto-format with black/isort * fix(tests): use pytest.fixture for sync fixtures and fix isort formatting * fix(tests): update binary URL for draft testing in all packages * chore: fix integration tests url and lint errors * chore: test with mcp-v202606 branch to fix unknown flag error * fix(test): core fallback and adk toolset import * chore: format files * Revert "chore: format files" This reverts commit ee00b9e. * chore(test): fix line length in bucket name selection * chore: bump TOOLBOX_VERSION to v1.6.0 * test: parameterize integration tests to run comprehensively for both stable and draft MCP versions
Previously, the protocol fallback error (-32004) was correctly handled if returned inside an HTTP 400 Bad Request. However, if it was returned inside an HTTP 200 OK response, the SDK failed to extract the fallback version and would instead raise a generic RuntimeError. This commit updates the `error` checking logic inside the 200 OK path to correctly extract the supported versions array and raise a ProtocolNegotiationError, along with corresponding unit tests.
Parameterizing tests with http_session causes pytest-asyncio to rapidly create and destroy multiple event loops. This occasionally leaks ResourceWarnings on teardown which caused test_tool_init_basic to fail because it asserts no warnings were raised. We now explicitly ignore ResourceWarning so we only catch business logic warnings.
d86e41f to
58c7b78
Compare
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.
Description
This PR standardizes the Python SDK's version opt-in strategy for the upcoming stateless draft and introduces protocol auto-negotiation fallback to ensure smooth backward compatibility with older servers.
Note
This PR is stacked on top of the test infrastructure changes in #706.
Changes:
protocol.py):Protocol.MCP_DRAFTconstant mapped to"DRAFT-2026-v1"to give developers a safe way to opt into testing the draft spec without hardcoding ephemeral version strings.Protocol.MCP_LATESTmapped to the stable2025-11-25release to ensure production workloads remain unaffected.client.py&mcp.py):-32004UnsupportedProtocolVersionError), the transport layer now safely raises aProtocolNegotiationError.test_e2e_mcp.py):test_protocol_fallback_e2eto verify smooth protocol negotiation downgrades against older servers. Leveraging the dual-server harness from the base PR, this test proves that a client requestingMCP_DRAFTsuccessfully falls back when hitting port5000, but correctly utilizes the draft protocol on port5001.