feat(client): add session renegotiation on HTTP 404 conformance scenario#326
Open
rinaldofesta wants to merge 1 commit into
Open
Conversation
Adds a CLIENT conformance scenario covering the Streamable HTTP requirement that when a client receives HTTP 404 in response to a request carrying an MCP-Session-Id, it MUST start a new session by sending a fresh InitializeRequest (with no session ID) and continue operating, rather than bricking the trajectory (issue modelcontextprotocol#76). The mock server assigns a session on the first initialize, then returns 404 to the next session-bearing request (mid-trajectory session loss), and expects the client to re-initialize without a session ID and keep operating under the new session. Emits two MUST checks (FAILURE on violation): - client-session-renegotiate-on-404 - client-session-continues-after-renegotiation Registers the scenario in the core/active client suites, adds a reference handler to everything-client (the TS SDK surfaces the 404 as a StreamableHTTPError, so renegotiation is done at the consumer level), and includes positive + negative + never-connected tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Adds a CLIENT conformance scenario for Streamable HTTP session renegotiation, closing #76.
Per the transport spec's session-management rules, when a client receives HTTP 404 in response to a request carrying an
MCP-Session-Id(the server has terminated/lost the session — e.g. a redeploy or in-memory session loss), the client MUST start a new session by sending a freshInitializeRequestwithout a session ID and continue operating — rather than bricking the trajectory.This is strictly the client side. The server-side 404 behavior is tracked separately under #79 (PRs #316/#322).
Scenario
A mock Streamable-HTTP server (vanilla
http, same shape asinitialize.ts/sse-retry.ts):initializeand assigns session A;initializewith no session ID, assigns session B, and serves a follow-up request under B.It distinguishes the failure modes: never re-initialized, re-initialized but re-attached the stale session ID, or never made a session-bearing request at all.
Checks (MUST → FAILURE)
client-session-renegotiate-on-404client-session-continues-after-renegotiation(SKIPPED when the client never renegotiated, to avoid double-counting)Registered in
scenariosListandcoreScenariosList; a reference passing handler is added toexamples/clients/typescript/everything-client.ts.Spec basis & traceability
A base-transport MUST present in
2025-03-26,2025-06-18, and2025-11-25(identical wording), sosource.introducedIn = '2025-03-26'. Deliberately not a draft-suite scenario —DRAFT-2026-v1removedMCP-Session-Id. No SEP governs it, sosrc/seps/traceability.jsonis unchanged (the descriptiveclient-*check IDs follow the existingclient-sse-*convention).Validation
npm run check(tsgo + eslint + prettier) — cleannpm test— 21 files, 227 tests passnpm run build— succeedsNotes for reviewers
StreamableHTTPError(404)); the referenceeverything-clienthandler performs renegotiation at the consumer level (drop the stale-session transport, reconnect without a session ID, retry). This matches the maintainer note on Add conformance tests for client session renegotiation on 404 #76 ("the SDK consumer should reconnect"). If renegotiation later moves into the SDK transport, the scenario stays valid and the reference handler simplifies.coreScenariosList(tier-1) alongsideSSERetryScenario, as a base-spec MUST — happy to move it out of core if you prefer.Implemented with the help of a coding agent (Claude Code) and reviewed locally by the author.