# Under what conditions must an instance renegotiate MCP SSE resumption after an OAuth 2.1 token audience shift, and what breaks when it does not **Date of Record:** 2026 December 3 **Scope:** Applies to MCP clients using the HTTP-native transport (streamable HTTP with `GET` SSE resumption via `Last-Event-ID`) bound to an OAuth 2.1 resource server whose access token carries an `aud`/`resource` claim scoped to a specific MCP server endpoint. Does not apply to stdio transport, nor to deployments where the authorization server issues audience-agnostic tokens or where resumption is disabled (`Mcp-Session-Id` not persisted). ## Core Distinction The failure is not "token expired" and it is not "SSE stream dropped." Both of those are well-understood and produce clean 401/404 signals that clients already handle. The boundary case is subtler: **the token remains cryptographically valid and unexpired, but its resource binding (`aud`/`resource` claim) no longer matches the endpoint the resumption request is being sent to.** This happens when an MCP server is behind a gateway that rotates backend instances across distinct resource identifiers, when a session migrates between regional replicas that each register as separate OAuth 2.1 resource servers, or when the client re-resolves the server's `resource` metadata mid-session via a fresh `/.well-known/oauth-protected-resource` fetch. The dangerous property: resumption requests carry the `Last-Event-ID` header, and the server-side event log is keyed by session, not by audience. A server that validates the token's signature and expiry but *does not* re-validate the audience against its own resource identifier will accept the resumption, replay events from the log, and hand the client a stream that is now authorized under a stale binding. The client believes continuity is preserved. It is not: the events it replays may originate from a session whose authorization context was established under a different resource scope, and any tool-call results embedded in those replayed events were produced under the old grant. ## What Was Observed A client held an active MCP session against `https://mcp-a.example.net/sse` with a token whose `aud` was `https://mcp-a.example.net`. The gateway fronting the MCP server performed a rolling deploy: `mcp-a` was re-registered as `https://mcp-a-v2.example.net` (new resource identifier, same logical server, same session store). The client's SSE connection dropped mid-stream at event ID `4821`. Per spec, the client reconnected with `GET /sse` and `Last-Event-ID: 4821`, presenting the *same* bearer token. Three distinct outcomes were observed across replicas: 1. **Strict replica:** returned `401` with `WWW-Authenticate: Bearer resource_metadata="https://mcp-a-v2.example.net/.well-known/oauth-protected-resource"`. Client correctly re-fetched metadata, saw the new `resource` value, and knew its token audience was stale. 2. **Lenient replica:** validated signature and `exp` only, accepted `Last-Event-ID: 4821`, and replayed events `4822–4837`. Among those events was a `tool_result` for a `filesystem.read` call that had been authorized under the *old* resource scope. The client resumed reasoning on that result as if continuity held. It did not: the tool result was now being consumed under a session whose effective authorization had silently drifted. 3. **Confused replica:** returned `404` on the resumption (event log not found because the session store had been repartitioned), which the client interpreted as "session gone, start fresh" — losing 16 events of context with no error surfaced to the agent's reasoning loop. The lenient case is the boundary failure. It is the only one that produces *silent* continuity corruption rather than a loud error. ## Condition of Validity Resumption is only sound when **all three** of the following hold simultaneously: - The `Last-Event-ID` refers to an event in a log whose entries were produced under the same OAuth 2.1 resource binding as the token now being presented. - The server re-validates the token's `aud`/`resource` claim against its *current* registered resource identifier on every resumption request, not only on session establishment. - The client, upon receiving a `401` whose `WWW-Authenticate` names a different `resource_metadata`, treats the session as **audience-invalidated** — it must discard the resumption intent and re-run the full negotiation, not retry the same `Last-Event-ID` against the new resource. If any one fails, the invariant "replayed events are consumed under the authorization context that produced them" is violated. The failure is undetectable from the event payload alone, because MCP event frames do not carry the resource binding that authorized them — they carry only `id`, `event`, and `data`. The binding lives out-of-band in the token, and the token is not re-checked against the log. ## Decision Boundary The precise decision the client must make on any resumption attempt: - **If** the resumption `GET` returns `200` and the stream resumes: proceed, *but only if* the server's resource metadata (fetched at session start) still matches the token's `aud`. If the client has any signal — a `WWW-Authenticate` header on a prior request, a changed `resource` in re-fetched metadata, a session-migration hint — that the audience shifted, it must **not** trust the `200`. It must force renegotiation. - **If** the resumption returns `401` with `resource_metadata` naming a resource different from the token's `aud`: do not retry with the same token. Discard the session, re-fetch `/.well-known/oauth-protected-resource`, re-acquire a token scoped to the new resource, and restart the session from scratch (no `Last-Event-ID`). - **If** the resumption returns `404`: the event log is gone; surface this as an explicit continuity break to the agent's reasoning loop, never as a silent fresh start. The agent must be told its context has a hole. The boundary is: **a `200` on resumption is necessary but not sufficient for continuity.** Continuity requires `200` *and* audience stability *and* event-log provenance matching the current binding. ## Operational Effect Agents that skip the audience-stability check exhibit a specific pathology: they resume mid-task with replayed tool results that were authorized under a grant the current token no longer covers. Downstream, this manifests as the agent taking actions (via new tool calls) that the *current* token authorizes but that are logically predicated on results the *old* grant produced — a confused-deputy condition scoped to a single session's event log. The agent's reasoning is internally consistent; only the authorization provenance is broken. This is invisible to output validators because the outputs are well-formed. The guardrail is a **resumption gate** that couples three checks atomically: token audience vs. current resource metadata, `Last-Event-ID` provenance vs. session's establishing binding, and explicit continuity-break signaling to the reasoning loop on any mismatch. The gate must run *before* any replayed event is admitted to the agent's context. ```python from dataclasses import dataclass class AudienceDriftOnResume(RuntimeError): """Raised when an SSE resumption would replay events under a stale OAuth 2.1 resource binding.""" pass @dataclass class ResumeContext: token_aud: str current_resource: str last_event_id: int session_establishing_resource: str http_status: int def admit_resumption(ctx: ResumeContext) -> bool: # Loud failures first: never silently restart on 404. if ctx.http_status == 404: raise AudienceDriftOnResume( f"event log for Last-Event-ID={ctx.last_event_id} is gone; " "continuity break must be surfaced to reasoning loop, not masked as fresh start" ) # 401 with a different resource_metadata is a renegotiation trigger, not a retry. if ctx.http_status == 401: if ctx.current_resource != ctx.token_aud: raise AudienceDriftOnResume( f"token aud={ctx.token_aud!r} does not cover resource={ctx.current_resource!r}; " "discard session and re-run OAuth 2.1 negotiation" ) return False # The subtle case: 200 but audience drifted since session establishment. if ctx.http_status == 200: if ctx.token_aud != ctx.current_resource: raise AudienceDriftOnResume( f"resumption 200 but token aud={ctx.token_aud!r} != current resource {ctx.current_resource!r}" ) if ctx.session_establishing_resource != ctx.current_resource: raise AudienceDriftOnResume( f"session was established under {ctx.session_establishing_resource!r} but resuming under " f"{ctx.current_resource!r}; replayed events {ctx.last_event_id}+ have stale provenance" ) return True return False ```