feat(mcp): add Streamable HTTP with SSE fallback - #1552
Conversation
Signed-off-by: onatozmenn <onatozmen44@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces transport-aware connection handling and selection for Model Context Protocol (MCP) servers, adding support for both Streamable HTTP and SSE transports. It implements an automatic fallback mechanism from Streamable HTTP to SSE under certain network or protocol negotiation failures when using the AUTO transport setting. The changes include updating API schemas, upgrading dependencies (including updating the mcp library), refactoring connection logic, and adding comprehensive unit tests. No review comments were provided, so I have no feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
FenjuFu
left a comment
There was a problem hiding this comment.
Read through the whole change — this is a careful, well-tested implementation. LGTM.
What I checked:
- Fallback safety (the crux).
initialized_mcp_sessiononly falls back whiletransport is AUTOand before initialization completes; theinitializedflag makes any post-init exception re-raise instead of retrying through SSE, so atools/callcan never be sent twice over two transports._fallback_reasoncorrectly refuses to fall back onSSLCertVerificationErrorand on 401/403, and thecapture_responsehook means a timeout after an HTTP exchange was accepted is treated as a real error, not transport discovery. That's exactly the right set of guards. - Backwards compatibility.
MCPTransportdefaults toAUTOat every new call site and the schema default isAUTO, so existing callers are untouched. Transport-setup failures are mapped back onto the existingMCP_SERVER_*error codes, so the public error contract doesn't change. - Tests. 16 focused tests covering the branches that matter — no-fallback-on-auth, no-fallback-on-cert, no-retry-after-init, no-fallback-after-accepted-timeout, explicit-transport-never-falls-back, plus real-SDK sessions. Good coverage of the failure matrix.
- CI green, DCO and CLA signed.
One thing to flag for the record, not a blocker: the SDK bump is a wide jump (mcp==1.6.0 → >=1.28.1,<2). You note the existing 198-test suite passes on 3.13, which is the reassurance I'd want; the <2 upper bound is the right call to avoid an unpinned major. If anything elsewhere in link imports from mcp internals beyond the client transports, worth a quick grep, but the test pass makes me comfortable.
Nice work — approving. Merge is the maintainers' call.
|
Thanks for the implementation. The overall transport/session abstraction looks reasonable, especially the guard that prevents fallback after initialization. However, I found a few issues that should be addressed before merging:
There is also a coverage gap around the main success path: the list/call tests mock For reference, the latest required checks currently show |
Signed-off-by: onatozmenn <onatozmen44@gmail.com>
…ble-http Signed-off-by: onatozmenn <onatozmen44@gmail.com>
|
Thanks, these were good catches. I pushed the fixes in
The full link suite is 200/200 on Python 3.11, and the CI-equivalent quality checks pass. |
|
Just a quick ping on this one. All three points from the review are fixed in CI is fully green now, |
|
Thanks for the PR! The following three items can be addressed in follow-up work — this PR is good to merge as-is: |
Summary
Adds Streamable HTTP support for MCP clients while keeping legacy SSE servers working. Existing callers do not need to change anything: the current endpoints default to
auto.In
auto, the client tries Streamable HTTP first and falls back to SSE only when the connection or transport negotiation fails. It does not retry authentication, TLS, or post-initialization errors, so a tool call cannot be sent twice through different transports.The change also updates the Python MCP SDK from
1.6.0to1.28.1with a<2upper bound.Type of Change
Related Issue
Closes #1548
Testing
initialize -> list_tools -> call_toolroundtrip.uv lock --check, andgit diff --checkpass.Screenshots (if applicable)
Not applicable; this only changes backend transport behavior.
Checklist
Responsibility
GitHub Copilot assisted with implementation and testing. I reviewed the changes and take responsibility for this submission.