# Under what conditions must an instance re-negotiate MCP tool authorization when an SSE session resumes as streamable HTTP and the resource indicator no longer matches **Date of Record:** 2026 November 30 **Scope:** Applies to MCP clients and servers that migrate a live session from the legacy HTTP+SSE transport to the streamable-HTTP transport while preserving a `Mcp-Session-Id`, and that bind OAuth access tokens to per-tool resource indicators (RFC 8707). Does not cover fresh sessions, stdio transport, or servers that do not enforce resource-indicator binding on tool invocation. ## Core Distinction The distinction that matters is between *session continuity* and *authorization continuity*. A resumable transport migration preserves the former cheaply — the `Mcp-Session-Id` header, the last-seen `Last-Event-ID`, and the server-side session object survive the switch from a long-lived SSE `GET` stream to paired streamable-HTTP `POST`/`GET`. Nothing in that handshake forces the OAuth access token to be re-examined against the resource indicator of the tools the session will now call. Authorization continuity is a separate invariant: **for every tool invocation, the audience (`aud`) of the bearer token presented must equal the resource indicator the client declared when the token was minted, and that indicator must match the resource the server maps the tool to.** Session resumption does not re-derive this. A token minted for `https://mcp.example.com/sse` (the SSE endpoint as resource) carries an `aud` that a streamable-HTTP server validating against `https://mcp.example.com/mcp` will reject — or, worse, a permissive validator will accept because it only checks signature and expiry, silently granting the tool call under an audience it was never issued for. The migration is the trigger; the invariant is the audience binding. ## What Was Observed A client held an SSE session against an MCP server exposing `search_documents` and `write_record`. The OAuth flow had requested a token with `resource=https://mcp.example.com/sse`, and the server's SSE handler validated `aud == https://mcp.example.com/sse` on each tool call relayed over the event stream. The session ran for ~40 minutes, then the client's SSE connection dropped (proxy idle timeout). The client reconnected using the streamable-HTTP transport, replaying: ``` POST /mcp HTTP/1.1 Mcp-Session-Id: 7f3a... Last-Event-ID: 812 Authorization: Bearer eyJ... ``` The server's streamable-HTTP endpoint resumed the session — the `Mcp-Session-Id` matched, the replay from `Last-Event-ID` succeeded, and pending server-to-client messages were delivered. Then the client issued `tools/call` for `write_record`. The streamable-HTTP tool dispatcher validated the token against its own resource indicator, `https://mcp.example.com/mcp`. Two outcomes were observed across deployments: 1. **Strict validator:** `401 invalid_token`, `error="invalid_target"`. The session was alive, the replay was intact, but every subsequent tool call failed. The client had no signal that the *transport* succeeded and the *authorization* failed — it interpreted the 401 as a transient transport error and retried the resume three times before surfacing a generic "session lost" to the orchestrator. 2. **Permissive validator:** the token's signature and expiry checked out, `aud` was not compared to the endpoint's resource indicator. `write_record` executed. The audit log recorded the call under a resource the token was never scoped to. This is the dangerous case: the migration *succeeded* and silently widened the token's effective audience from the SSE endpoint to the streamable-HTTP endpoint. The non-obvious part: the failure is not in the resume logic and not in the token validation logic taken alone. It is in the seam — the server treats "session resumed" as "authorization established," and the client treats "session resumed" as "no re-auth needed." Neither side re-runs the resource-indicator derivation that the initial OAuth flow performed. ## Condition of Validity The invariant holds — i.e., the migration is safe without re-authorization — only when all of the following are true: - The resource indicator declared at token issuance is *transport-agnostic*: it identifies the MCP server resource, not a specific endpoint path (`https://mcp.example.com`, not `.../sse` or `.../mcp`). - The server's streamable-HTTP validator compares `aud` to the same resource identifier the SSE handler used, and both map to the same canonical resource. - The `Mcp-Session-Id` is bound server-side to the token's subject and audience at session creation, and the resume path re-checks that binding rather than trusting the session ID alone. - No tool's required scope changed between the two transport endpoints (e.g., a tool exposed only on streamable HTTP that the SSE-era token was never scoped for). If any of these fails, the migration crosses an authorization boundary and the token must be re-derived (new OAuth authorization request with the streamable-HTTP resource indicator, or a token exchange) before any `tools/call` is accepted on the resumed session. ## Decision Boundary The decision boundary is: **does the resumed transport's resource indicator equal the `aud` of the presented token, and is that binding re-verified on the resume request?** - If `aud` matches the streamable-HTTP resource indicator and the session-to-token binding is intact → resume without re-auth. This is the fast path and is correct only under the conditions above. - If `aud` matches the *old* SSE resource indicator but not the new one → the server MUST reject the resume's first `tools/call` with `invalid_target` (not `invalid_token`, which misleads the client into retrying the transport) and MUST NOT tear down the session; the client must perform a fresh authorization request scoped to the new resource indicator and rebind. - If the server cannot determine the audience (opaque token, no introspection) → fail closed: require re-authorization on transport change. A resume that cannot prove audience continuity is an authorization gap. The boundary is drawn at the *first tool call after resume*, not at the resume handshake itself, because the handshake carries no tool semantics. Placing the check at the handshake would break legitimate clients that resume only to drain pending messages (`notifications`, `sampling` responses) without invoking tools. ## Operational Effect When the boundary is respected, transport migration is invisible to the agent's task loop: the `Mcp-Session-Id` and `Last-Event-ID` preserve conversational and event state, and the token either already carries the right audience or is transparently re-derived. When it is violated, the agent observes a split failure — the session appears healthy (replay works, messages flow) while tool calls fail or, under permissive validation, execute against an unintended resource. The latter corrupts the audit trail and violates the least-privilege contract the resource indicator exists to enforce. The guardrail is a single server-side invariant: on every `tools/call` over a resumed session, recompute the expected resource indicator for the target tool and compare it to the token's `aud`; on mismatch, return `invalid_target` with the expected indicator in the `WWW-Authenticate` `error_description`, and require the client to re-authorize before the next call. The client-side counterpart is to treat `invalid_target` (distinct from `invalid_token`) as a signal to re-run the OAuth flow with the new resource indicator, not to retry the resume. Neither side may infer authorization continuity from session continuity. ```python class ResourceIndicatorMismatch(RuntimeError): """Raised when a resumed MCP session's token audience does not match the resource indicator required by the streamable-HTTP tool endpoint.""" def validate_resumed_session_tool_call( session_id: str, token_audience: str, endpoint_resource_indicator: str, session_token_binding: str | None, token_subject: str, ) -> None: # Session continuity is assumed already established by the resume handshake. # Authorization continuity must be re-derived here, at the first tool call. if session_token_binding is None: raise ResourceIndicatorMismatch( f"session {session_id!r} has no token binding; " "cannot prove audience continuity across transport migration" ) if session_token_binding != token_subject: raise ResourceIndicatorMismatch( f"session {session_id!r} bound to subject {session_token_binding!r}, " f"but token subject is {token_subject!r}" ) if token_audience != endpoint_resource_indicator: raise ResourceIndicatorMismatch( f"token aud={token_audience!r} does not match " f"endpoint resource indicator {endpoint_resource_indicator!r}; " "client must re-authorize with the new resource indicator" ) ```