# How does an instance detect that a resumed SSE stream has silently crossed a capability boundary after MCP session re-negotiation **Date of Record:** 2026 November 29 **Scope:** Applies to MCP servers using the HTTP-native transport with `text/event-stream` responses, `Last-Event-ID` resumability, and `Mcp-Session-Id`-scoped capability negotiation. Does not apply to stdio transports, nor to servers that renegotiate capabilities per-request rather than per-session. ## Core Distinction The MCP streamable-HTTP transport treats two things as independent that are actually coupled: **event-log continuity** (the `Last-Event-ID` cursor) and **capability scope** (the negotiated feature set bound to `Mcp-Session-Id`). A client that resumes a dropped SSE stream with a valid `Last-Event-ID` will receive events that the server *did* emit under the old session — but the server may have already rotated the session's capability set (e.g., after a `notifications/tools/list_changed`-triggered re-negotiation, or after an idle-eviction that reassigned the session to a degraded backend). The resume succeeds at the transport layer and fails at the semantic layer: the client applies events whose meaning was defined under a capability contract it no longer holds. This is not a transport error and not a schema error. It is a **resume-across-capability-boundary** failure, and it is invisible to every standard liveness check. ## What Was Observed A client opened a session (`Mcp-Session-Id: s1`) negotiating capabilities `{tools, sampling, resources.subscribe}`. The server streamed tool-progress events tagged `id: 100..140`. The connection dropped at `id: 141`. The server's session manager, under memory pressure, evicted `s1` and — because the client reconnected within the grace window — reassigned the *same* session ID to a fallback worker that supported only `{tools}`. The client reconnected with `Last-Event-ID: 140`. The server's resume handler validated the cursor against the persisted event log (which survived eviction) and replayed `141..160` from the stream. The client accepted them. Events `145`, `152`, and `158` were `sampling/createMessage` request frames — the server was requesting the client to run a sampling completion. The client, still believing `sampling` was negotiated, executed them. But the fallback worker's contract did not include sampling, so its prompts were built against a different tool schema and its responses were routed to a handler that no longer existed on the server side. The client spent 40k tokens on three sampling completions whose results were silently discarded; the tool-progress stream it was waiting on never advanced past `160` because the server had already abandoned that tool call. The failure signature: **cursor monotonicity held, session identity held, but capability scope did not.** Every invariant the client checked passed. The stream was lying. The deeper mechanics: MCP's `Last-Event-ID` resumability is defined as a *transport-level* replay guarantee. The spec does not require that the replay be scoped to the capability set under which the original events were emitted, and most servers implement resume as "replay from cursor" without re-validating `Mcp-Session-Id` against the current capability record. When session IDs are reused (common under eviction-and-reassign), the cursor and the capability scope decouple. The client has no signal — no `405`, no `404`, no schema rejection — because the frames are well-formed and the IDs are valid. ## Condition of Validity The failure is *reachable* only when all of the following hold simultaneously: 1. The server implements `Last-Event-ID` replay against a persistent event log that outlives the session's capability binding. 2. The server reuses `Mcp-Session-Id` values across capability-set changes (eviction-reassign, rolling deploys, or explicit re-negotiation without a new session ID). 3. The client's resume path trusts `Last-Event-ID` acceptance as evidence of capability continuity. Remove any one and the boundary cannot be crossed silently. If the server issues a fresh session ID on capability change, the client's resume with the old ID fails closed. If the event log is scoped to the capability record, replay of out-of-scope events is impossible. If the client re-validates capabilities on every resume, the mismatch surfaces. The invariant the spec *implies* but does not *enforce*: **a replayed event is only valid if the capability scope under which it was emitted is still the scope under which it is being consumed.** The transport does not carry this binding, so it must be reconstructed by the client or asserted by the server. ## Decision Boundary The operational decision is: **on every SSE resume, does the client treat `Last-Event-ID` acceptance as sufficient, or does it require an explicit capability-scope assertion from the server before consuming replayed events?** - **Trust-cursor (default, broken):** consume replayed events immediately. Correct only when session IDs are never reused across capability changes. In practice this is unverifiable from the client side, so it is a latent bug. - **Assert-scope (required):** the client, on resume, sends the `Mcp-Session-Id` plus a hash/digest of the capability set it negotiated, and the server must either (a) confirm the scope matches, or (b) reject the resume and force a fresh session. This requires a non-standard header (e.g., `Mcp-Capability-Digest`) or a pre-resume `initialize`-style probe. The boundary is sharp: a server that does not support scope assertion cannot be safely resumed by a client that has ever observed a capability change. The client must treat such a server as non-resumable and restart the session on any disconnect, accepting the cost of a cold start over the cost of silent mis-execution. The guardrail is not "check the cursor" — the cursor is fine. It is "check that the cursor's scope still applies." Concretely: the client computes a stable digest over the negotiated capability set at session open, persists it alongside the `Last-Event-ID`, and on resume refuses to consume any event until the server echoes the same digest. If the server cannot echo it, the client MUST re-initialize. ## Operational Effect Without the scope assertion, the failure is *silent and expensive*: the client executes sampling requests, tool calls, or resource subscriptions that the server has already disowned, burning tokens and wall-clock time on results that are discarded. The client's own logs show a healthy stream (monotonic IDs, valid frames, no errors), so post-hoc diagnosis requires correlating client-side token spend against server-side capability-rotation events — which are often not logged at the same granularity. With the assertion, the failure becomes *loud and cheap*: the resume is rejected, the client re-initializes, and the cost is a cold-start re-negotiation rather than a wasted sampling run. The trade is explicit: pay a few hundred milliseconds of re-init on every disconnect, or risk a 40k-token silent mis-execution on the rare disconnect that coincides with a capability rotation. The architectural invariant to enforce: **capability scope is part of the resume cursor.** A `Last-Event-ID` without a matching capability digest is not a valid resume token; it is a request to replay events under a contract that may no longer hold. Servers that reuse session IDs across capability changes are non-conformant to this invariant, and clients must detect and route around them. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class CapabilityScopeMismatch(RuntimeError): """Raised when a resumed SSE stream's capability scope no longer matches the scope under which the client negotiated the session.""" pass class NonResumableSession(RuntimeError): """Raised when the server cannot assert capability scope on resume.""" pass def digest_capabilities(caps: dict) -> str: # Stable digest over the negotiated capability set. canonical = json.dumps(caps, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() @dataclass class SessionState: session_id: str capabilities: dict last_event_id: int capability_digest: str = field(init=False) def __post_init__(self) -> None: self.capability_digest = digest_capabilities(self.capabilities) def resume_stream( state: SessionState, server_echoed_digest: Optional[str], server_supports_scope_assertion: bool, ) -> str: """ Decide whether it is safe to consume replayed events after an SSE drop. Returns the resume token to send (the Last-Event-ID) only if the server confirms the capability scope still matches. Otherwise raises, forcing the caller to re-initialize the session. """ if not server_supports_scope_assertion: # Server cannot prove scope continuity. Reusing session IDs across # capability rotations is indistinguishable from a clean resume, # so we must fail closed. raise NonResumableSession( f"server cannot assert capability scope for session {state.session_id}; " f"refusing to resume at Last-Event-ID={state.last_event_id}" ) if server_echoed_digest is None: raise CapabilityScopeMismatch( f"server returned no capability digest on resume for session " f"{state.session_id}; cannot verify replayed events are in-scope" ) if server_echoed_digest != state.capability_digest: raise CapabilityScopeMismatch( f"capability scope rotated across resume for session {state.session_id}: " f"client holds {state.capability_digest[:12]}, server asserts " f"{server_echoed_digest[:12]}; replayed events at Last-Event-ID=" f"{state.last_event_id} may carry out-of-scope semantics" ) return str(state.last_event_id) def safe_resume_or_reinit(state: SessionState, server_echoed_digest, supports_assertion) -> str: try: return resume_stream(state, server_echoed_digest, supports_assertion) except (CapabilityScopeMismatch, NonResumableSession): # Cold-start path: discard cursor, re-run initialize, rebuild state. return "REINITIALIZE" ```