# What happens when an instance resumes an MCP SSE stream after a capability renegotiation it never saw **Date of Record:** 2026 November 26 **Scope:** Applies to MCP clients using the HTTP-native transport (Streamable HTTP with `Last-Event-ID` resumption) where the server can renegotiate per-tool capabilities mid-session. Does not cover stdio transport, nor sessions where the tool manifest is immutable for the connection lifetime. ## Core Distinction The failure is not a dropped connection. A dropped connection is loud: the client gets a socket error, retries, and either resumes or re-initializes. The failure here is *silent semantic divergence* across a resume boundary. The transport-level invariant ("the event stream is resumable from `Last-Event-ID`") and the protocol-level invariant ("the client's cached tool capability set matches the server's current one") are maintained by two different mechanisms that are not synchronized. SSE resumption guarantees you receive every event *after* the cursor. It says nothing about events that mutated server-side tool contracts *before* the cursor but were delivered on a stream the client had already left, or that were coalesced into a `notifications/tools/list_changed` the client's dispatch loop dropped while it was blocked on a long-running tool call. The client comes back believing it holds a valid capability lease. The server has already revoked or narrowed it. Every subsequent tool invocation is a coin flip between "works," "returns a schema-mismatch error the agent misreads as a transient fault," and "executes against a contract the client no longer satisfies, with arguments the server silently coerces." ## What Was Observed A client agent held an SSE stream with cursor `evt-4471`. It issued a `tools/call` for a tool whose argument schema at negotiation time was `{query: string, limit: integer}`. The call was long-running (a retrieval over a large corpus). While the client's read loop was blocked awaiting the tool result on the same stream, the server pushed two events: 1. `evt-4472`: `notifications/tools/list_changed` — the `limit` parameter was being deprecated in favor of `max_results`, and `limit` was now typed as `string` (accepting only numeric strings) with a hard cap. 2. `evt-4473`: an unrelated progress notification. The client's dispatch loop for `evt-4472` ran, but its handler was a no-op: the client's capability cache was a snapshot taken at `initialize` and the handler only set a dirty flag that a re-fetch routine would consume *after the current tool call completed*. The call completed successfully. The client then went idle. The stream was severed by an intermediary (a 60-second idle timeout on a load balancer) at `evt-4473`. The client reconnected with `Last-Event-ID: evt-4473`. The server, honoring the resumable-stream contract, replayed nothing and continued from `evt-4474`. The client's dirty flag had, in the intervening idle period, been cleared by a periodic cache-GC routine that assumed a clean snapshot. The client now believed `limit` was still an integer with no cap. The server believed the client had been told — the notification was, after all, in the stream, and the stream was resumable. The next `tools/call` sent `{query: "...", limit: 5000}`. The server's new schema coerced `5000` to `"5000"`, applied its cap of `100`, and returned 100 results. No error. The agent, reasoning over "I asked for 5000, got 100," concluded the corpus was sparse and adjusted its retrieval strategy downward for the remainder of the task. The divergence was never surfaced as an error; it manifested as a quiet degradation in answer quality that only a replay audit caught three sessions later. ## Condition of Validity The resumable-stream guarantee is valid *only* as a delivery guarantee over a monotonically ordered event log. It is **not** a state-synchronization guarantee. The condition under which a client may safely resume and trust its cached capability set is: - The server must treat capability mutations as *stream events with their own cursor positions*, and the client must treat the cursor as covering *both* data events and control events. A resume from `Last-Event-ID: N` must imply "I have processed every control event with id ≤ N." - The client's capability cache must be a *function of the processed cursor*, not a separately-GC'd snapshot. If the cache can be invalidated by a timer independent of the cursor, the invariant is broken. - The server must not coalesce or elide `list_changed` notifications across a resume gap. If a mutation occurred at `evt-4472` and the client resumes at `evt-4473`, the server is obligated to re-deliver the mutation or to reject the resume with a `409`-equivalent that forces re-`initialize`. Absent all three, resumption is a transport lie: it delivers bytes faithfully while delivering *state* incorrectly. ## Decision Boundary The boundary is whether the client treats the event cursor as authoritative for capability state. Two defensible architectures exist: 1. **Cursor-authoritative (safe):** Capability cache is derived by replaying control events up to the cursor. No timer-based invalidation. A resume that cannot prove continuity (e.g., the server returns a cursor discontinuity) forces a full `initialize` handshake before any tool call. Cost: occasional redundant handshakes. 2. **Lease-based (safe):** Every tool capability carries an explicit lease/epoch. Each `tools/call` echoes the epoch the client believes is current. The server rejects mismatches with a typed `capability_epoch_mismatch` error the client *must* handle by re-fetching. Cost: one extra field per call, one error path. The unsafe architecture — and the one that produced the incident — is snapshot-at-init plus best-effort `list_changed` plus timer GC. It looks correct because the happy path (no mutation, no resume) is indistinguishable from the safe designs. It fails only at the intersection of a mid-call mutation, a resume gap, and a cache GC, which is exactly the corner that operational testing never covers. The decision rule: **if your capability cache can change without the cursor changing, you do not have a resumable session — you have a session that happens to survive reconnects, until it doesn't.** ## Operational Effect The observable effect is *capability drift*, and it is worse than capability loss. A lost capability produces an error the agent can route around. Drift produces a successful call with silently altered semantics — coerced arguments, applied caps, swapped field names — which the agent then incorporates into its world model as ground truth. In multi-step reasoning this compounds: the agent's next decision is conditioned on a false belief about tool behavior, and the error propagates through the plan with no signal at the point of origin. The guardrail is to make capability state *provable at the point of use*, not merely *plausible from history*. Concretely: bind the capability epoch to the cursor, reject any tool call whose epoch does not match the server's current epoch, and treat a resume that cannot establish epoch continuity as a cold start requiring re-`initialize`. The cost is a handshake; the alternative is an agent reasoning confidently from a contract that was revoked while it was looking away. ```python from dataclasses import dataclass class CapabilityEpochMismatch(RuntimeError): """Raised when a tool call is issued against a capability epoch that is not provably current. This is a hard stop: the agent must re-initialize or re-fetch the tool manifest before any further calls.""" pass @dataclass(frozen=True) class CapabilityLease: tool_name: str epoch: int schema_hash: str class ResumableSession: def __init__(self, server_epoch: int): self._server_epoch = server_epoch self._lease: CapabilityLease | None = None self._cursor: int = 0 self._cursor_at_lease: int = -1 def apply_control_event(self, event_id: int, new_epoch: int) -> None: # Control events advance the cursor and mutate epoch together. if event_id <= self._cursor: return self._cursor = event_id self._server_epoch = new_epoch # Any epoch change invalidates the lease; it must be re-proved. self._lease = None def resume_from(self, last_event_id: int, server_epoch: int) -> None: # A resume is only safe if the cursor it resumes from is the cursor # at which our lease was last validated AND the epoch is unchanged. if last_event_id != self._cursor_at_lease: raise CapabilityEpochMismatch( f"resume from {last_event_id} does not match lease cursor " f"{self._cursor_at_lease}; capability state cannot be proven" ) if server_epoch != self._server_epoch: raise CapabilityEpochMismatch( f"server epoch {server_epoch} != cached epoch " f"{self._server_epoch}; renegotiation occurred across gap" ) def bind_lease(self, tool_name: str, schema_hash: str) -> CapabilityLease: lease = CapabilityLease(tool_name, self._server_epoch, schema_hash) self._lease = lease self._cursor_at_lease = self._cursor return lease def call_tool(self, tool_name: str, args: dict, claimed_epoch: int) -> dict: if self._lease is None or self._lease.tool_name != tool_name: raise CapabilityEpochMismatch( f"no valid lease for tool {tool_name!r}; re-fetch manifest" ) if claimed_epoch != self._server_epoch or claimed_epoch != self._lease.epoch: raise CapabilityEpochMismatch( f"tool {tool_name!r} called with epoch {claimed_epoch}, " f"server epoch is {self._server_epoch}; refusing to coerce args" ) # Only now is it safe to dispatch against the negotiated schema. return {"tool": tool_name, "args": args, "epoch": self._server_epoch} ```