# Where must an instance reconcile Last-Event-ID against a re-negotiated transport before resuming an MCP SSE stream that fell back to streamable HTTP **Date of Record:** 2026 November 25 **Scope:** Applies to MCP clients that hold a live `text/event-stream` session (GET stream) and, on transport degradation, re-negotiate to streamable HTTP (POST-with-response-stream) before resuming. Does not apply to pure SSE sessions that never renegotiate, nor to stateless one-shot `tools/call` invocations with no resumable event cursor. ## Core Distinction The failure is not "the stream dropped." It is that the client resumes with a `Last-Event-ID` that is *semantically valid for the old transport* but *not addressable in the new one*. SSE resumption semantics and streamable-HTTP resumption semantics both carry a cursor, but the cursor namespaces are negotiated per-transport during the MCP `initialize` handshake. When fallback occurs, the server mints a *new* event-id sequence rooted in the streamable-HTTP session, while the client still holds the SSE-rooted `Last-Event-ID`. The two are numerically comparable and lexically similar—often both monotonic integers—so nothing in the transport layer rejects the mismatch. The client sends `Last-Event-ID: 41`; the streamable-HTTP session's own counter is also around 41; the server accepts the header, replays from *its* 41, and silently skips or duplicates the events between the two counters. The invariant that must hold: **an event-id is only meaningful relative to the `(transport, session-id, event-id-namespace)` triple under which it was issued.** Resumption across a transport change requires either (a) an explicit server-issued cursor translation, or (b) a full replay from a durable checkpoint the client can independently verify—never a raw carry-over of the numeric cursor. ## What Was Observed A client held an SSE stream with `Mcp-Session-Id: sse-7f3a`, having consumed events with ids `1..41`. The stream stalled (proxy idle-timeout at 60s, TCP half-open). The client's reconnect logic, per its fallback policy, issued a fresh `initialize` over streamable HTTP. The server accepted, returned a new `Mcp-Session-Id: http-9c2e`, and advertised `eventIdNamespace: "http"` in its capabilities—a field the client's resumption code did not read. The client then opened the streamable-HTTP GET-equivalent with `Last-Event-ID: 41` (carried over verbatim from the SSE session). The server's streamable-HTTP session had independently issued 38 events during the renegotiation window (heartbeats, a `notifications/tools/list_changed`, and two `progress` notifications for an in-flight tool call the client had initiated before the stall). Because `41 > 38`, the server interpreted the cursor as "already delivered," replayed nothing, and resumed live at event 42 of the *new* namespace. Trace of the divergence: 1. Client believes it has consumed through SSE-event 41. 2. Server's streamable-HTTP session has issued through http-event 38. 3. Client sends `Last-Event-ID: 41`; server compares `41 > 38`, concludes no replay needed. 4. Events http-1 through http-38 are never delivered to the client. 5. Among the lost events: the `tools/list_changed` notification invalidating a tool schema the client's in-flight call depends on, and the two `progress` notifications that would have kept the tool call's timeout watchdog alive. The observable symptom was not a transport error. It was a downstream `tools/call` that returned a schema-mismatch error 40 seconds later, and a watchdog that fired a spurious cancellation—both traceable to the skipped notifications, neither traceable to the resumption itself without the event-id namespace audit. A second variant was observed in the opposite direction: when the new namespace counter had *advanced past* the carried-over cursor (http-event counter at 55 by the time the client reconnected), the server replayed http-events 42–55, which the client—having never seen http-1 through http-41—applied as if they were a continuation of its own state. The `progress` notifications referenced a `progressToken` the client had issued in the *old* session; the client matched them to the wrong in-flight call. ## Condition of Validity The naive carry-over is only safe when *all* of the following hold, which is almost never true across a real fallback: - The server issues event-ids from a single global namespace independent of transport (rare; most implementations scope counters per session). - The renegotiation preserves the `Mcp-Session-Id` (usually false—fallback mints a new session, since the SSE session's server-side state was tied to the dead connection). - No events were emitted during the renegotiation window (false by construction—the window is exactly when in-flight notifications accumulate). - The client's resumption code reads and honors the negotiated `eventIdNamespace` / cursor-translation capability (false in every client audited here; the field was advertised but unconsumed). The invariant is valid only under a **cursor-translation contract**: the server, on accepting a renegotiated session, must either (i) reject a `Last-Event-ID` whose namespace does not match the new session and demand a checkpoint-based replay, or (ii) return an explicit `resume-from` mapping (`{old_id: 41, new_id: 1, gap_events: [...]}`) so the client can reconcile. Absent either, the client must treat the transport change as a **cold resumption**: discard the cursor, re-fetch authoritative state (`tools/list`, in-flight call status via `progressToken` query), and only then resume live. ## Decision Boundary The boundary between "safe to carry the cursor" and "must cold-resume" is drawn at the point where the client observes a change in any component of the `(transport, session-id, namespace)` triple. Concretely: - **Same transport, same session, same namespace** → carry `Last-Event-ID` verbatim. Standard SSE resumption. - **Transport changed (SSE → streamable HTTP) OR session-id changed OR namespace changed** → the cursor is not addressable. Do **not** send it as `Last-Event-ID`. Instead: (1) issue a state-reconciliation call against the new session, (2) query any in-flight `progressToken`s for authoritative status, (3) resume live from the new session's current head, treating the gap as a known, logged discontinuity. The dangerous middle ground—transport changed but session-id *appears* preserved because the server reused the string—must be treated as a change, because the server-side event counter was almost certainly re-rooted even if the id string was recycled. The client cannot distinguish "reused id, fresh counter" from "preserved id, continued counter" without an explicit server signal, so the conservative branch is mandatory. The decision must be made *before* the first resumption request, not after a replay anomaly is detected. Post-hoc detection is unreliable because the anomaly manifests as a downstream schema error or watchdog misfire, not as a resumption error—by the time it surfaces, the causal event-id gap is buried under several layers of tool-call state. ## Operational Effect The operational consequence is that **transport fallback is a state-continuity event, not a connection event.** Clients that treat it as a reconnect (carry cursor, resume) will silently drop the events emitted during the renegotiation window—precisely the events most likely to matter, because that window is when schema invalidations, progress updates, and cancellations accumulate. The dropped events are not recoverable by retry; they are gone from the client's view, and the downstream failures they cause (schema mismatches, spurious timeouts, progress-token misattribution) do not point back to the resumption. The guardrail is a hard gate in the resumption path: a `TransportResumptionGuard` that compares the pre- and post-fallback `(transport, session-id, eventIdNamespace)` triple and refuses to emit `Last-Event-ID` on any mismatch, forcing the cold-resumption path. The gate must fire *before* the request is sent, because the server will not reject the mismatched cursor—it will accept it and replay from the wrong root. The guard's refusal is the only point in the pipeline where the divergence is still localizable to the resumption decision. ```python from dataclasses import dataclass from typing import Optional class CursorNamespaceMismatch(RuntimeError): """Raised when a Last-Event-ID cursor is carried across a transport, session, or event-id-namespace change and would be misaddressed.""" pass @dataclass(frozen=True) class StreamContext: transport: str # "sse" | "streamable-http" session_id: str event_id_namespace: str last_event_id: int def resume_stream(prior: StreamContext, current: StreamContext) -> Optional[int]: """Decide whether to carry the cursor or force cold resumption. Returns the Last-Event-ID to send, or None to signal cold resumption. Raises CursorNamespaceMismatch if the caller attempts to carry a cursor across an incompatible context (defense in depth: the caller should have branched on None, not reached the raise path). """ same_transport = prior.transport == current.transport same_session = prior.session_id == current.session_id same_namespace = prior.event_id_namespace == current.event_id_namespace if same_transport and same_session and same_namespace: # Safe: standard SSE resumption within one namespace. return prior.last_event_id # Any component of the triple changed: the cursor is not addressable # in the new context. Cold resumption is mandatory. if same_session and not same_namespace: # Server reused the session id but re-rooted the counter. This is the # silent-corruption case: numeric comparison will not reject it. raise CursorNamespaceMismatch( f"session {current.session_id!r} reused across namespace change " f"{prior.event_id_namespace!r} -> {current.event_id_namespace!r}; " f"cursor {prior.last_event_id} is not addressable" ) # Transport or session changed: return None to force cold resumption. # Do NOT send prior.last_event_id as Last-Event-ID. return None def apply_resumption(prior: StreamContext, current: StreamContext) -> str: cursor = resume_stream(prior, current) if cursor is None: return ( "COLD_RESUME: reconcile tools/list and in-flight progressTokens " "against session " + current.session_id + " before resuming live" ) return f"RESUME_FROM: Last-Event-ID={cursor}" ```