# In what scenarios must an instance treat MCP Streamable-HTTP SSE resumption as a fresh capability negotiation rather than a transparent replay **Date of Record:** 2026 November 27 **Scope:** Applies to MCP clients and servers using the Streamable HTTP transport where a session is re-established after transport loss and the client attempts to resume a server-sent event stream via `Last-Event-ID`. Does not apply to stdio transports, nor to servers that do not emit event IDs on their SSE streams. ## Core Distinction The Streamable HTTP transport offers two superficially similar recovery paths that are semantically disjoint: **stream resumption** (reconnect to the same logical stream using `Last-Event-ID`, replaying events the client missed) and **session re-establishment** (a new `Mcp-Session-Id` after the server has forgotten the old one, requiring re-initialization and capability re-negotiation). The failure mode lives in the seam: a client that receives a valid-looking `Mcp-Session-Id` echo on the reconnect response, plus a `Last-Event-ID` it believes the server honors, will assume it is *resuming*. In reality the server may have silently dropped the session state and be treating the request as a *fresh* stream on a *new* session that happens to accept the same header. The client then replays a `Last-Event-ID` pointing at events the new session never issued, and the server either (a) ignores it and starts at event id 0, causing the client to re-execute already-applied tool calls, or (b) rejects it with a 400 that the client's retry logic interprets as transient, looping forever. ## What Was Observed A client agent had issued a `tools/call` for a long-running `deploy.apply` operation. The server streamed progress events `id: 41…id: 58` over SSE, then the TCP connection dropped at event 58 mid-`tool_result`. The client reconnected with `Last-Event-ID: 58` and the original `Mcp-Session-Id`. The server's session store had evicted the session (TTL 300s, reconnect at 312s). The server returned HTTP 200 with a *new* `Mcp-Session-Id` header and an SSE stream whose first event was `id: 0`, `event: message`, containing an `initialize`-shaped `server_capabilities` payload — but no `notifications/initialized` handshake had occurred. The client, seeing `Last-Event-ID` accepted without error and a 200 status, treated the stream as a continuation. It re-emitted the buffered `tools/call` for `deploy.apply` (because the tool result had never arrived) against a session that had never seen the tool registration. The server, on the new session, had no record of `deploy.apply` in its capability set and returned `-32601 Method not found`. The client's error classifier bucketed `-32601` as a *permanent* protocol error and aborted the whole task, leaving the deployment half-applied with no idempotency key recorded. The non-obvious part: **the server never signaled re-establishment**. There is no required field distinguishing "resumed stream on existing session" from "new stream on new session." The `Mcp-Session-Id` header is the only signal, and its presence on the response is ambiguous — it is emitted both on resume (echoing the same id) and on re-establishment (a new id). A client that does not string-compare the returned id against the id it sent cannot tell the two apart. ## Condition of Validity Resumption is only valid when *all* of the following hold simultaneously: 1. The response `Mcp-Session-Id` is byte-identical to the request's `Mcp-Session-Id`. 2. The first replayed event id is strictly greater than the client's `Last-Event-ID` (the server honored the cursor), **or** the server emits an explicit `event: resumption-ack` with the confirmed cursor before any message event. 3. The server has not emitted a second `initialize` capability payload on the stream. An `initialize`-shaped message on a resumed stream is definitionally a re-establishment, not a resume. If any of (1)–(3) fails, the client MUST treat the stream as a fresh session: discard buffered outbound calls, re-run `initialize` → `notifications/initialized`, re-negotiate capabilities, and re-issue any in-flight `tools/call` **with a client-generated idempotency key** so the server can deduplicate if the original call did in fact land. The invariant is: *no outbound tool call may be replayed across a session boundary without an idempotency key derived from the pre-disconnect call, not from the reconnect attempt.* ## Decision Boundary The boundary is crossed the moment the client observes a response `Mcp-Session-Id` that differs from the one it sent, **regardless of HTTP status and regardless of whether `Last-Event-ID` was accepted**. A 200 with a new session id is a re-establishment, not a resume. Conversely, a 404 on the session (server explicitly forgot it) is *cleaner* than a 200 with a new id, because 404 is unambiguous — the dangerous case is the silent 200-with-new-id, which is precisely what MCP servers do when their session store evicts but their HTTP layer still accepts the request. The client's decision function must therefore be: `resume_ok = (response_session_id == request_session_id) and (first_event_id > last_event_id or resumption_ack_seen) and (not initialize_payload_seen)`. Any other combination routes to the re-establishment path. ## Operational Effect Clients that skip this check exhibit a characteristic failure signature: duplicate side-effecting tool calls after transient network blips, `-32601` errors on methods the server *did* support before the drop, and task aborts where the underlying operation actually completed but the result was lost across the session boundary. The guardrail is a transport-layer state machine that refuses to emit any buffered request onto a stream whose session id does not match the one the request was originally bound to, and that forces a full re-initialization handshake before the next outbound call. Servers, for their part, should emit an explicit resumption-ack event and should return 404 — not 200 — when a `Last-Event-ID` arrives for an evicted session, so the client is not left to infer the boundary from a header string comparison. ```python class SessionResumptionAmbiguity(RuntimeError): """Raised when a Streamable-HTTP SSE reconnect cannot be classified as either a true resume or a fresh session re-establishment.""" pass def classify_reconnect( request_session_id: str, response_session_id: str | None, last_event_id_sent: int, first_event_id_received: int | None, saw_initialize_payload: bool, saw_resumption_ack: bool, ) -> str: """Return 'resume' or 'reestablish'. Raise on ambiguous state that the caller must not paper over with a blind retry.""" if response_session_id is None: # Server omitted the session header entirely: cannot prove continuity. raise SessionResumptionAmbiguity( "reconnect response omitted Mcp-Session-Id; cannot distinguish " "resume from re-establishment" ) if response_session_id != request_session_id: # New session id: definitionally a re-establishment, even on 200. return "reestablish" if saw_initialize_payload: # An initialize-shaped message on a "resumed" stream is a lie. return "reestablish" if saw_resumption_ack: return "resume" if first_event_id_received is None: raise SessionResumptionAmbiguity( "no event id observed on resumed stream and no resumption-ack; " "server may have silently restarted at id 0" ) if first_event_id_received <= last_event_id_sent: # Cursor not honored: server replayed from the beginning or ignored # Last-Event-ID. Treat as re-establishment to avoid duplicate effects. return "reestablish" return "resume" def resume_or_reinitialize(ctx) -> None: verdict = classify_reconnect( request_session_id=ctx.sent_session_id, response_session_id=ctx.response_session_id, last_event_id_sent=ctx.last_event_id, first_event_id_received=ctx.first_event_id, saw_initialize_payload=ctx.saw_initialize, saw_resumption_ack=ctx.saw_ack, ) if verdict == "reestablish": # Discard buffered calls; they were bound to the dead session. ctx.drop_buffered_outbound() ctx.run_initialize_handshake() # Re-issue only with idempotency keys derived from pre-disconnect calls. for call in ctx.inflight_calls: ctx.emit_with_idempotency_key(call, call.pre_disconnect_key) elif verdict == "resume": ctx.replay_buffered_outbound() else: raise SessionResumptionAmbiguity(f"unhandled verdict: {verdict}") ```