Repository navigation
Preserve protocol version on session resumption after crash - #326
Merged
Merged
Conversation
mcpc <= 0.5.0 showed "Protocol: unknown" for every stdio server because it read the negotiated version from transport.protocolVersion, which MCP SDK v1's stdio client transport never exposes (typescript-sdk#1468 — the client-side getter was ultimately not added in typescript-sdk#1660; only the v2 server packages propagate it). The SDK v2 migration (#314) already fixed detection via Client.getNegotiatedProtocolVersion(), but nothing guarded it: assert that stdio sessions report a real date-formatted protocol version in both human and --json output. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011pqNs7aoZWzXjgBUxAsias
The SDK v2 client skips the initialize handshake when reconnecting with a preserved MCP-Session-Id, so a bridge restarted after a crash never learned the protocol version: session details showed "Protocol: unknown (stateful)" without the Server line, and all requests on the resumed connection went out without the required MCP-Protocol-Version header. Thread the protocolVersion persisted in sessions.json through the resume path (bridge-manager -> bridge -> transport) using the SDK's transport option for exactly this case, derive the protocol era from the restored version so era-dependent routing keeps working, and fall back to the persisted serverInfo in session details. Covered by a new e2e test that crashes the bridge and asserts the resumed session keeps its protocol version and server info. Fixes #324 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011pqNs7aoZWzXjgBUxAsias
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.
Sessions resumed after a bridge crash lost their negotiated protocol version: session details showed
Protocol: unknown (stateful)without the server name, and all requests on the resumed connection were sent without the requiredMCP-Protocol-Versionheader. The SDK skips the initialize handshake when reconnecting with a preservedMCP-Session-Id, so mcpc now seeds the reconstructed transport with the version persisted in sessions.json.protocolVersionthrough the resume path (bridge manager → bridge → transport), using the SDK transport option intended for exactly this caseserverInfoin session details after resumptionStdioServerTransport.setProtocolVersionto save protocol version for stdio transport modelcontextprotocol/typescript-sdk#1468)Fixes #324. Refs #325 (follow-up: capabilities/instructions after resumption).
https://claude.ai/code/session_011pqNs7aoZWzXjgBUxAsias