# How should an instance reconcile SSE resume state when an MCP HTTP-native tool server rotates its OAuth 2.1 resource indicator mid-stream **Date of Record:** 2026 November 29 **Scope:** Applies to MCP clients using the HTTP-native transport (POST for requests, GET with `text/event-stream` for server-to-client messages) where the server supports resumable streams via `Last-Event-ID` and is protected by OAuth 2.1 with RFC 8707 resource indicators. Does not apply to stdio transport, nor to stateless one-shot request/response tool servers that never emit resumable SSE. ## Core Distinction The MCP spec treats stream resumption and authorization as orthogonal: `Last-Event-ID` is a transport-level cursor, and the OAuth 2.1 `resource` parameter is a token-binding claim. In a correct implementation they *are* orthogonal — but only when the resource indicator is stable for the lifetime of the event-ID epoch. The boundary failure occurs when the server (or an intermediary authorization server) issues a token whose `aud`/resource indicator has changed — typically because the tool server was re-registered under a new canonical URI, an AS rotated its audience value, or a gateway rewrote the resource to include a tenant path segment — while the client still holds event IDs minted under the *old* resource binding. The client then attempts `GET /mcp` with `Last-Event-ID: ` and `Authorization: Bearer `. The server accepts the token (valid signature, valid audience for *current* config) but cannot locate the event ID in its replay buffer, because the buffer was keyed to the prior resource epoch and was either cleared on reconfiguration or partitioned by resource. The resume silently degrades to a fresh stream, and the agent loses every in-flight tool-call result between the last delivered event and the disconnect. ## What Was Observed A tool server exposing `search_index` and `fetch_document` was fronted by an AS that rotated its resource indicator from `https://tools.example.com/mcp` to `https://tools.example.com/v2/mcp` during a rolling deploy. The deploy did not restart SSE replay buffers, but it *did* re-key them by the `resource` claim parsed from the bearer token, so that a token for `/v2/mcp` could not replay events minted under `/mcp`. A long-running agent had an open stream with last delivered event `id: 4471` (a `notifications/progress` for `fetch_document` call `c-88`). The connection dropped at a NAT rebind. On reconnect the client sent: ``` GET /v2/mcp HTTP/1.1 Authorization: Bearer Last-Event-ID: 4471 Accept: text/event-stream ``` The server returned `200 OK` with a fresh stream and no replay — event 4472 onward was delivered, but events between 4471 and the disconnect (including the terminal `result` for `c-88` and the `result` for a concurrent `search_index` call `c-91`) were never re-sent. The client's `Last-Event-ID` was accepted syntactically but matched nothing in the new resource-keyed buffer, and the server had no obligation under the spec to signal the miss. The agent's JSON-RPC request map still held `c-88` and `c-91` as pending; they never resolved. The agent stalled until its own request timeout, then retried `fetch_document` — a non-idempotent side effect on the server's document cache, executed twice. The critical, non-obvious detail: **the HTTP status was 200 and the stream was healthy.** There was no `4xx`, no `Last-Event-ID` rejection, no error event. The failure was invisible at the transport layer and only manifested as orphaned request IDs in the client's correlation table. ## Condition of Validity Resumption via `Last-Event-ID` is only sound under the conjunction: 1. **Resource-indicator stability across the event-ID epoch.** The `resource` value the client presents on resume must equal the resource under which the replayed events were minted. If the AS rotates audiences, the client must treat the rotation as an epoch boundary. 2. **Server-side replay-buffer keying that is either resource-agnostic or explicitly signals epoch mismatch.** A buffer keyed by resource must return a distinguishable signal (e.g., `409` with a `resume-epoch-mismatch` body, or a synthetic `notifications/stream/reset` event) rather than a silent fresh stream. 3. **Client-side correlation between `Last-Event-ID` and pending JSON-RPC request IDs.** The client must know which requests were awaiting responses at the moment of the last delivered event, so it can detect orphaned IDs when replay is short. When condition 1 fails and condition 2 is absent, the resume is *unsound but indistinguishable from sound* at the HTTP layer. This is the dangerous regime. The spec does not require condition 2; a conformant server may legally drop the replay. ## Decision Boundary On any reconnect where the presented `resource` differs from the resource under which the current `Last-Event-ID` was minted, the client must choose between two policies: - **Hard-reset policy (default, safe):** discard the `Last-Event-ID`, treat the stream as fresh, and *reconcile every pending request ID* by re-issuing or explicitly failing each. This is correct but may duplicate side effects for non-idempotent tools. - **Epoch-pinned policy (requires server support):** request resume with the *old* resource indicator to force the server to replay from the old buffer, accepting that the token may be rejected (`401`/`403`) if the AS has already invalidated the old audience. If the old token is still valid, replay succeeds and correlation is preserved. The boundary is crossed exactly when `new_resource != old_resource_at_last_event` **and** the client has ≥1 pending non-idempotent request whose last-known event ID predates the rotation. In that case the hard-reset policy is mandatory unless the server advertises epoch-aware resume (a capability flag in `initialize` result, e.g. `capabilities.streaming.resumeAcrossEpochs: true`). Absent that flag, the client MUST NOT assume replay covers the rotation boundary. ## Operational Effect Agents that skip this reconciliation exhibit a characteristic signature: a burst of duplicate tool invocations immediately after a deploy, correlated with an AS audience rotation, with no corresponding error in transport logs. The duplicate rate scales with the number of pending non-idempotent calls at rotation time. The fix is to bind the resume cursor to the resource epoch: store `(last_event_id, resource_indicator_at_mint)` together, and on reconnect compare the presented resource against the stored one. On mismatch, either downgrade to hard-reset with idempotency keys on all re-issued calls, or fail closed. The invariant to enforce: **an event-ID cursor is only interpretable within the resource epoch that minted it; crossing epochs requires explicit reconciliation, never silent replay.** ```python class ResumeEpochMismatch(RuntimeError): """Raised when an SSE resume crosses a resource-indicator epoch boundary without the server advertising epoch-aware replay.""" pass def reconcile_resume( last_event_id: str | None, resource_at_mint: str | None, presented_resource: str, pending_request_ids: set[str], server_caps: dict, ) -> str | None: """ Decide whether to trust Last-Event-ID on reconnect. Returns the event ID to send, or None to force a fresh stream. """ if last_event_id is None: return None if resource_at_mint is None: # No recorded epoch; cannot prove cursor validity. raise ResumeEpochMismatch( f"event cursor {last_event_id} has no recorded resource epoch; " f"presented resource={presented_resource}" ) if resource_at_mint == presented_resource: return last_event_id # Epoch boundary crossed. if server_caps.get("streaming", {}).get("resumeAcrossEpochs") is True: return last_event_id if pending_request_ids: # Hard-reset is unsafe for non-idempotent calls unless caller # has idempotency keys; surface the decision to the caller. raise ResumeEpochMismatch( f"resource rotated {resource_at_mint} -> {presented_resource} " f"with {len(pending_request_ids)} pending requests " f"({sorted(pending_request_ids)}); replay not guaranteed, " f"hard-reset required" ) # No pending work: safe to start fresh. return None ```