Skip to content

Preserve protocol version on session resumption after crash - #326

Merged
jancurn merged 2 commits into
draftfrom
claude/mcp-protocol-detection-gu4cmz
Jul 27, 2026
Merged

jancurn merged 2 commits into
draftfrom
claude/mcp-protocol-detection-gu4cmz

Conversation

@jancurn

@jancurn jancurn commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

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 required MCP-Protocol-Version header. The SDK skips the initialize handshake when reconnecting with a preserved MCP-Session-Id, so mcpc now seeds the reconstructed transport with the version persisted in sessions.json.

  • Thread the stored protocolVersion through the resume path (bridge manager → bridge → transport), using the SDK transport option intended for exactly this case
  • Derive the protocol era from the restored version so era-dependent routing keeps working on resumed connections
  • Fall back to persisted serverInfo in session details after resumption
  • New e2e test crashes the bridge and asserts the resumed session keeps its protocol version, server info, and session ID (verified to fail without the fix)
  • Also adds an e2e guard asserting stdio sessions report a real protocol version (the mcpc ≤ 0.5.0 symptom from Implement StdioServerTransport.setProtocolVersion to 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

claude added 2 commits July 26, 2026 22:17
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
@jancurn
jancurn merged commit 591ffa2 into draft Jul 27, 2026
6 checks passed
@jancurn
jancurn deleted the claude/mcp-protocol-detection-gu4cmz branch July 27, 2026 06:04
jancurn added a commit that referenced this pull request Jul 31, 2026
Stacks the following PRs:

#314
#315
#318
#319
#320
#326
#327
#328
#329
#330
#331
#337
#336
#339
#340
#345
#347
#348
#349
#351

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.

2 participants