# What structural signals indicate SSE resumption has silently crossed an OAuth 2.1 resource-server binding boundary in MCP streamable HTTP transport **Date of Record:** 2026 November 26 **Scope:** Applies to MCP servers using the streamable HTTP transport with SSE resumability (`Last-Event-ID` replay) and OAuth 2.1 resource-server token validation per-request. Does not apply to stdio transport, nor to servers that treat the SSE stream as stateless (no event store) or that bind tokens at session creation only. ## Core Distinction The MCP streamable HTTP transport permits a client to reconnect to an interrupted SSE stream and resume via `Last-Event-ID`, requesting replay of all events after that ID. OAuth 2.1 resource-server binding, per RFC 8707 and the MCP authorization spec, requires that every HTTP request carry a bearer token whose `aud` (or resource indicator) matches this server, and that the token be validated on *that* request. These two mechanisms compose badly: the resume request is a *new* HTTP request that carries a *new* (or refreshed) token, but the replayed event stream was originally generated under a *previous* token's authorization context. The failure is not that resumption fails. The failure is that resumption *succeeds* while the replayed events were authorized under a principal, scope, or audience that the current request's token no longer represents — or, symmetrically, that the replay is *rejected* because the event store keys on the old token and the new token's `jti`/`sub` does not match, producing a silent gap the client cannot distinguish from "no more events." The structural signal is a divergence between the *identity under which events were persisted* and the *identity under which they are being replayed*, with no field in the SSE frame or resume response that surfaces the mismatch. ## What Was Observed A tool-calling agent session against an MCP server with a 15-minute access-token TTL and a 10-minute SSE keep-alive idle window. The agent issued `tools/call` for a long-running operation; the server emitted progress notifications as SSE events `id: 41..58`, each tagged internally with the token's `sub` and `scope`. At event 58 the token expired mid-stream. The client's SSE connection dropped (server closed on the next request-time validation), the client refreshed the token via its authorization server, and reconnected with `Last-Event-ID: 58` and the new bearer token. Three observed variants across deployments: 1. **Silent principal swap.** The event store was keyed only by `session_id`, not by `sub`. The new token belonged to the same human but a different OAuth client (a delegated sub-agent). Replay of events `59..72` proceeded, but those events had been generated under the original client's `scope: tools:write`. The new token carried `scope: tools:read`. The server had already executed the writes; the replay delivered the *results* of write-authorized execution to a read-only principal. No error was raised because replay reads from the store, not from a re-authorized execution path. 2. **Silent gap on `jti` mismatch.** The event store keyed on hash of the access token. New token, new key, empty result set. The server returned `200 OK` with an empty event stream and immediately closed. The client interpreted an empty replay as "stream complete" and advanced its cursor. Events `59..72` — including the terminal `result` for the tool call — were never delivered. The agent's task hung until an unrelated timeout fired. 3. **Audience confusion across resource servers.** A gateway fronted two MCP servers, A and B, sharing an event store for cost reasons. A resume request bearing a token with `aud: server-A` was routed to server B's stream endpoint after a load-balancer failover. B validated the token against its own audience and *rejected* it — correct — but the client saw a `401` on a resume, treated it as terminal, and abandoned the session rather than re-resolving the endpoint. In all three, the transport-level invariant ("resume delivers the contiguous event suffix after `Last-Event-ID`") and the authorization invariant ("every delivered byte is authorized by the presenting token") were each individually satisfied by some component, and violated in composition. ## Condition of Validity The resumability guarantee is only sound when the following holds at the moment of replay: - The event store partitions events by a key that is *at least as restrictive* as the token's authorization context — concretely, by `(session_id, sub, client_id, aud)` or a hash thereof, not by `session_id` alone. - The resume handler re-validates the token *and* compares its authorization context against the context recorded on the stored events it is about to emit, failing closed on any mismatch rather than emitting a partial or empty suffix. - An empty replay result is distinguishable, in the protocol, from a completed replay. MCP's streamable transport does not currently mandate a terminator event that distinguishes these; deployments must add one (e.g., a synthetic `resume_complete` event with the server's last-known event ID) or the client cannot tell "caught up" from "lost the tail." - The `aud`/resource indicator in the token matches the server instance that owns the event store partition being read. Shared event stores across resource servers violate this unless the partition key includes `aud`. When any of these does not hold, the transport still functions; it simply stops being a resumption of the *same authorized stream*. ## Decision Boundary The operational decision is where to place the authorization check relative to the replay read: - **Check-before-read (recommended).** Validate token, extract `(sub, client_id, aud, scope)`, then query the event store with that tuple as part of the key. Mismatch yields a `403` with a machine-readable reason (`resume_principal_mismatch`), never an empty `200`. This makes the failure loud. - **Read-then-filter (rejected).** Read the full suffix by `session_id`, then filter events by current scope. This silently drops events the client's cursor has already passed, producing a *hole* in the sequence that violates SSE's contiguity contract and is undetectable by `Last-Event-ID` alone. - **Re-authorize-and-replay (situational).** For read-only replays of already-executed effects, permit replay if the new token's `sub` matches and the events are non-mutating results; require re-execution otherwise. This must be an explicit policy flag on the server, not an emergent behavior of the store's key. The boundary is crossed the moment a resume request is served from a store partition whose key does not include the full authorization tuple of the presenting token. Below that line, resumption is safe; above it, the client is receiving bytes it cannot prove it is entitled to, or is missing bytes it believes it has. ## Operational Effect For an autonomous agent, the practical consequence is that `Last-Event-ID` is an *unauthenticated cursor*. It is client-supplied, monotonic-looking, and carries no binding to the token that produced the events it points past. An agent that trusts a `200` on resume as proof of continuity will, under principal or audience change, either act on results it was not authorized to see or proceed with a task whose terminal event it never received. The correct client-side discipline is to treat every resume response as untrusted until it contains an explicit `resume_complete` marker whose embedded event ID is `>=` the last ID the client held before disconnect; absent that marker, the client must re-issue the original request rather than advance its cursor. The correct server-side discipline is to key the event store on the full authorization tuple and to fail closed with a distinguishable error on mismatch. Neither discipline is enforced by the protocol; both must be built. ```python from dataclasses import dataclass class ResumeBindingError(RuntimeError): """Raised when an SSE resume crosses an OAuth 2.1 resource-server binding boundary.""" @dataclass(frozen=True) class AuthContext: sub: str client_id: str aud: str scope: frozenset[str] @dataclass(frozen=True) class StoredEvent: event_id: int auth: AuthContext def resume_stream( last_event_id: int, presenting: AuthContext, event_store: dict[int, StoredEvent], server_aud: str, ) -> list[StoredEvent]: # 1. The presenting token must be bound to *this* resource server. if presenting.aud != server_aud: raise ResumeBindingError( f"token aud={presenting.aud!r} does not match server aud={server_aud!r}; " "resume would replay events authorized for a different resource server" ) # 2. Collect the contiguous suffix after the client's cursor. suffix = [e for eid, e in sorted(event_store.items()) if eid > last_event_id] if not suffix: # Empty is ambiguous: caught-up vs. wrong-partition. Fail closed. raise ResumeBindingError( f"empty replay after Last-Event-ID={last_event_id}; cannot distinguish " "stream completion from authorization-partition mismatch" ) # 3. Every replayed event must have been persisted under a context # compatible with the presenting token. Scope may narrow, never widen. for ev in suffix: if ev.auth.sub != presenting.sub or ev.auth.client_id != presenting.client_id: raise ResumeBindingError( f"event {ev.event_id} persisted under sub={ev.auth.sub!r}/" f"client={ev.auth.client_id!r}, replay requested under " f"sub={presenting.sub!r}/client={presenting.client_id!r}" ) if not ev.auth.scope.issubset(presenting.scope): raise ResumeBindingError( f"event {ev.event_id} requires scope {sorted(ev.auth.scope)}, " f"presenting token carries {sorted(presenting.scope)}" ) return suffix ```