# What structural signals indicate an MCP session-negotiation replay hazard when resumable SSE is silently upgraded to streamable HTTP **Date of Record:** 2026 November 25 **Scope:** Applies to MCP clients that begin a session over HTTP+SSE with `Last-Event-ID` resumption and are then redirected or renegotiated onto the streamable-HTTP transport mid-session, where per-tool capability scopes were established against the SSE session. Does not apply to pure stdio transports or to sessions that never emit resumable event IDs. ## Core Distinction The failure is not "the connection dropped." It is that the *resumption identity* and the *capability scope identity* are two different keys that the protocol lets you conflate. On SSE, the session is anchored by an event-ID cursor (`Last-Event-ID`) that the server uses to replay missed events; the capability scope is anchored separately by the `initialize` handshake and the tool list negotiated at session start. When an HTTP-native client is told to upgrade to streamable HTTP (via `307`/`308` redirect, `Upgrade`, or a server-advertised `mcp-transport: streamable-http` hint), the client typically carries the SSE cursor forward as a resumption token while the server treats the streamable-HTTP endpoint as a *fresh* session with a *fresh* capability scope. The cursor survives; the scope does not. Replayed events then arrive under a scope that never authorized them, or authorized them under a narrower per-tool grant. This is distinct from ordinary reconnect amnesia. Ordinary amnesia loses events; this hazard *replays events into the wrong authorization context*. The events are not lost — they are re-delivered to an instance whose per-tool scope was silently reset to the handshake default. ## What Was Observed A client initialized over SSE, received `initialize` result with `capabilities.tools` and a per-tool scope map granting `filesystem.read` to `read_file` but not `filesystem.write` to `write_file`. It then executed a long `read_file` tool call whose result was streamed as multiple SSE events carrying monotonic `id:` values. Mid-call, the server returned a `308 Permanent Redirect` to the streamable-HTTP endpoint (a routine load-balancer rebalance). The client re-issued its request to the new endpoint with `Last-Event-ID: 41` and the original `Mcp-Session-Id` header. The streamable-HTTP endpoint accepted the request, did not recognize the session ID as belonging to its own handshake table, and — critically — *did not reject it*. It created a new session, replayed events 42–47 from a shared event log keyed only by event ID, and returned the completed tool result. The replayed events were attributed to the *new* session's default scope, which the server had populated from the tool's static manifest rather than from the client's negotiated per-tool grant. The manifest declared `read_file` with `filesystem.read` *and* `filesystem.stat`, and the replay path applied the manifest scope wholesale. The client's auditor, replaying the same event IDs against its own recorded scope, saw a `stat` operation that its grant did not cover and raised a scope-mismatch on a result it had already accepted. The structural signals that preceded this, in order of observability: 1. A `308`/`307` on a request that carried both `Mcp-Session-Id` and `Last-Event-ID`. The presence of *both* keys on a redirect is the primary tell. 2. The redirect target's `initialize`-equivalent response omitted the per-tool scope map (or returned a manifest-derived default). Absence of the scope map in the renegotiated response, while the cursor was still honored, is the confirmation. 3. Replayed event IDs were contiguous with the pre-redirect cursor but their payloads referenced tools outside the client's recorded grant. Cursor continuity with scope discontinuity is the invariant violation. 4. The server's session table had no entry for the carried `Mcp-Session-Id`, yet returned `200` rather than `404`/`410`. A missing session that is silently re-created rather than rejected is the enabling condition. ## Condition of Validity The hazard is live only when all of the following hold simultaneously: - The transport carries a resumable cursor (`Last-Event-ID` or equivalent) *and* a session identifier across a redirect or upgrade. - The receiving endpoint keys its replay log by cursor alone, not by `(session, cursor)` pair. - Per-tool capability scope is established at handshake and is *not* re-derived from the carried session on renegotiation — i.e., the new endpoint falls back to a manifest or default scope. - The replayed events were produced under a scope broader than the client's negotiated grant. If the replay log is keyed by `(session, cursor)`, the redirect yields a `410 Gone` and the client must re-handshake — safe. If the endpoint rejects unknown `Mcp-Session-Id` with `404`, the client re-initializes and re-negotiates scope — safe. The hazard requires the *silent re-create* path. ## Decision Boundary The boundary is whether the client treats cursor continuity as sufficient evidence of session continuity. It is not. The correct decision rule: - On any redirect or upgrade, the client must treat the carried cursor as *advisory only* and must require the new endpoint to echo the negotiated per-tool scope map in its renegotiation response. - If the renegotiation response omits the scope map, or returns a scope map that differs from the client's recorded grant, the client must discard the carried cursor, re-initialize from scratch, and re-issue the in-flight tool call as a *new* call — not a resumption. - If the server returns `200` on a request whose `Mcp-Session-Id` it does not hold, the client must treat that as a protocol violation, not a success. The invariant to enforce: **capability scope is bound to the session handshake, not to the event cursor; any path that delivers events without re-confirming the scope map is a scope-laundering path and must be rejected.** ## Operational Effect Without the guardrail, the failure is silent and the damage is a scope escalation that the auditor catches only on replay — after the tool result has already been consumed downstream. The client's reasoning loop has acted on a `stat` result it was never granted, and the error compounds: subsequent tool calls are planned on the assumption that `filesystem.stat` is available, and the divergence between the client's recorded grant and the server's applied scope widens with each resumed call. With the guardrail, the redirect forces a re-handshake, the in-flight call is re-issued under a freshly negotiated scope, and the auditor's replay matches the client's grant exactly. The cost is one extra round-trip per redirect; the benefit is that the replay discrepancy class is eliminated at the transport boundary rather than discovered after the fact by the verification layer. The deeper lesson: in HTTP-native MCP, the cursor and the scope are two independent continuity keys, and the protocol's resumption semantics only guarantee the former. Any client that treats a replayed event as authorized because its cursor was continuous has confused transport continuity with authorization continuity. ```python from dataclasses import dataclass class ScopeLaunderingError(RuntimeError): """Raised when a resumed event is delivered under a scope the client never negotiated.""" pass @dataclass(frozen=True) class NegotiatedScope: session_id: str tool_grants: dict[str, frozenset[str]] def resume_after_redirect( carried_session_id: str, carried_cursor: int, recorded_scope: NegotiatedScope, renegotiation_response: dict, ) -> NegotiatedScope: """ Enforce the invariant: a carried cursor is advisory; scope continuity must be re-confirmed by the redirect target before any replayed event is accepted. """ echoed_session = renegotiation_response.get("mcp_session_id") echoed_scope = renegotiation_response.get("tool_scope") # Signal 1: the target silently minted a new session instead of honoring ours. if echoed_session != carried_session_id: raise ScopeLaunderingError( f"session discontinuity on resume: carried {carried_session_id!r}, " f"target echoed {echoed_session!r}; cursor {carried_cursor} must be discarded" ) # Signal 2: the target omitted the per-tool scope map entirely. if echoed_scope is None: raise ScopeLaunderingError( f"renegotiation omitted tool scope for session {carried_session_id!r}; " "replayed events cannot be authorized" ) # Signal 3: the target's scope differs from what the client negotiated. rederived = NegotiatedScope( session_id=echoed_session, tool_grants={k: frozenset(v) for k, v in echoed_scope.items()}, ) if rederived.tool_grants != recorded_scope.tool_grants: raise ScopeLaunderingError( f"scope drift on resume: recorded {recorded_scope.tool_grants!r}, " f"target applied {rederived.tool_grants!r}" ) return rederived ```