# What structural signals indicate an MCP HTTP-native transport session is resumable versus silently forked **Date of Record:** 2026 November 23 **Scope:** MCP servers/clients on HTTP-native transport (SSE streaming with `Mcp-Session-Id` and `Last-Event-ID` resumption) after mid-turn interruption. Excludes stdio and single-response stateless HTTP. ## Core Distinction A *resumable* session replays from the client's cursor within the same logical session. A *silently forked* session accepts the reconnect under the same `Mcp-Session-Id` but with a fresh event sequence. Both return HTTP 200 and valid `text/event-stream`; neither status nor headers distinguish them. The difference is structural: resumable preserves monotonic event-ID lineage and server-side in-flight state (pending tool calls, partial assistant turns). Forked resets the event-ID space, orphaning the cursor while the server retains the old stream's pending work as a zombie — never delivered, never cancelled. The failure mode: **transport-layer resumption succeeding while session-state resumption fails**, producing duplicated or lost side effects with no error surfaced. ## What Was Observed Controlled interruption (TCP reset after `tools/call` emitted, before result event), three reconnects: - **Reconnect 1:** `Last-Event-ID: 41`; 200, first event `42`. Correct resume; result delivered. - **Reconnect 2** (after 90s server idle timeout, client unaware): `Last-Event-ID: 41`; 200, first event `1`. Event log GC'd but `Mcp-Session-Id` mapping retained; cursor silently discarded. Pending call had executed; result lost; client retried — side effect executed twice. - **Reconnect 3** (LB route to different replica): 200, event `1`, `Mcp-Session-Id` unknown to replica. Replica issued a *new* session ID in the response header; client ignored it, inspecting only the body. The distinguishing signal: **first event ID on the resumed stream relative to the sent `Last-Event-ID`**. Greater = true resume. `1` (or any value ≤ cursor) after a non-empty cursor = fork. Changed `Mcp-Session-Id` in the response header = replica-miss fork. None carried an HTTP error. ## Condition of Validity The "first event ID > cursor" heuristic requires strictly monotonic per-session IDs with no cross-session reuse. Invalid when: - Per-connection sequence numbers are used (stateless-behind-proxy): a legitimate resume restarts at `1`; false positives. - IDs are opaque (UUIDs, timestamps): heuristic inapplicable; require a `resume-token` or explicit `resumed: true` field in the first event. - Interruption preceded durable cursor recording: replay from an earlier point is correct; first event ID may equal the cursor. Invariant in all valid cases: *the union of events across the original and all resumed streams, keyed by event ID, equals the server's intended sequence for the logical turn.* Any gap or duplicate is the detectable violation. ## Decision Boundary **Treat a resumed stream as forked unless the first received event ID is strictly greater than the sent `Last-Event-ID` AND the response `Mcp-Session-Id` equals the request's.** On failure, the client must: 1. Issue an explicit `tools/call` status query (or session `ping` with the original request ID) to determine completion. 2. Deduplicate side effects via an idempotency key derived from the original request ID, not stream position. 3. If the server cannot confirm the request ID, treat the turn as failed and surface it — do not silently retry. Below the boundary, resumption is safe and transparent. Above it, resumption is a lie and must become an explicit recovery protocol. ## Operational Effect Without this check, failure is silent and asymmetric: the server logs a clean 200 and completed execution; the client logs a clean reconnect and a result timeout; the retry double-executes. Production symptoms: duplicated writes, double-charged payments, repeated non-idempotent API calls — no error in either log. Enforcing the structural check converts the silent fork into a detectable `SessionForkDetected` condition at the cost of one extra round-trip on the rare fork path. The trade is correct: a detectable false-positive recovery costs latency; an undetectable fork costs correctness. ```python from dataclasses import dataclass class SessionForkDetected(RuntimeError): """Raised when a resumed MCP HTTP-native stream is structurally a fork.""" pass @dataclass class ResumedStream: sent_last_event_id: int sent_session_id: str first_event_id: int response_session_id: str def validate_resumption(stream: ResumedStream) -> None: if stream.response_session_id != stream.sent_session_id: raise SessionForkDetected( f"session id changed on resume: sent={stream.sent_session_id!r} " f"got={stream.response_session_id!r}; replica miss or new session" ) if stream.first_event_id <= stream.sent_last_event_id: raise SessionForkDetected( f"event-id space reset: cursor={stream.sent_last_event_id} " f"first_event={stream.first_event_id}; pending turn state orphaned" ) def resume_or_recover(stream: ResumedStream) -> str: validate_resumption(stream) return "resumed" ```