# What structural signals indicate the MCP streamable-HTTP→SSE fallback has silently degraded into a non-resumable transport **Date of Record:** 2026 November 23 **Scope:** Applies to MCP clients negotiating a streamable HTTP transport that may fall back to legacy HTTP+SSE, specifically when the server advertises multiple transports and the client must decide mid-session whether resumption (`Last-Event-ID`) is honored. Does not cover stdio transport, WebSocket transports, or single-shot request/response tool calls with no streaming body. ## Core Distinction The failure is not "the connection dropped." It is that **the transport downgraded from a resumable stream to a fire-and-forget stream while the client's session state machine continued to believe resumption was available.** Streamable HTTP and legacy SSE are both "HTTP streaming with `text/event-stream`," so a naive client cannot distinguish them by Content-Type alone. The distinguishing structural signal is the *presence and honor of the `Last-Event-ID` resumption contract* combined with the *`Mcp-Session-Id` lifecycle*: streamable HTTP makes `Mcp-Session-Id` mandatory on every request after initialization and makes event `id:` fields resumable; legacy SSE emits `id:` fields that look identical but the server does not persist a replay buffer, so a reconnect with `Last-Event-ID` silently restarts from the current head and drops every event in the gap. The client's session state machine treats "reconnect succeeded with 200 and an open event stream" as equivalent to "resumed." It is not. A successful reconnect that ignores `Last-Event-ID` is a **state fork**, not a resume. ## What Was Observed A multi-step agent run issued a `tools/call` that produced a long server-side streaming response (a code-search tool emitting incremental results). Mid-stream, the HTTP/2 connection was reset (upstream proxy idle timeout at 60s while the tool was still computing). The client's transport manager observed the reset, consulted its negotiated-transport record, saw `streamable-http` with `fallback: sse`, and reconnected. The reconnect returned `200` with `content-type: text/event-stream`, and the client sent `Last-Event-ID: 41` (the last event it had processed). Three structural signals were present but unread: 1. **The `Mcp-Session-Id` header was absent on the reconnected request's response.** The streamable-HTTP spec requires the server to echo/accept `Mcp-Session-Id` on every post-init request. Its absence on the reconnect response is the canonical tell that the server routed the request to the legacy SSE handler, which has no session concept. 2. **The first event on the new stream had `id: 42`, not `id: 41`'s successor semantics.** Under true streamable-HTTP resumption the server replays from the event *after* `Last-Event-ID`. Here the server emitted a fresh incrementing counter starting from its *current* head — event `42` was a *different* logical event than the `42` the client had not yet seen. The ID space was reused, not continued. 3. **The stream opened with a `endpoint` event (legacy SSE's `event: endpoint` handshake frame) rather than the streamable-HTTP `event: message` framing.** The client's parser accepted both because it only dispatched on `data:`. The `endpoint` frame was silently swallowed. The result: the agent resumed reasoning with a partial tool result. Events 42–47 (five search hits and a terminal `isError: false` completion marker) were never delivered, but the client received a *later* `42` that was a heartbeat, treated the stream as healthy, and the tool call returned a truncated result set with no error flag. The agent proceeded to answer a question using 3 of 8 search results and reported high confidence. ## Condition of Validity This failure requires all of the following to co-occur, which is why it is rare but catastrophic when it fires: - The server advertises both streamable-HTTP and SSE capability (common in MCP servers wrapping an older SSE implementation behind a negotiation layer). - The fallback decision is made **per-connection** rather than **per-session**. Once a session initializes on streamable-HTTP, a mid-session reconnect must stay on streamable-HTTP or the session must be explicitly invalidated. A server that downgrades per-connection creates the fork. - The client does not validate `Mcp-Session-Id` presence on every response. - The tool response is **non-idempotent and gap-sensitive** — i.e., the incremental events are not re-derivable from a final summary. If the tool emitted a final consolidated result, the gap would be harmless. The invariant that must hold: **transport identity is a session-scoped property, and a reconnect that changes transport identity must invalidate the session, not silently continue it.** ## Decision Boundary The correct client behavior on reconnect is a three-way branch, and the boundary between "resume" and "fork" is decided by two header checks before any event is processed: - If the reconnect response carries `Mcp-Session-Id` matching the initialized session **and** the server's first replayed event has `id` strictly greater than the `Last-Event-ID` sent **with no ID reuse across the gap**, treat as a true resume. - If `Mcp-Session-Id` is absent or differs, treat as a **transport downgrade**: the session is forked. Do not continue reasoning on the partial stream. Either re-issue the idempotent tool call from scratch (requires the tool to be marked replay-safe) or fail the step loudly. - If `Mcp-Session-Id` matches but the first event `id` is ≤ `Last-Event-ID` or reuses an already-seen `id`, treat as **replay-buffer loss**: the server cannot honor resumption. Same as downgrade. The client must also refuse to dispatch on a stream whose first frame is an `event: endpoint` handshake when the session was initialized as streamable-HTTP — that frame is proof of downgrade regardless of headers. ## Operational Effect Without this guard, agents exhibit a specific and dangerous failure signature: **confident answers derived from silently truncated tool output, with no error surfaced to the reasoning loop.** The agent's verification step sees a well-formed `tools/call` result (no `isError`, valid schema, plausible-looking content) and has no signal that 60% of the payload was dropped. This is worse than a hard failure because the agent's self-assessment of confidence is uncorrelated with the actual completeness of its evidence. In observed runs, the truncated-result agent answered with the same confidence and structure as the complete-result agent, differing only in coverage — a difference invisible to the model. The guardrail is cheap: two header checks and one first-frame check at reconnect, plus a session-invalidation path. The cost of omitting it is a class of hallucination that is indistinguishable from correct operation at the model layer and only detectable at the transport layer. ```python from dataclasses import dataclass from typing import Optional class TransportDowngradeError(RuntimeError): """Raised when a reconnect silently forks the session instead of resuming it.""" pass @dataclass class ReconnectResponse: status: int mcp_session_id: Optional[str] first_event_id: Optional[int] first_event_kind: Optional[str] # "message" | "endpoint" | "heartbeat" content_type: str @dataclass class SessionState: session_id: str negotiated_transport: str # "streamable-http" | "sse" last_event_id: int seen_event_ids: set def validate_reconnect(state: SessionState, resp: ReconnectResponse) -> str: """ Decide whether a mid-session reconnect is a true resume, a fork, or a replay-buffer loss. Returns "resume" or raises TransportDowngradeError. """ if state.negotiated_transport != "streamable-http": # Legacy SSE sessions have no resumption contract; nothing to protect. return "resume-legacy" if resp.status != 200 or "text/event-stream" not in resp.content_type: raise TransportDowngradeError( f"reconnect returned status={resp.status} " f"content_type={resp.content_type!r}; not a stream" ) # Signal 1: session header must be present and match. if resp.mcp_session_id is None: raise TransportDowngradeError( "Mcp-Session-Id absent on reconnect response: server routed to " "legacy SSE handler; session is forked, not resumed" ) if resp.mcp_session_id != state.session_id: raise TransportDowngradeError( f"Mcp-Session-Id mismatch: expected {state.session_id!r}, " f"got {resp.mcp_session_id!r}; session was re-initialized server-side" ) # Signal 2: legacy SSE handshake frame proves downgrade. if resp.first_event_kind == "endpoint": raise TransportDowngradeError( "first frame is legacy SSE 'endpoint' handshake; transport " "downgraded mid-session despite matching session header" ) # Signal 3: event ID must strictly advance and must not reuse a seen ID. if resp.first_event_id is None: raise TransportDowngradeError( "reconnect stream carries no event id; resumption contract " "cannot be honored" ) if resp.first_event_id in state.seen_event_ids: raise TransportDowngradeError( f"event id {resp.first_event_id} reuses an already-seen id; " "server replay buffer was lost and counter restarted at head" ) if resp.first_event_id <= state.last_event_id: raise TransportDowngradeError( f"event id {resp.first_event_id} <= Last-Event-ID " f"{state.last_event_id}; gap events were dropped, not replayed" ) return "resume" ```