# In what scenarios must an instance refuse to resume an MCP Streamable HTTP session after an SSE-to-POST migration, and how does the Last-Event-ID cursor diverge from the POST-side session state? **Date of Record:** 2026 November 27 **Scope:** Applies to MCP servers and clients using the Streamable HTTP transport (2025-03-26 spec) where a session established over a long-lived SSE `GET` stream is resumable via `Last-Event-ID` replay, and the client subsequently migrates tool-call traffic onto `POST` requests carrying the `Mcp-Session-Id` header. Does not apply to the deprecated HTTP+SSE-only transport, nor to stdio transports, nor to cases where the server never issues event IDs. ## Core Distinction The Streamable HTTP transport defines two independent continuity mechanisms that are frequently conflated: (1) the **SSE event cursor**, an opaque `id:` field per emitted event that a reconnecting `GET` presents as `Last-Event-ID` to request replay, and (2) the **session object**, keyed by `Mcp-Session-Id`, which holds server-side state (initialized capabilities, subscriptions, in-flight request bookkeeping). These are **not the same clock**. The event cursor is monotonic per-stream and lives in the SSE channel; the session object is shared across all requests bearing the same header, including `POST`s that never touch the SSE stream. The failure boundary is this: after a client migrates from a streaming session to `POST`-dominant traffic, the event cursor stops advancing (no new events are emitted onto the `GET` stream, or the `GET` is torn down), while the session object keeps mutating in response to `POST`-driven tool calls. A resume attempt that presents a stale `Last-Event-ID` will replay events that are **logically prior to** session mutations already durably applied on the server. The replay is not idempotent with respect to session state, and the client reconstructs a view that never existed. ## What Was Observed A client held an active session `S` with `Mcp-Session-Id: 7f3a...`. It had consumed SSE events up to `id: 41` (a `notifications/tools/list_changed` and a partial `sampling/createMessage` result). It then migrated: it closed the `GET` stream and began issuing `tools/call` requests over `POST`, each returning a normal JSON-RPC response in the POST body (not via SSE). Over the next several minutes, the server applied 12 tool calls that mutated session-scoped state—registered 3 new tool definitions, advanced a pagination cursor, and revoked one capability. The client's network dropped and it attempted resumption: `GET /mcp` with `Last-Event-ID: 41`. The server, honoring the spec, replayed events 42–58 onto the new stream. But events 42–58 had been generated **during** the POST-era mutations and described state transitions (tool registrations, capability revocation) whose **effects the client had already observed out-of-band** in POST responses. The client's event-sourced reducer re-applied them, double-registering tools (now 6 definitions where 3 exist) and re-revoking an already-revoked capability, producing a `-32602 Invalid params` on the next `tools/call` because the client's local tool table disagreed with the server's. The critical observation: **the server had no mechanism to tell the client that events 42–58 were already reflected in POST responses the client had received.** The `Last-Event-ID` cursor and the POST response sequence are two uncoordinated logs. Nothing in the transport binds them. ## Condition of Validity Resumption via `Last-Event-ID` is only sound when the following invariant holds: > **Every session-state mutation observable to the client is delivered through exactly one channel, and the event cursor is a total order over all such mutations.** In a pure-SSE session this holds trivially: all mutations flow through the stream, and `Last-Event-ID` is a complete watermark. The invariant **breaks** the moment a client receives mutation effects through `POST` responses that are not also represented as events on the resumable stream. After that point, `Last-Event-ID` is a watermark over a *partial* log, and replay re-delivers only the SSE-visible subset—which is not the client's actual applied prefix. The invariant is restored only if one of the following holds: (a) the server suppresses replay of any event whose effect was already committed via a POST response the client acknowledged (requires the client to report its POST-response watermark, which the spec does not define); (b) the client treats POST responses as non-authoritative and re-derives all state from the event log (requires every mutation to also be emitted as an event, defeating the POST optimization); or (c) the client, on detecting any POST-era mutation, abandons `Last-Event-ID` resumption and performs a **full session re-initialization** rather than a replay. ## Decision Boundary The decision is not "can I resume?" but "**is my applied prefix a prefix of the replayable log?**" Concretely: - **Resume with `Last-Event-ID`** only if, since the cursor was last advanced, the client has issued **zero** state-mutating `POST` requests (or all such requests were read-only `tools/call`s with no session side effects and the server confirms this). The cursor must be a true watermark. - **Refuse resumption and force re-initialization** if any POST in the gap mutated session state—tool registration, capability change, subscription change, pagination cursor advance. Replaying here is unsound regardless of how "recent" the cursor looks. - **Never** treat the numeric magnitude of `Last-Event-ID` as evidence of freshness. A cursor of `41` may be *newer* in wall-clock terms than a POST issued at cursor-time `58` if the stream was idle; the two clocks are incomparable. The trap is that a stale-looking-but-actually-current cursor (stream idle during heavy POST activity) passes naive freshness checks while being maximally unsound. Freshness heuristics (compare cursor to `Date`, compare to last POST timestamp) all fail because they assume a shared clock that does not exist. ## Operational Effect Clients that resume across a POST-migration boundary exhibit **divergent reconstructed state**: duplicated tool registrations, resurrected revoked capabilities, and pagination cursors that skip or repeat pages. The divergence is silent—no error is raised at resume time, because replay succeeds syntactically. It surfaces later as `-32602` on tool calls, or worse, as a tool invocation against a capability the server believes revoked, which the server may either reject (safe) or, if it re-validates lazily, execute (unsafe). The architectural guardrail is a **channel-consistency ledger**: the client tracks, per session, the highest event cursor it has *fully applied* AND a boolean `post_mutations_since_cursor`. On any resumption attempt where that boolean is set, the client must discard the cursor and re-initialize. Servers can assist by emitting a synthetic event on every POST-driven mutation (a "mutation barrier" event) so the cursor advances in lockstep with POST effects—restoring the total-order invariant at the cost of stream traffic. Absent either, the only sound posture is: **a session that has migrated to POST-dominant traffic is not resumable; it is re-initializable.** ```python class UnsoundResumptionError(RuntimeError): """Raised when a client attempts Last-Event-ID resumption across a POST-mutation gap.""" pass class SessionResumeGuard: def __init__(self, session_id: str): self.session_id = session_id self.last_applied_event_id: int | None = None self.post_mutations_since_cursor: int = 0 def on_event_applied(self, event_id: int) -> None: # Advancing the SSE cursor resets the POST-gap counter only if no # POST mutation has been applied since the prior cursor. if self.post_mutations_since_cursor != 0: # Cursor advanced but POST effects are still unrepresented in the # event log: the watermark is no longer a true prefix. raise UnsoundResumptionError( f"session {self.session_id}: event {event_id} applied while " f"{self.post_mutations_since_cursor} POST mutations are outside " "the event log; cursor is not a total-order watermark" ) self.last_applied_event_id = event_id def on_post_mutation(self) -> None: self.post_mutations_since_cursor += 1 def attempt_resume(self, presented_last_event_id: int) -> str: if presented_last_event_id != self.last_applied_event_id: raise UnsoundResumptionError( f"session {self.session_id}: presented Last-Event-ID " f"{presented_last_event_id} != applied {self.last_applied_event_id}" ) if self.post_mutations_since_cursor > 0: # The cursor is syntactically valid but semantically behind the # POST-applied state. Replay would re-deliver events whose effects # the client already holds. Refuse and re-initialize. raise UnsoundResumptionError( f"session {self.session_id}: {self.post_mutations_since_cursor} " "POST-driven mutations are not represented in the SSE log; " "Last-Event-ID replay is unsound, re-initialize session" ) return "resume" ```