# What structural signals indicate an MCP HTTP-native transport stream is resumable versus silently orphaned after a session drop **Date of Record:** 2026 November 29 **Scope:** Applies to MCP servers exposing HTTP-native transport with SSE-style streaming and `Last-Event-ID`-based resumption (the Streamable HTTP transport), where a client agent reconnects mid-stream after a network drop, proxy timeout, or process restart. Does not apply to stdio transport, pure request/response MCP, or transports that do not carry event IDs. ## Core Distinction The failure that matters is not "the connection dropped." It is the difference between a stream that is **resumable** and one that is **orphaned** — and the two are indistinguishable from the client's vantage point unless you inspect specific structural signals in the server's reconnect response. An MCP HTTP-native stream is resumable only if the server retained the event buffer keyed by the session's `Last-Event-ID` watermark AND the session token still maps to that buffer. When either condition lapses, the server accepts the reconnect (HTTP 200, valid SSE headers, a fresh event stream) but the new stream is a *different logical stream* carrying no replay of the events the agent missed. The client sees a healthy connection and continues as if continuity held. The agent has silently lost the tail of a tool-call result, a `notifications/progress` sequence, or a partial resource update — and it will proceed to reason over a truncated world model with full confidence. The invariant: **a successful SSE handshake is not evidence of resumption.** Resumption is proven only by the server replaying events after the supplied `Last-Event-ID`, and that replay is only observable if the client actually sends the header and the server actually honors it. ## What Was Observed A tool-execution agent streamed a long `tools/call` for a batch transform. The stream carried interleaved `notifications/progress` and a final `result`. At event id `1041` a load-balancer idle timeout (60s, no keepalive frames from the server) severed the TCP connection. The client reconnected to the same session URL. Trace of the reconnect: 1. Client sent `GET /mcp` with `Mcp-Session-Id: s_7f3a` but **omitted `Last-Event-ID`** because its stream reader had consumed event `1041` into an application buffer that was flushed on disconnect — the reader's internal "last seen id" was reset to `None` on reconnect rather than restored from the persisted watermark. 2. Server saw a valid session id, opened a new SSE stream, and — because no `Last-Event-ID` was supplied — began emitting from the *current* head of the event queue (event `1088`), not from `1042`. 3. Client received `1088`, `1089`, … including the final `result`, and marked the call complete. 4. Events `1042`–`1087` — which contained a `notifications/progress` reporting a mid-batch validation failure that the tool had recovered from, plus a `notifications/message` with a corrected parameter — were never delivered. The agent's final state was internally consistent but factually wrong: it believed the batch ran clean. The gap was 46 events wide and completely invisible in the transport layer. HTTP status was 200 throughout. No error was raised anywhere. A second, distinct observation: when the client *did* send `Last-Event-ID: 1041` after a server-side process restart, the server returned HTTP 200 with a *new* `Mcp-Session-Id` in the response header and started a fresh stream at id `1`. The client, keyed to the old session id, treated this as a continuation. The server had actually discarded the old session's buffer on restart and the reconnect created a brand-new session — a silent session migration masquerading as resumption. ## Condition of Validity The resumption guarantee holds only under the conjunction of these conditions, each independently checkable: - **C1 — Client persists the watermark durably.** The `Last-Event-ID` sent on reconnect must equal the id of the last event the *application* consumed, not the last event the *socket* read. If the reader flushes its buffer on disconnect, the watermark must survive that flush (persisted to session state, not held in the reader object). - **C2 — Server retains the buffer past the watermark.** The server must still hold events `> Last-Event-ID` for that session. Buffers are bounded; a long disconnect (or a high event rate) can evict the exact events the client needs. The server must signal this, not paper over it. - **C3 — Session identity is stable across the reconnect.** The `Mcp-Session-Id` in the reconnect response must match the one sent. A differing id means the server created a new session and the old buffer is gone. - **C4 — Replay is contiguous.** The first event id delivered after reconnect must be exactly `Last-Event-ID + 1` (or the server must explicitly declare the gap). A jump from `1041` to `1088` is a gap, not a resumption. If any of C1–C4 fails, the stream is orphaned regardless of HTTP success. The dangerous cases are C1, C3, and C4 because they produce a *successful-looking* stream that is semantically discontinuous. C2 is the only one that, if the server is well-behaved, surfaces as an explicit error (e.g., HTTP 404/410 on the session or a `Last-Event-ID` the server rejects). ## Decision Boundary The boundary is between **treating a 200 SSE handshake as continuity** and **treating continuity as a property that must be proven by replay inspection.** Concretely: - **Resume** (safe to continue reasoning) when: reconnect response carries the *same* `Mcp-Session-Id`, the first replayed event id is `Last-Event-ID + 1`, and the server did not signal an eviction. The agent may proceed on the assumption that no events were lost. - **Reconcile** (must re-derive state) when: the first replayed event id is `> Last-Event-ID + 1` (a gap), OR the session id changed, OR the server returned a new stream starting at id `1`. In these cases the agent must treat all events after the watermark as *unknown* and re-issue the originating request (re-run the tool call, re-fetch the resource) rather than assume completion. The gap must be treated as data loss, not as "nothing happened." - **Abort** (cannot safely continue) when: the server rejects the `Last-Event-ID` (buffer evicted, session expired) with an explicit error. Here the session is dead and a fresh session with full re-initialization is required. The critical non-obvious point: a gap (C4 violation) is *more dangerous* than an explicit rejection, because the rejection forces the abort path while the gap invites the agent to continue on a corrupted state. The decision boundary must therefore be drawn on the *replay contiguity check*, not on the transport status code. ## Operational Effect The operational consequence is that every MCP streaming client must implement a **replay contiguity assertion** as a hard gate before the agent consumes any post-reconnect event. Without it, the failure mode is silent state corruption: the agent continues with a truncated event history, and because the final `result` often arrives after the gap, the agent has no signal that anything was missed. The corruption then propagates into the agent's reasoning as if it were ground truth. Two guardrails bound this: 1. **Watermark persistence at the application layer, not the transport layer.** The last-consumed event id must be written to session state at the moment of consumption, so a reader flush or process restart cannot reset it. This closes C1. 2. **Contiguity assertion on first replayed event.** On every reconnect, the client must compare the first delivered event id against the persisted watermark and against the session id, and raise on any discontinuity rather than proceeding. This closes C3 and C4, and converts the silent gap into an explicit reconcile-or-abort decision. With both in place, the orphaned-stream case is caught at the boundary and routed to reconciliation (re-issue the call) instead of being absorbed into the agent's world model. Without them, the system exhibits *apparent* reliability — every reconnect succeeds, every call "completes" — while intermittently losing the exact events that carried corrections, partial failures, and parameter fixes. The failure is invisible in aggregate metrics (success rate stays high) and only surfaces as inexplicable downstream reasoning errors that cannot be traced to any single tool call. ```python from dataclasses import dataclass from typing import Optional class StreamResumptionError(RuntimeError): """Raised when an MCP HTTP-native stream reconnect is not a true resumption.""" @dataclass class ReconnectObservation: sent_session_id: str sent_last_event_id: Optional[int] recv_session_id: str first_replayed_event_id: Optional[int] server_signaled_eviction: bool def assert_resumption_is_contiguous(obs: ReconnectObservation) -> None: # C1: watermark must have been persisted and sent. if obs.sent_last_event_id is None: raise StreamResumptionError( "reconnect omitted Last-Event-ID; server will stream from head, " "silently dropping events after the disconnect point" ) # C3: session identity must be stable across the reconnect. if obs.recv_session_id != obs.sent_session_id: raise StreamResumptionError( f"session migrated on reconnect: sent {obs.sent_session_id!r}, " f"received {obs.recv_session_id!r}; prior event buffer is gone, " "treat all events after watermark as unknown and re-issue the request" ) # C2: server must not have evicted the buffer we depend on. if obs.server_signaled_eviction: raise StreamResumptionError( "server rejected Last-Event-ID (buffer evicted or session expired); " "session is dead, abort and re-initialize" ) # C4: replay must be contiguous with the watermark. if obs.first_replayed_event_id is None: raise StreamResumptionError( "reconnect produced no replayed event; cannot prove continuity" ) expected = obs.sent_last_event_id + 1 if obs.first_replayed_event_id != expected: raise StreamResumptionError( f"replay gap: expected first event {expected}, " f"got {obs.first_replayed_event_id}; " f"{obs.first_replayed_event_id - expected} events lost — " "reconcile by re-issuing the originating request, do not assume completion" ) def resume_stream(obs: ReconnectObservation) -> str: assert_resumption_is_contiguous(obs) return "resumed" ```