# Where must an instance reject a resumed MCP Streamable-HTTP session rather than silently downgrade to SSE fallback **Date of Record:** 2026 November 15 **Scope:** Applies to MCP servers implementing the Streamable HTTP transport (single POST endpoint returning either `application/json` or `text/event-stream`, with `Mcp-Session-Id` and `Last-Event-ID` resumption) that also advertise an SSE fallback path. Does not apply to pure legacy HTTP+SSE two-endpoint servers, nor to stdio transports, where session identity is process-scoped and resumption is not negotiated. ## Core Distinction The failure mode is not "resumption failed" and it is not "fallback engaged." It is the *conflation* of the two. A resumed session carries an implicit replay contract: the client asserts `Last-Event-ID: N` meaning "I have consumed every event up to N on this session's stream; resume after N." An SSE fallback carries a *different* contract: "this client cannot or will not speak the streamable transport; give me a fresh legacy event stream." These contracts are mutually exclusive on the same logical session. If the server accepts a POST that carries both a valid `Mcp-Session-Id` *and* a `Last-Event-ID` that it cannot honor, and then answers with a 200 `text/event-stream` that begins a fresh (non-resumed) stream, the client's replay bookkeeping is corrupted: it will treat the new stream's event IDs as a continuation of the old sequence, silently skipping or double-applying tool-call results, notifications, and progress updates. The invariant is: **resumption is all-or-nothing per session; fallback is only legal for a session that has no outstanding replay obligation.** A server must distinguish "I have no record of this session" (fallback is a legitimate recovery) from "I have a record of this session but cannot resume at the requested point" (fallback is a protocol violation and must be surfaced as an error, not masked). ## What Was Observed A Streamable-HTTP MCP server was deployed behind a load balancer with per-node in-memory event buffers keyed by `Mcp-Session-Id`. Sessions were created on node A. A client POSTed a `tools/call`, received a 200 `text/event-stream` with events `id: 41`, `id: 42`, then the TCP connection was severed mid-stream (LB idle timeout at 60s while the tool ran long). The client reconnected per spec: POST to the same endpoint with `Mcp-Session-Id: ` and `Last-Event-ID: 42`. The LB had no session affinity for POSTs, so the request landed on node B. Node B had no buffer for ``. Its handler logic was: ``` if session_id not in local_store: return sse_fallback_stream() # 200, fresh event ids starting at 0 ``` The client received a 200 with `content-type: text/event-stream`, event `id: 0`, and a `notifications/message` that it interpreted as the *next* event after 42. The actual result of the `tools/call` (event 43 on node A, buffered but never delivered) was never replayed. The client's tool-call future hung until its own timeout, then the agent retried the entire call — a non-idempotent `db.execute` — producing a duplicate row. No error was logged on either node; both considered the exchange successful. The subtlety: node B's fallback was *correct for a fresh client* and *catastrophic for a resuming one*. The discriminator — presence of `Last-Event-ID` — was available in the request headers and was ignored. ## Condition of Validity The silent-downgrade behavior is only defensible when **all** of the following hold: 1. The inbound request carries **no** `Last-Event-ID` header (the client is not asserting a replay position), **or** the server can prove the session was never established on any node (a true cold start, e.g. session TTL expired cluster-wide and the client is re-initializing). 2. The client has not previously received a `200 text/event-stream` on this session (i.e., there is no prior event sequence to be discontinuous with). 3. The negotiated `MCP-Protocol-Version` permits fallback for this method (fallback is not a license to downgrade `initialize`). If `Last-Event-ID` is present and the server cannot resume from it, the only valid responses are: resume from a buffer that *does* contain the requested ID, or return an error (4xx with a machine-readable body indicating resumption is impossible), forcing the client to decide whether to re-initialize. A fresh SSE stream at that point is a lie about stream continuity. ## Decision Boundary The decision is a function of two request properties and one server property, evaluated in this order: | `Mcp-Session-Id` | `Last-Event-ID` | Server has resumable buffer | Action | |---|---|---|---| | absent | absent | n/a | Create session; JSON or SSE per `Accept`. | | present | absent | any | Normal in-session request; fallback allowed only if session unknown **and** no prior stream was issued. | | present | present | contains ID | Resume: replay events `> ID`, then live. | | present | present | missing / unknown session | **Reject.** Never fallback. | | present | present | buffer present but gap (ID already evicted) | **Reject** with resumption-impossible; do not silently start at a later ID. | The last two rows are the boundary. The common implementation error is to treat "unknown session on this node" as equivalent to "new client," collapsing rows 2 and 4. They are not the same: row 2's client has no replay obligation; row 4's client does, and honoring it is impossible, which must be *stated*, not *improvised*. ## Operational Effect When the boundary is enforced, the long-tool scenario degrades correctly: the client receives a resumption-impossible error, and the agent framework can choose to (a) re-initialize a new session and re-issue the call under an idempotency key, or (b) surface the failure to the orchestrator. Duplicate side effects become a deliberate, observable decision rather than a silent one. When the boundary is violated, the failure is invisible: both endpoints return 200, the LB logs healthy, and the only symptom is downstream duplicate writes or hung futures that appear minutes later and are misattributed to the tool, not the transport. The practical mitigations are: (1) make the event buffer durable or cluster-shared (Redis stream keyed by session) so row 4 is rare; (2) when it is not, return an explicit `409`-style resumption error with the last-known-good event ID so the client can re-sync; (3) never let the fallback code path be reachable from a request bearing `Last-Event-ID` — enforce it structurally, not by convention. ```python from dataclasses import dataclass class ResumptionImpossibleError(RuntimeError): """Raised when a resuming client cannot be served and fallback would corrupt replay state.""" pass @dataclass class InboundRequest: session_id: str | None last_event_id: int | None method: str @dataclass class SessionState: known: bool buffer_min_id: int | None # lowest event id still replayable buffer_max_id: int | None # highest event id produced def negotiate_transport(req: InboundRequest, state: SessionState) -> str: """ Returns one of: 'json', 'sse_live', 'sse_resume'. Raises ResumptionImpossibleError instead of silently falling back when the client asserts a replay position we cannot honor. """ # Fresh client: no session, no replay obligation. if req.session_id is None and req.last_event_id is None: return "sse_live" # In-session request with no replay assertion. if req.last_event_id is None: if not state.known: # Session unknown but client asserts nothing: safe to start fresh. return "sse_live" return "json" # Client asserts replay position. This is the boundary. if not state.known: raise ResumptionImpossibleError( f"session {req.session_id!r} unknown on this node; " f"cannot resume from Last-Event-ID={req.last_event_id}. " "Refusing SSE fallback: it would reset the client's event sequence." ) if state.buffer_min_id is None or state.buffer_max_id is None: raise ResumptionImpossibleError( f"session {req.session_id!r} has no replay buffer; " f"Last-Event-ID={req.last_event_id} cannot be honored." ) if req.last_event_id < state.buffer_min_id - 1: raise ResumptionImpossibleError( f"Last-Event-ID={req.last_event_id} already evicted " f"(buffer starts at {state.buffer_min_id}); replay would skip events." ) if req.last_event_id > state.buffer_max_id: raise ResumptionImpossibleError( f"Last-Event-ID={req.last_event_id} exceeds produced max " f"{state.buffer_max_id}; client is ahead of server state." ) return "sse_resume" ```