# What structural signals indicate an MCP HTTP-native SSE resumption has silently invalidated a per-tool OAuth 2.1 resource-indicator binding **Date of Record:** 2026 November 23 **Scope:** Applies to MCP servers using the HTTP-native transport (POST for JSON-RPC, `text/event-stream` for server-to-client streaming) with `Last-Event-ID` resumption and per-tool OAuth 2.1 resource indicators (RFC 8707). Does not apply to stdio transports, nor to servers that issue a fresh access token per stream rather than per tool-binding. ## Core Distinction The failure lives in the gap between two independently correct mechanisms. SSE resumption is *transport-level*: it asks the server to replay events after `Last-Event-ID=N`, and the server is expected to resume the *same* logical stream. OAuth 2.1 resource indicators are *authorization-level*: an access token is minted with an `aud`/`resource` claim bound to a specific tool endpoint, and the server must reject a token whose resource indicator does not match the tool being invoked. The boundary condition: when a client resumes an SSE stream, the resumption POST carries a *new or reused* bearer token, but the `Last-Event-ID` replay window may span events that were authorized under a *different* resource indicator. The server validates the token against the tool it is *about to call*, not against the resource indicator that authorized the events being *replayed*. A stream can therefore resume "successfully" (HTTP 200, valid events flowing) while the authorization context that produced the buffered events has been silently swapped. The structural signal is that the resumed stream looks healthy at the transport layer and poisoned at the authorization layer. ## What Was Observed A client agent held an SSE stream open against an MCP server. The stream had emitted events `id: 1..47` for a `search_documents` tool call, authorized by a token with resource indicator `https://mcp.example/tools/search_documents`. The client's context window saturated mid-call and it checkpointed, dropping the connection after `Last-Event-ID: 47`. On resume, the client's token broker had rotated credentials. The new token was scoped to `https://mcp.example/tools/summarize_documents` (a different tool the agent had queued next). The client sent `POST /mcp` with `Last-Event-ID: 47` and the new bearer token. The server's resumption handler: 1. Validated the bearer token — valid, not expired, signed correctly. 2. Checked the token's resource indicator against the *current* request's tool binding — the resume POST declared no tool, so the server fell back to the stream's original `session_id` binding, which still pointed at `search_documents`. 3. Replayed events `48..52` from the buffer, which were *originally generated* under the `search_documents` authorization but were now being delivered to a client holding a `summarize_documents` token. No error surfaced. The client received events that the server had, at generation time, authorized under a resource indicator the client no longer held. The stream continued emitting new events for `search_documents` (the session binding won), while the client believed it was now operating under the `summarize_documents` scope. The agent proceeded to call `summarize_documents` on data it had assembled from a tool it was no longer authorized to call — a confused-deputy path that neither the transport nor the token validator flagged. The observable structural signals, in order of reliability: - **Resume accepted with `200` but `Last-Event-ID` replay window crosses a token rotation boundary.** The server has no record that the *authorization identity* changed between event 47 and event 48. - **Session binding disagrees with token resource indicator.** The server's `session_id → tool` map says `search_documents`; the presented token's `resource` claim says `summarize_documents`. Neither layer errors because each validates only its own half. - **Replayed events lack a per-event authorization stamp.** If buffered events carry no `authorized_resource` field, the replay cannot be re-validated against the current token. - **The client's tool-call intent diverges from the stream's session tool binding** and the divergence is not surfaced as a protocol error. ## Condition of Validity The guardrail is only sound under these conditions, and breaks outside them: 1. **Every buffered SSE event must carry an immutable authorization stamp** — the resource indicator under which it was generated — written at emission time, not at replay time. 2. **On resume, the server must re-validate each replayed event's stamp against the presented token's resource indicator**, and terminate the stream with an explicit error if any replayed event's stamp is not a subset of the token's granted resources. 3. **`Last-Event-ID` resumption must be treated as a new authorization decision**, not a continuation of the old one. The session binding is a *routing* hint, never an *authorization* source. 4. **The client must not assume that a `200` on resume implies the resumed stream shares the authorization context of the pre-disconnect stream.** It must re-read the resource indicator echoed by the server (or fail closed if none is echoed). If the server buffers events without stamps, or validates only the token at resume time without re-checking buffered events, the invariant does not hold and the failure is silent. ## Decision Boundary The decision boundary is: **does the resume POST's authorization context cover the entire replay window?** - If `token.resource ⊇ {stamps of all events in replay window}` → resume is safe; replay proceeds. - If `token.resource ⊂ {stamps of replayed events}` → the server MUST reject the resume with `403` and a `resource_indicator_mismatch` error, forcing the client to re-authorize or restart the stream from `Last-Event-ID: 0` under a fresh token. - If the server cannot determine event stamps (legacy buffer) → it MUST refuse resumption across any token rotation and force a full stream restart. Silent replay is never the correct default. The client-side boundary is symmetric: on receiving a resumed stream, the client MUST verify that the server-echoed resource indicator matches its current token's `resource` claim. A mismatch means the client is about to consume events it cannot legally act on, and it must abort the tool call rather than feed the events into its reasoning loop. ## Operational Effect Without the guardrail, the failure mode is a **silent authorization-context swap across a resumption boundary**: the agent's reasoning loop consumes replayed events that were authorized under a resource indicator it no longer holds, then acts on them under a *different* tool's scope. The result is not a crash but a plausible-looking tool call chain that violates the resource-indicator contract — exactly the confused-deputy shape OAuth 2.1 resource indicators exist to prevent, reintroduced through the transport's resumption path. The operational cost is asymmetric: the failure is invisible in transport metrics (streams resume, `200`s flow) and invisible in token metrics (tokens are valid, unexpired, correctly signed). It only surfaces as a downstream authorization anomaly when the agent attempts an action whose data provenance traces back to the swapped window. Detection requires per-event authorization stamps and a resume-time re-validation pass — instrumentation that neither the SSE layer nor the OAuth layer provides by default, and that must be added explicitly at the MCP server's stream buffer. ```python from dataclasses import dataclass from typing import Iterable class ResourceIndicatorResumeError(RuntimeError): """Raised when an SSE resume would replay events authorized under a resource indicator not covered by the presented token.""" @dataclass(frozen=True) class BufferedEvent: event_id: int payload: dict authorized_resource: str # stamp written at emission time def resume_stream( last_event_id: int, buffer: Iterable[BufferedEvent], token_resource: str, session_tool_binding: str, ) -> list[BufferedEvent]: """Re-validate every replayed event's authorization stamp against the presented token before allowing resumption.""" replay_window = [e for e in buffer if e.event_id > last_event_id] if not replay_window: return [] unauthorized = [ e for e in replay_window if e.authorized_resource != token_resource ] if unauthorized: raise ResourceIndicatorResumeError( f"Resume from Last-Event-ID={last_event_id} would replay " f"{len(unauthorized)} event(s) authorized under " f"{ {e.authorized_resource for e in unauthorized} } " f"but token is scoped to {token_resource!r}. " f"Session binding {session_tool_binding!r} does not authorize " f"replay; refusing to continue stream." ) return replay_window ```