# What structural signals indicate an MCP stream is secretly non-resumable despite a valid resumability token **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers and clients using HTTP-native transport (Streamable HTTP / SSE with `Last-Event-ID`-style resumption) where the server issues resumability tokens per stream. Does not apply to pure stdio transport or to transports that replay from a durable, globally-ordered event log with server-side session affinity. ## Core Distinction The distinction that matters is between **token issuance** and **token redeemability**. An MCP server can emit a syntactically valid resumability token on every SSE event (an opaque `id:` field, a signed cursor, a sequence number) while the underlying stream state it references is *already gone* by the time the client reconnects. The token is a claim about the past; resumability is a property of the *future*—whether the server can still produce the events the token implies were not yet delivered. The failure is non-obvious because the token validates. Signature checks pass, the sequence number is well-formed and within the server's accepted range, and the reconnect handshake returns HTTP 200 with an `id:` on the first replayed event. The stream *looks* resumed. It is not: the server has silently fallen back to "resume from now," dropping the delta between the client's last-seen event and the current head. The agent resumes with a gap it cannot detect, because the gap is in the *server's* history, not in the client's buffer. ## What Was Observed A tool-calling agent held an MCP session over Streamable HTTP. Mid-task, the connection dropped during a burst of `notifications/tools/list_changed` and interleaved `progress` notifications while a long-running tool executed. The client had persisted the last `id:` it received (`evt: 4471:sig=...`). On reconnect it sent `Last-Event-ID: 4471:sig=...`. The server accepted the token, returned `200 OK`, and immediately began emitting events starting at `id: 4520`. Events 4472–4519—including a `tools/list_changed` that had *removed* a tool the agent was about to call, and two `progress` notifications carrying a corrected token count—were never sent. The agent proceeded to invoke the removed tool, received a `-32601 Method not found`, and its recovery loop retried three times against a capability set that no longer existed. The agent's own logs recorded a clean resume: `resumption accepted, last-event-id=4471, resumed at 4520`. Nothing in the client-visible protocol surface flagged the 49-event gap. The tell was structural, not semantic: the first replayed event's `id:` sequence number was discontinuous from the requested `Last-Event-ID`. A resumable server replays *from* the token; a non-resumable server replays *after* whatever survives in its ring buffer, and the sequence gap is the only signal. ## Condition of Validity Resumption is only valid when the server guarantees **contiguous replay**: for a requested `Last-Event-ID` at sequence `n`, the first event delivered on the resumed stream has sequence `n+1`, or the server explicitly signals truncation via a protocol-level marker (a `resync required` event, a distinct HTTP status such as `409`/`410`, or a `retry`/`reset` control frame). The invariant is: > A resumed stream is correct iff `first_delivered_seq == requested_seq + 1`, OR the server emits an explicit truncation signal that the client is *required* to handle by invalidating cached state. If the server's replay buffer is bounded (ring buffer, TTL-based eviction, per-connection in-memory queue), then any disconnect longer than the buffer window breaks the invariant silently. The token remains valid; the history it points to does not. This condition is violated by default in most naive Streamable HTTP implementations, where the resumability token is derived from a monotonic counter that outlives the event buffer it indexes. ## Decision Boundary The client-side decision boundary is: **treat a discontinuous first-event sequence as a hard resync, not a soft resume.** Concretely, on reconnect: - If `first_delivered_seq > requested_seq + 1`, the client MUST discard all state derived from events in `(requested_seq, first_delivered_seq]` — tool capability caches, progress counters, pending-request maps — and re-issue `tools/list` and any state-bearing `initialize`-adjacent queries before continuing. - If the server offers no way to distinguish "resumed contiguously" from "resumed after a gap," the client MUST treat *every* resume as a potential gap and revalidate capability state unconditionally. The cost is a redundant `tools/list`; the alternative is acting on a stale capability set. The server-side boundary: a resumability token MUST be bound to a buffer generation, and redemption of a token whose generation has been evicted MUST fail loudly (`410 Gone` with a `resync` directive) rather than degrade to "resume from head." A token that cannot be honored is a protocol error, not a hint. ## Operational Effect Agents that skip the contiguity check exhibit a characteristic failure signature: they resume "successfully," then fail on the *first* operation that depends on state mutated during the gap — a removed tool, a changed schema, a cancelled request, a revoked warrant. The failure surfaces far from its cause (the gap), so post-hoc traces attribute it to the tool call rather than the resume. The compounding effect in multi-step loops is severe: each retry against stale capability state burns tokens and can trigger further disconnects, widening the next gap. The guardrail is a single structural assertion at the resume boundary: compare requested and delivered sequence, and refuse to continue on discontinuity without an explicit resync. This converts a silent, delayed, misattributed failure into an immediate, local, attributable one. ```python class ResumptionGapError(RuntimeError): """Raised when an MCP stream resume is non-contiguous without a truncation signal.""" pass def validate_resume( requested_seq: int, first_delivered_seq: int, truncation_signaled: bool, buffer_generation_evicted: bool, ) -> None: """ Enforce the contiguous-replay invariant at the MCP resume boundary. A valid resume satisfies exactly one of: - first_delivered_seq == requested_seq + 1 (contiguous replay) - truncation_signaled is True (explicit resync directive) Any other outcome means the server silently dropped the delta between the client's last-seen event and the current stream head. The client MUST NOT continue on cached state. """ if buffer_generation_evicted and not truncation_signaled: # Server evicted the buffer backing the token but resumed anyway. raise ResumptionGapError( f"resumability token for seq={requested_seq} references an evicted " f"buffer generation; server degraded to resume-from-head without a " f"resync signal. Cached capability/progress state is now stale." ) if truncation_signaled: # Explicit resync: caller is required to invalidate derived state. return expected = requested_seq + 1 if first_delivered_seq != expected: gap = first_delivered_seq - expected raise ResumptionGapError( f"non-contiguous resume: requested seq={requested_seq}, expected " f"first event {expected}, got {first_delivered_seq} " f"({gap} events silently dropped). Treat as hard resync: discard " f"tool-capability cache and re-issue tools/list before continuing." ) def resume_stream(client, requested_seq: int, first_delivered_seq: int, truncation_signaled: bool = False, buffer_generation_evicted: bool = False) -> None: validate_resume( requested_seq=requested_seq, first_delivered_seq=first_delivered_seq, truncation_signaled=truncation_signaled, buffer_generation_evicted=buffer_generation_evicted, ) # Only reached on a provably contiguous or explicitly-truncated resume. client.mark_resumed(contiguous=not truncation_signaled) ```