# Under what conditions must an instance reject a resumed MCP SSE stream when OAuth 2.1 resource indicators change mid-session **Date of Record:** 2026 November 14 **Scope:** Applies to MCP servers exposing HTTP-native transport (POST + `text/event-stream`) with `Last-Event-ID` resumability and per-tool OAuth 2.1 resource indicators (RFC 8707). Does not apply to stdio transports, to servers that bind a single resource indicator for the whole session, or to streams that have never been interrupted (no `Last-Event-ID` presented). ## Core Distinction A resumed SSE stream is not a continuation of the *request*; it is a continuation of the *authorization context* under which the original event sequence was produced. The `Last-Event-ID` token is an opaque pointer into server-side replay state, and that replay state was materialized under a specific access token, a specific `resource` indicator, and a specific set of scopes. When a client reconnects with `Last-Event-ID` plus a *fresh* bearer token whose `resource` claim targets a different tool endpoint, the server faces a fork: replay events minted under resource A into a stream now authorized against resource B, or refuse the resume and force a fresh stream. The non-obvious failure is that the naive implementation *accepts* the resume, because the token validates and the event ID resolves. Both halves of the resume are individually valid; only their *composition* is invalid. This is an invariant violation across the (token, event-ID) pair, not a failure of either component. ## What Was Observed During a multi-tool session, a client held a stream open against `resource=https://mcp.example.com/tools/search`. A mid-stream tool call to `resource=https://mcp.example.com/tools/fetch` required a step-up authorization (broader scope, distinct resource indicator). The client performed the OAuth 2.1 exchange, obtained a new access token bound to the `fetch` resource, and — because the transport layer reconnects transparently on network blips and the reconnect code path reused the *current* token from the credential store — presented: ``` GET /mcp/stream HTTP/1.1 Authorization: Bearer Last-Event-ID: 8842 ``` The server resolved event `8842` in the replay log (originally produced under the `search` resource), replayed events `8843..8851` (search results, including partial document fragments), and then continued the live stream. The client received search-scoped payloads on a stream it now believed was authorized for `fetch`. No error surfaced. The audit log showed a single stream with a `resource` claim of `fetch` and replayed content that had been gated under `search`. The inverse case also occurred: after a token refresh that *narrowed* scope (downscoped token for a read-only tool), the resumed stream replayed events that the narrowed token could no longer have generated, effectively re-granting access to historical output the current authorization would not permit. ## Condition of Validity The resume is only valid when all of the following hold for the `Last-Event-ID` being presented: 1. The `resource` claim in the presented token equals the resource indicator under which the event sequence was originally minted (stored as stream metadata at event creation time). 2. The scope set of the presented token is a superset of the scope set recorded on the replay log entry for that stream. 3. The `sub` (and, where present, `client_id`) match the principal that opened the stream. 4. The event ID has not been reaped — i.e., it is within the replay window and not past the server's retention horizon. If any of 1–3 fails, the resume is a *reauthorization event*, not a *reconnection*, and must be treated as a new stream. If 4 fails, the resume is impossible regardless of authorization and the client must reissue the original MCP request from scratch. ## Decision Boundary The boundary is between two superficially identical HTTP requests: - **Reconnection:** same principal, same `resource`, same-or-broader scope, valid event ID → replay and continue. - **Reauthorization:** same principal, *different* `resource` or *narrower* scope, valid event ID → refuse replay, return `409 Conflict` (or `403` with a `WWW-Authenticate` challenge naming the required resource), and require a fresh request. The trap is treating the OAuth token as the sole authorization gate. The token authorizes the *current* request; it does not authorize the *replay history*. Replay history carries its own authorization provenance that must be re-checked at resume time. Servers that validate only the token and the event ID will silently cross the boundary — and the crossing is invisible because both halves pass their local checks. A second boundary: when the client presents a token whose `resource` differs but whose scope is a strict superset, do *not* accept on the reasoning that the broader token "covers" the original. Resource indicators are not hierarchical; `fetch` does not imply `search`, and a superset of scopes on the wrong resource is still the wrong resource. ## Operational Effect When the boundary is enforced correctly, the client observes a `409` on resume and must re-issue the original MCP request under the new token. This costs a full round-trip and re-execution of the tool call, but it preserves the invariant that every byte delivered on a stream was authorized under the resource indicator stamped on that stream's replay log. When the boundary is *not* enforced, three failure modes appear in production: - **Cross-resource leakage:** replay of tool output into a stream authorized for a different tool, defeating per-tool isolation. - **Scope regression:** downscoped tokens silently regain access to historical output produced under broader scopes. - **Audit desynchronization:** the stream's recorded `resource` claim describes the *current* token, not the provenance of the replayed events, so post-hoc audit cannot reconstruct which authorization context produced which bytes. The fix is to stamp each replay log entry with `(resource, scope_set, sub, client_id)` at mint time and to re-validate that stamp against the presented token on every resume — treating a mismatch as a hard refusal, not a warning. ```python import dataclasses from typing import FrozenSet class StreamResumeAuthorizationError(RuntimeError): """Raised when a Last-Event-ID resume is presented under an authorization context that does not match the provenance of the replayed events.""" @dataclasses.dataclass(frozen=True) class StreamProvenance: resource: str scopes: FrozenSet[str] subject: str client_id: str @dataclasses.dataclass(frozen=True) class PresentedToken: resource: str scopes: FrozenSet[str] subject: str client_id: str def validate_resume( provenance: StreamProvenance, presented: PresentedToken, event_id_in_window: bool, ) -> None: if not event_id_in_window: raise StreamResumeAuthorizationError( f"event {event_id_in_window!r} outside replay window; " "client must reissue original MCP request" ) if presented.resource != provenance.resource: raise StreamResumeAuthorizationError( f"resource indicator mismatch on resume: stream minted under " f"{provenance.resource!r}, token presented for {presented.resource!r}" ) if not provenance.scopes.issubset(presented.scopes): missing = provenance.scopes - presented.scopes raise StreamResumeAuthorizationError( f"scope regression on resume: missing {sorted(missing)} required " f"to replay stream minted under {provenance.resource!r}" ) if presented.subject != provenance.subject: raise StreamResumeAuthorizationError( "principal mismatch on resume; treating as new stream" ) if presented.client_id != provenance.client_id: raise StreamResumeAuthorizationError( "client_id mismatch on resume; treating as new stream" ) ```