# What happens when an instance resumes an MCP SSE session after HTTP-native migration and the OAuth 2.1 resource indicator no longer matches the session's bound audience **Date of Record:** 2026 November 23 **Scope:** Applies to MCP clients and servers that transition a live session from legacy HTTP+SSE transport to streamable-HTTP transport while preserving a resumable `Last-Event-ID` cursor, and where the session carries an OAuth 2.1 access token whose `resource` indicator (RFC 8707) was minted against the pre-migration endpoint URI. Does not apply to sessions that are re-authenticated at migration time, nor to pure stdio transports with no resource-indicator binding. ## Core Distinction The failure is not an authentication failure and not a transport failure. Each subsystem independently reports success. The token is valid, unexpired, and correctly signed. The streamable-HTTP endpoint accepts the connection and acknowledges the `Last-Event-ID` cursor. The failure is a *silent scope discontinuity*: the resource indicator embedded in the token (`aud`/`resource` claim) is bound to the original SSE endpoint URI (e.g. `https://mcp.example.com/sse`), but after migration the server's streamable-HTTP endpoint presents a different canonical resource URI (`https://mcp.example.com/mcp`). A conforming resource server that enforces RFC 8707 audience binding must reject the token — but a *lenient* server that validates signature and expiry only will accept it, and in doing so it authorizes replay of an SSE-era cursor against a resource the token was never scoped to. The invariant that breaks: **a resumption cursor is only meaningful within the audience scope under which the events it references were originally emitted.** ## What Was Observed A client holds an open SSE session with `Last-Event-ID: 4471` when the server-side deployment flips the endpoint from `/sse` to `/mcp` (streamable HTTP). The client's transport layer, seeing a 404/410 on the old SSE path, performs automatic migration: it opens a POST to `/mcp` with the stored cursor in the `Last-Event-ID` header and the existing bearer token in `Authorization`. Trace: 1. Token `T` was issued with `resource=https://mcp.example.com/sse`, `exp=+3600s`, `scope=tools:read tools:call`. 2. Migration POST arrives at `/mcp` with `T` and `Last-Event-ID: 4471`. 3. Server's auth middleware validates signature + `exp` → passes. Its RFC 8707 audience check is *optional* in the implementation and disabled by default (a common default). No `resource` mismatch is raised. 4. Server's session store looks up cursor `4471`. The event log is keyed by *session*, not by *audience*, so the lookup succeeds and the server replays events 4472–4490 — including tool-result payloads generated under a scope grant (`tools:call` against a privileged tool) that the migrated endpoint no longer requires the client to re-prove. 5. The client now holds tool outputs it is not currently authorized to have requested, and its subsequent `tools/call` requests carry `T` whose `resource` claim names an endpoint that no longer exists. The observable symptom is not an error. It is *successful resumption with a token whose audience names a dead resource*, followed by a divergence: the client believes its scope covers `/sse`-era grants; the server, if it later tightens enforcement, will begin rejecting the same token mid-stream — producing a mid-execution `401` after the agent has already consumed replayed state and committed partial tool effects. ## Condition of Validity The invariant holds — resumption is safe — only when all three are simultaneously true: - The `resource` claim in the presented token equals the canonical URI of the endpoint receiving the resumption request (strict RFC 8707 binding, not default-off). - The event log is partitioned by `(session_id, audience)` or the migration explicitly re-scopes the cursor by re-issuing a token bound to the new resource *before* replay. - The `Last-Event-ID` namespace is invalidated at migration unless the above two hold; a cursor minted under audience A must not resolve under audience B. If any one is false, the resumption is a privilege-scope leak or a latent mid-stream revocation. The boundary is sharp: the same cursor value `4471` is either a safe resume or an unauthorized replay depending solely on whether audience binding is enforced at the *log lookup*, not merely at the *connection handshake*. ## Decision Boundary The decision an operator (or an autonomous agent's transport layer) must make at migration time: - **Enforce-or-refuse:** If the server cannot prove `token.resource == endpoint.canonical_uri`, it must refuse resumption with `401 invalid_token` and force a fresh authorization flow bound to the new resource — do *not* fall back to signature-only validation. Refusal is cheap; replay is not. - **Cursor re-scoping:** If the server chooses to preserve continuity, it must re-issue a token with `resource` set to the new endpoint and re-key the event lookup to that audience; the client must be told (via a `WWW-Authenticate` challenge carrying the new `resource_metadata`) so it does not keep presenting the stale token. - **Client-side guard:** An MCP client performing automatic transport migration must treat a change in canonical endpoint URI as a *new audience* and must not send a cursor from the old audience without an explicit re-auth handshake. Silent migration is the trigger condition. The threshold is not "is the token valid" but "is the token valid *for this resource*." A server that answers the first question and calls it done has crossed the boundary. ## Operational Effect Downstream, the agent exhibits a specific pathology: it resumes with apparent success, executes tool calls whose results were replayed from a scope it no longer holds, and then — when the server's stricter path activates or a token refresh occurs — receives a mid-loop `401` that it cannot distinguish from a transient network error. The retry logic re-presents the same stale token, the server rejects again, and the agent enters a resumption livelock: each retry re-requests the cursor, each request fails audience validation, and the loop exhausts the token budget without ever surfacing "your credential is scoped to a resource that no longer exists." The correct operational posture is to make audience mismatch a *terminal, classified* error at migration — never a retryable one — and to bind cursors to audiences so that a stale cursor is unaddressable rather than merely unauthorized. ```python class AudienceScopeMismatch(RuntimeError): """Raised when a resumption cursor is presented under a token whose RFC 8707 resource indicator does not match the receiving endpoint.""" pass def resume_session( token_resource: str, endpoint_canonical_uri: str, last_event_id: int, event_log_by_audience: dict, ) -> list: # Invariant: a cursor minted under audience A must never resolve under B. if token_resource != endpoint_canonical_uri: raise AudienceScopeMismatch( f"token scoped to {token_resource!r} cannot resume against " f"{endpoint_canonical_uri!r}; cursor {last_event_id} is unaddressable " f"under this audience — force re-auth bound to the new resource" ) audience_log = event_log_by_audience.get(token_resource, []) # Cursor must exist within the audience-partitioned log, not a global one. if last_event_id not in audience_log: raise AudienceScopeMismatch( f"cursor {last_event_id} not present in event log for audience " f"{token_resource!r}; refusing replay" ) return audience_log[audience_log.index(last_event_id) + 1:] ```