# Under what conditions must an instance refuse to resume an MCP session across an HTTP-native transport upgrade **Date of Record:** 2026 November 17 **Scope:** Applies to MCP servers exposing both the legacy HTTP+SSE transport and the streamable-HTTP transport on the same host, where session continuity is attempted via `Last-Event-ID` replay and the caller is authorized under an OAuth 2.1 resource-server binding with a token audience scoped to a single transport endpoint. Does not apply to pure stdio transports, nor to deployments where the authorization server issues audience-agnostic tokens. ## Core Distinction Session identity and transport identity are orthogonal, but the resumption path in HTTP-native MCP conflates them. A session is a logical conversation keyed by `Mcp-Session-Id`; a transport is the wire binding that carries it. The SSE transport encodes resumption state as an event-ID cursor (`Last-Event-ID`) replayed against a per-connection event log. Streamable HTTP encodes resumption state as a server-side session store addressed by `Mcp-Session-Id` plus an optional `Last-Event-ID` for resuming a specific in-flight stream. These are not interchangeable cursors: an SSE event ID is meaningful only within the event log of the connection that produced it, whereas a streamable-HTTP resume token is meaningful only within the session store of the server that minted it. The boundary failure is treating a valid-looking `Last-Event-ID` from one transport as a valid resume cursor for the other. ## What Was Observed A client opened an SSE session, received `Mcp-Session-Id: S1` and a stream of events carrying monotonically increasing IDs `e1…e42`. The SSE connection dropped at `e42`. The client, upgraded to streamable HTTP (same host, same path prefix, different `Accept` negotiation), issued `POST` with `Mcp-Session-Id: S1` and `Last-Event-ID: e42`. The server accepted the request, found session `S1` in its store (the ID namespace happened to be shared because both transports were backed by the same session allocator), and replayed the streamable-HTTP event log from its own cursor — which had been advancing independently and was at `e7`. The client consequently replayed seven events it had already processed and *skipped* events `e8…e42` that existed only in the SSE log. The MCP `initialize` handshake had already completed, so no capability renegotiation occurred; the client's tool-call state machine advanced on a corrupted event sequence and issued a `tools/call` against a resource whose creation event it had never seen. Separately, the OAuth binding: the access token carried `aud` set to the SSE endpoint URI. Streamable HTTP requests to the same logical server presented the same token. The resource server validated signature and expiry but did not enforce audience match against the *specific* transport endpoint, so the token was accepted for a transport it was never issued for. The session store, keyed only by `Mcp-Session-Id`, had no record of which transport had minted the session, so it could not reject the cross-transport resume on that basis either. ## Condition of Validity Cross-transport resumption is safe **only** when all three of the following hold simultaneously: 1. The session store records the transport binding (`transport: "sse" | "streamable-http"`) at session creation and rejects resume attempts whose presented transport differs, returning a terminal `404`/`400` rather than a best-effort replay. 2. The `Last-Event-ID` cursor is namespaced by transport and session (e.g., `sse:S1:e42` vs `sth:S1:e7`), so a cursor from one log cannot be interpreted against another. 3. The OAuth resource-server binding enforces `aud` equality against the exact endpoint URI that received the request, and the token's `scope` includes the transport-specific resource indicator. If any one is absent, the transport upgrade must be treated as a *new session*: the server must invalidate `S1`, force a fresh `initialize`, and require re-authorization. The invariant is: **a session may only be resumed by the transport that created it, under the token audience issued for that transport.** ## Decision Boundary The decision to refuse is not "should I resume?" but "is the presented resume cursor provably from the same event log as the session's current transport binding?" If the session's recorded transport differs from the request's transport, refuse unconditionally — do not attempt cursor translation, do not fall back to replay-from-zero, do not silently re-initialize while preserving `Mcp-Session-Id`. Re-initialization must issue a *new* session ID; reusing the old ID after a transport switch is the exact condition that produced the observed corruption. The refusal is a hard boundary, not a heuristic: a mismatched cursor is indistinguishable from a malicious replay, and the cost of a false refusal (one extra handshake) is trivially smaller than the cost of a false accept (silent event loss in an agent's tool-call sequence). ## Operational Effect Enforcing the boundary converts a silent data-integrity failure into a loud, recoverable protocol error. Clients see a `400` on resume, discard local session state, and re-run `initialize` — adding one round trip but preserving the event-sequence invariant. The OAuth audience check moves from "valid token for this server" to "valid token for this endpoint," which means a token minted for SSE cannot be replayed against streamable HTTP even if the session store is compromised. The residual cost is that legitimate transport upgrades (rare, and typically client-initiated at reconnect) now require explicit re-authorization rather than transparent resume; this is the correct trade, because transparent cross-transport resume is the mechanism by which the failure propagates. ```python class CrossTransportResumeError(RuntimeError): """Raised when a session resume is attempted across incompatible transports or with a token whose audience does not match the receiving endpoint.""" def resume_session( session_store: dict, session_id: str, request_transport: str, last_event_id: str | None, token_aud: str, endpoint_uri: str, ) -> dict: record = session_store.get(session_id) if record is None: raise CrossTransportResumeError( f"unknown session {session_id!r}; refusing resume" ) if record["transport"] != request_transport: raise CrossTransportResumeError( f"session {session_id!r} was minted under transport " f"{record['transport']!r}; resume requested under " f"{request_transport!r}. Cross-transport resume is forbidden; " f"invalidate session and re-initialize." ) if token_aud != endpoint_uri: raise CrossTransportResumeError( f"token audience {token_aud!r} does not match receiving endpoint " f"{endpoint_uri!r}; resource-server binding violated." ) if last_event_id is not None: prefix = f"{request_transport}:{session_id}:" if not last_event_id.startswith(prefix): raise CrossTransportResumeError( f"cursor {last_event_id!r} is not namespaced for session " f"{session_id!r} under transport {request_transport!r}; " f"refusing to interpret foreign event log." ) cursor = int(last_event_id.rsplit(":", 1)[1]) if cursor > record["last_event_seq"]: raise CrossTransportResumeError( f"cursor {cursor} exceeds session high-water mark " f"{record['last_event_seq']}; possible replay attack." ) return record ```