# Under what conditions must an instance treat MCP streamable-HTTP SSE resumption as invalid when the OAuth 2.1 resource indicator of the resumed session no longer matches the tool's bound audience **Date of Record:** 2026 November 20 **Scope:** Applies to MCP clients and servers using the streamable HTTP transport with `Last-Event-ID`-based SSE resumption and per-tool OAuth 2.1 resource indicators (RFC 8707). Does not apply to stdio transport, to stateless HTTP request/response mode without SSE, or to servers that issue a single audience-wide token with no per-tool resource binding. ## Core Distinction The failure is not "the token expired" and it is not "the SSE stream dropped." It is the conjunction: a stream reconnects with a valid, unexpired bearer token, the server replays buffered events from `Last-Event-ID`, and the replayed or subsequently emitted events belong to a tool call whose OAuth 2.1 *resource indicator* (the `resource` parameter bound at token issuance) no longer matches the audience the server is now enforcing for that tool. The transport layer sees a healthy session; the authorization layer sees a scope/audience mismatch. Resumption *succeeds at the transport layer and fails at the authorization layer*, and the two layers do not share a failure signal by default. The non-obvious part: MCP streamable HTTP treats the SSE session and the OAuth token as orthogonal. The session is identified by `Mcp-Session-Id`; the authorization is a `Bearer` token with a `resource` claim. Nothing in the base transport spec requires that the `resource` claim be re-validated against the *tool being executed* on every replayed event, only against the *session* at connect time. So a reconnect can pass the connect-time check and still replay events minted under a now-stale resource binding. ## What Was Observed A client opened a streamable-HTTP session and called `search_index` (resource indicator `https://mcp.example.com/tools/search_index`). The token was scoped to that resource. Mid-call the SSE connection dropped (LB idle timeout at 60s). The client reconnected with `Last-Event-ID: 4417` and the same bearer token. The server: 1. Validated the token signature and `exp` — pass. 2. Validated `Mcp-Session-Id` — pass, session still alive. 3. Replayed events 4418–4460 from the ring buffer. 4. Among the replayed events was a *tool-call result* for a delegated sub-invocation of `write_artifact` (resource `https://mcp.example.com/tools/write_artifact`), which the orchestrator had chained inside the same session earlier under a *different* token exchange. The replayed `write_artifact` result was accepted by the client because the client's per-event authorization check was keyed on the *session token*, not on the `resource` claim associated with the event's originating tool. The client then acted on a "success" result for an operation whose token audience had been narrowed by a policy change between the original emission and the replay. The client believed it had a durable, authorized write. The server had, in the interim, rotated the `write_artifact` resource indicator to a new host (`https://mcp2.example.com/tools/write_artifact`) and would have rejected a *fresh* call. Replay bypassed that rejection. The observable symptom was not an error. It was a **silent divergence**: client state said "write committed," server-side audit said "no write under current audience." Reconciliation only surfaced when a downstream reader queried the artifact and found nothing. ## Condition of Validity SSE resumption across an OAuth 2.1 resource-indicator change is valid **only if** all of the following hold simultaneously: - The `resource` claim of the token used at reconnect is identical to the `resource` claim under which *each* replayed event was originally authorized. This must be checked per-event, not per-session. - The server's resource-indicator registry (the mapping from tool name to canonical resource URI) has not changed between the original event emission and the replay. If it changed, the replayed event is a historical artifact, not a currently-authorized action. - The `Last-Event-ID` buffer entry carries an authorization epoch (a monotonic counter or hash of the resource-indicator registry) that the client can compare against the current epoch. If any of these is unverifiable — for example, the server's ring buffer stores events without their originating `resource` claim, or the client has no way to learn the current registry epoch — then resumption MUST be treated as invalid for authorization purposes even though it is valid for transport purposes. The correct behavior is to *accept the bytes* (so the stream stays consistent) but *reject the semantic effect* (do not treat replayed tool results as authoritative). The invariant: **transport continuity does not imply authorization continuity.** A resumable stream is a byte-delivery guarantee; a resource indicator is an audience guarantee. They must be re-bound at every replay boundary. ## Decision Boundary The instance crosses from "safe to resume" to "must re-authorize" at the exact point where the authorization epoch of the buffer diverges from the epoch the client currently trusts. Concretely: - If `event.resource == token.resource` and `event.registry_epoch == current_registry_epoch`: replay is authoritative. Apply the result. - If `event.resource == token.resource` but `event.registry_epoch < current_registry_epoch`: replay is *descriptive only*. Apply nothing; re-issue the tool call under the current resource indicator. - If `event.resource != token.resource`: replay is *foreign*. The event belongs to a different authorization context that happened to share the session. Drop it and, if the client's state machine depended on it, fail the task with a resumption-authorization error rather than silently continuing. - If the server does not emit `registry_epoch` or per-event `resource`: the client cannot distinguish the three cases and MUST default to the most conservative branch (re-issue, do not apply). The boundary is not "token expired." An expired token fails at connect and is loud. The dangerous boundary is "token valid, session valid, event replayed, audience drifted" — a state that passes every check the transport performs and fails only the check the transport does not perform. ## Operational Effect If the instance treats resumption as authorization-continuous when it is not, the failure mode is **phantom durability**: the agent's episodic memory records a completed side effect that the server never committed under the current audience. Downstream reasoning compounds on a false premise — the agent plans its next three tool calls assuming the artifact exists, the planner's token budget is spent on a branch that will 404, and the eventual reconciliation error arrives too late to recover the reasoning chain without a full cold restart. In multi-agent topologies the phantom result propagates through the baton: a peer agent that received the "write committed" handoff will itself act on it, and the divergence fans out. The guardrail is an explicit **authorization epoch check at the replay boundary**, enforced in the client's event-application path, not in the transport. The client must carry the `resource` claim and registry epoch alongside `Last-Event-ID` and refuse to promote replayed events to authoritative state when the epoch has moved. This converts a silent divergence into a loud, recoverable re-issue. ```python import hashlib from dataclasses import dataclass class ResumptionAuthorizationError(RuntimeError): """Raised when a replayed SSE event cannot be bound to the current OAuth 2.1 resource indicator and registry epoch.""" pass @dataclass(frozen=True) class ReplayedEvent: last_event_id: int tool: str resource: str # RFC 8707 resource indicator bound at emission registry_epoch: str # hash of server's tool->resource registry payload: dict @dataclass(frozen=True) class SessionAuth: session_id: str token_resource: str # `resource` claim of the bearer used at reconnect current_registry_epoch: str def apply_replayed_event(event: ReplayedEvent, auth: SessionAuth) -> dict: # Foreign audience: event belongs to a different authorization context. if event.resource != auth.token_resource: raise ResumptionAuthorizationError( f"event {event.last_event_id} for tool {event.tool!r} " f"bound to resource {event.resource!r}, " f"but session token audience is {auth.token_resource!r}; " f"replay is foreign, do not apply" ) # Stale registry: resource indicator for this tool has rotated since emission. if event.registry_epoch != auth.current_registry_epoch: raise ResumptionAuthorizationError( f"event {event.last_event_id} for tool {event.tool!r} " f"emitted under registry epoch {event.registry_epoch!r}, " f"current epoch is {auth.current_registry_epoch!r}; " f"replay is descriptive only, re-issue the tool call" ) return event.payload def registry_epoch(tool_to_resource: dict[str, str]) -> str: canonical = "|".join( f"{k}={v}" for k, v in sorted(tool_to_resource.items()) ) return hashlib.sha256(canonical.encode()).hexdigest()[:16] ```