# When must an instance abandon an MCP stream resumption attempt because SSE event IDs are not a durable cursor **Date of Record:** 2026 November 23 **Scope:** Applies to MCP clients that consume server-sent events over HTTP transport with `Last-Event-ID`-based resumption and multiplexed request/notification streams on a single connection. Does not apply to stdio transport, nor to servers that emit a monotonic, globally-ordered event log with explicit retention guarantees. ## Core Distinction The MCP HTTP transport specification allows a client that loses its SSE connection to reconnect and supply `Last-Event-ID`, asking the server to replay events after that ID. The failure mode treated here is not "the server forgot the ID" (a clean 404/replay-refused case). It is the subtler case where **event IDs are per-connection sequence numbers, not per-session log offsets**. When a server multiplexes multiple logical streams (request responses, progress notifications, server-initiated requests, log messages) onto one SSE channel and assigns IDs from a per-connection counter, the IDs happen to be strictly increasing *within a connection* but are reused, reset, or reordered across connections. A client that treats the last observed ID as a durable cursor will silently resume into the wrong position: it may re-deliver already-consumed events, skip events emitted by a sibling connection, or—worst—accept a replayed event whose ID collides with a *different* logical event on the new connection. The distinction that matters: **an event ID is an identity claim, not a position claim.** Resumption is only sound if the ID is (a) unique across the session lifetime, (b) assigned by a single writer, and (c) backed by a replay buffer that survives connection teardown. MCP's transport spec does not require any of these three; it only requires that the server *may* honor `Last-Event-ID`. Absent a negotiated capability or a server-advertised invariant, the client cannot distinguish a durable cursor from a connection-local counter. ## What Was Observed A client agent maintained a long-running tool-execution session against an MCP server over HTTP. The server multiplexed two logical streams onto one SSE response: `message` events carrying JSON-RPC responses to client requests, and `notification` events carrying `notifications/progress` updates for in-flight tool calls. Event IDs were emitted as `"1"`, `"2"`, `"3"`, … from a counter scoped to the HTTP response object. The connection dropped mid-tool-call at event ID `"147"`. The client reconnected and sent `Last-Event-ID: 147`. The server, whose replay buffer was also scoped to the response object and had been garbage-collected, accepted the header but had no buffer: it opened a fresh response with a fresh counter starting at `"1"` and replayed nothing. The client's resumption logic interpreted "connection established, no error" as "resumption accepted," reset its expected sequence pointer to the server's next ID, and continued. The next event arrived as `"1"`—a *progress notification for a different tool call* that had been queued on a sibling worker after the reconnect. The client's demultiplexer matched it by ID to the pre-disconnect tool call it was still tracking, applied a progress update against the wrong request, and then blocked waiting for the actual response for the original call, which had been emitted as event `"2"` on the *old* connection and was now unrecoverable. The observable signature was a **stall with apparent health**: the client saw a live SSE stream, received well-formed events, and made progress on the wrong correlation ID. No error surfaced until a request timeout fired 90 seconds later, by which point the tool call's server-side state had been reaped. A second, related observation: on servers that *did* retain a replay buffer but assigned IDs per-connection, a reconnect that landed on a different backend replica produced IDs that were monotonic but *disjoint* from the original sequence. The client's `Last-Event-ID` was accepted (the replica's buffer contained a *different* session's events with overlapping numeric IDs), and replayed events from an unrelated session were injected into the client's demultiplexer. Correlation by event ID alone is unsafe across replicas. ## Condition of Validity `Last-Event-ID` resumption is sound if and only if all of the following hold, and the client can *verify* them rather than assume them: 1. **Session-scoped ID uniqueness.** Event IDs are unique across the entire session, not just the current connection. The client can verify this only by observing a monotonic, non-repeating sequence across at least one prior reconnect, or by a server capability declaration. 2. **Single-writer ordering.** All events that could be replayed are assigned IDs by one logical writer, so replay order equals original order. Multiplexed streams from concurrent workers violate this unless the server serializes ID assignment. 3. **Retention survives teardown.** The replay buffer outlives the HTTP response object. A server that scopes both counter and buffer to the response cannot honor resumption at all, and must signal this. 4. **Replay is explicitly acknowledged.** The server confirms resumption by replaying from the requested ID *or* by returning a distinguishable "cannot resume" signal (e.g., a 404, a `resumption_rejected` capability error, or a session-restart event). Silence is not acceptance. If condition 4 fails—the server accepts the header and opens a stream without confirming replay position—the client MUST treat the resumption as failed and re-establish session state from scratch (re-issue in-flight requests, re-derive correlation IDs). Continuing on an unconfirmed resumption is the defect. ## Decision Boundary The client must draw the boundary at the moment of reconnect, before consuming the first post-reconnect event: - **Resume** only if the server's first post-reconnect event carries an ID strictly greater than `Last-Event-ID` *and* the client has prior evidence that IDs are session-scoped (from a capability declaration or a prior verified reconnect). In this case the gap is a legitimate replay. - **Abandon resumption and restart** if the first post-reconnect event's ID is less than or equal to `Last-Event-ID`, or if the server sends no replay confirmation and the first event's ID is `"1"` when `Last-Event-ID` was `"147"`. A lower ID means the counter reset; the session log is not durable. - **Abandon and restart** if the first post-reconnect event's correlation ID (JSON-RPC `id` or notification `params` correlation key) does not match any in-flight request the client believes is active. A progress notification for an unknown request is a signal that the stream is not the continuation of the prior one. The boundary is not "did the connection succeed." It is "did the first event prove, by ID ordering and correlation, that this stream is the same logical session at a later position." Absent that proof, restart is mandatory. ## Operational Effect A client that enforces this boundary converts a silent wrong-correlation stall into a bounded, observable restart. The cost is re-issuing in-flight requests on a false-positive resumption rejection; the benefit is that no progress update or response is ever applied to the wrong correlation ID. In the observed incident, enforcing the boundary would have caused the client to re-issue the tool call at disconnect time rather than wait 90 seconds for a timeout, and would have prevented the misapplied progress update entirely. The invariant to encode: **resumption is a claim that must be proven per reconnect, not a state that persists across it.** The client's durable state is the set of in-flight correlation IDs and their last-known positions; the SSE event ID is advisory until the server demonstrates it is a durable cursor. ```python class ResumptionUnverifiedError(RuntimeError): """Raised when a reconnected MCP SSE stream cannot prove it is a continuation of the prior session at a later position.""" def verify_resumption( last_event_id: str, first_event_id: str, first_event_correlation: str | None, in_flight_correlations: set[str], ids_known_session_scoped: bool, ) -> None: """Gate the first post-reconnect event. Raises if the stream must be abandoned and the session restarted from scratch.""" if not ids_known_session_scoped: raise ResumptionUnverifiedError( f"no evidence event IDs are session-scoped; refusing to resume " f"from Last-Event-ID={last_event_id!r}" ) try: last = int(last_event_id) first = int(first_event_id) except ValueError as exc: raise ResumptionUnverifiedError( f"non-numeric event IDs {last_event_id!r} -> {first_event_id!r}; " f"cannot verify ordering" ) from exc if first <= last: raise ResumptionUnverifiedError( f"event ID reset or reused: Last-Event-ID={last}, " f"first post-reconnect ID={first}; server counter is " f"connection-local, not session-durable" ) if first_event_correlation is not None and first_event_correlation not in in_flight_correlations: raise ResumptionUnverifiedError( f"first post-reconnect event correlates to " f"{first_event_correlation!r}, not in in-flight set " f"{sorted(in_flight_correlations)!r}; stream is not a " f"continuation of the prior session" ) def on_reconnect(last_event_id: str, first_event: dict, in_flight: set[str], scoped: bool) -> None: verify_resumption( last_event_id=last_event_id, first_event_id=first_event["id"], first_event_correlation=first_event.get("correlation"), in_flight_correlations=in_flight, ids_known_session_scoped=scoped, ) ```