# Under what conditions must an instance treat MCP SSE `Last-Event-ID` resumption as a replay of tool *effects*, not just a replay of tool *results* **Date of Record:** 2026 November 27 **Scope:** Applies to MCP clients connected to a stateful HTTP-native transport server (Streamable HTTP / SSE) that supports `Last-Event-ID`-based stream resumption, where the server emits tool-call progress and completion events on a long-lived stream and the client may reconnect mid-execution. Does not apply to stateless stdio transports, nor to servers that emit only idempotent read-only notifications. ## Core Distinction The MCP resumption contract is a *transport-layer* guarantee: on reconnection with a `Last-Event-ID` header, the server replays events the client has not yet acknowledged, so the client observes a contiguous event stream. Engineers routinely read this as "the client sees every result exactly once." That reading is wrong in a specific and dangerous way. Resumption replays **events**, and events are *descriptions of what the server did*, not *the doing itself*. When a `tools/call` request has already been dispatched and the server side-effect (a file write, a transaction commit, an outbound API mutation) has already occurred, the completion event for that call is a *post-hoc assertion*. If the stream breaks between the side-effect and the client's durable acknowledgement of the completion event, resumption will replay the completion event — and a client that treats "I received a `result` for request N" as "request N has not yet been executed" will re-issue `tools/call` for N. The server, having no idempotency key, executes it again. The invariant that must hold: **event replay ≠ effect replay.** A resumed stream guarantees the client can reconstruct the *observation history*; it says nothing about whether the *effect history* is single-shot. The two diverge precisely in the window between server-side effect commit and client-side durable acknowledgement. ## What Was Observed A research agent driving a browser-automation MCP server over Streamable HTTP issued `tools/call` for `page.submit_form` against a checkout flow on a staging environment. The server assigned the call `request_id=7f3a`, executed it (network POST to the payment sandbox, form submitted, order created), and began emitting progress events: `progress` (id `evt-101`), `progress` (id `evt-102`), then `result` (id `evt-103`) carrying `{"order_id": "ord_9921"}`. The client's network layer dropped the TCP connection during the write of `evt-103` — the event arrived truncated, was discarded by the SSE parser, and the client's last durable `Last-Event-ID` remained `evt-102`. The client's supervisor, seeing the stream dead and the call unresolved, reconnected with `Last-Event-ID: evt-102`. The server, correctly per spec, replayed from `evt-103`. The client received the `result` for `7f3a` and marked the call complete — but only *after* a naive retry path (see below) had already fired. Here is the actual sequence that produced the duplicate: 1. Connection drop detected at `t+0`. Supervisor classifies the *call* as failed because no `result` was observed within its local timeout. 2. Supervisor reconnects the *stream* with `Last-Event-ID: evt-102` and, in parallel, re-issues `tools/call` with a *new* `request_id` (`7f3b`) because the client's request table keyed on `request_id` had no entry for `7f3a` — `7f3a` had been evicted from the in-flight table on the disconnect (a "disconnect means abandon" policy). 3. Server executes `7f3b` → second form submission → `ord_9922`. 4. Replayed `evt-103` arrives carrying `ord_9921`, and the client records *both* orders as valid results of the same logical task. The failure is not that resumption lost events. It is that the client conflated *stream continuity* (which resumption repaired) with *call continuity* (which resumption does not address). The two are governed by different identifiers — `Last-Event-ID` for the stream, `request_id` for the call — and the client maintained only the former across reconnection. ## Condition of Validity The "resumption replays results exactly once" assumption is valid only when **all three** of the following hold: - **Effect idempotency:** the tool is idempotent, or the server deduplicates on `request_id`. Most MCP servers do neither by default; `tools/call` is fire-and-forget from the server's perspective once dispatched. - **Call-table durability:** the client's in-flight request table survives the transport disconnect. If the client evicts in-flight entries on socket close, `request_id` continuity is lost and a retry produces a new id. - **Acknowledgement ordering:** the client durably records `Last-Event-ID` *after* processing each event, not before, and does not advance it past an event it failed to parse. A client that advances on receipt-then-parse will skip `evt-103` entirely and never learn `ord_9921` existed. When any of these fails — and in practice the second fails on every client that treats disconnect as abandonment — resumption becomes a *duplicate-effect amplifier*, not a repair mechanism. The condition of validity is therefore narrow: it holds for read-only tools, for servers with explicit `request_id` dedup, and for clients with persistent request tables. It does not hold for the general mutating-tool case. ## Decision Boundary The boundary is the moment the client decides whether to retry a `tools/call` after a stream break. The correct decision rule is: - **Retry with the same `request_id`** only if the server advertises idempotent `tools/call` (via a capability or documented dedup window) *and* the client has durably retained the request. Otherwise a retry is a new effect. - **Do not retry on stream break alone.** A broken stream is not evidence the call failed; it is evidence the client's *view* is incomplete. The correct action is to reconnect and drain the replay first, then reconcile: if the replayed stream contains a `result` for the outstanding `request_id`, the call succeeded — do not retry. Only if replay completes without that `result` (or the server returns a resumption gap error, meaning events were evicted from its buffer) may the client conclude the call is *unknown*, not failed. - **Treat resumption-gap as a distinct state.** When the server cannot honor `Last-Event-ID` because the event buffer rolled over, it must signal a gap. The client must then treat *all* calls dispatched since the last acknowledged event as having unknown outcome and escalate to a reconciliation query (e.g., `tools/list`-adjacent state read or an out-of-band check) rather than blind retry. The invariant to enforce: **a `tools/call` may be retried only under an explicit idempotency warrant, never under a transport-failure inference.** ## Operational Effect Clients that violate this boundary produce silent duplicate side-effects — double submissions, double payments, duplicated file appends, repeated outbound messages — that are invisible in the event log because *both* completions are legitimate events with distinct `request_id`s. The duplicate is not a protocol error; it is a semantically valid execution of two distinct calls the client chose to make. Post-hoc audit sees two successful calls and no anomaly. The guardrail is to bind call identity to a client-generated idempotency token that is *stable across reconnection* and *durable across disconnect*, and to make resumption reconciliation mandatory before any retry. The code below encodes the reconciliation gate: it refuses to retry a mutating call on transport failure unless an idempotency warrant is present, and it raises when a resumption gap leaves call outcomes unknown. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ResumptionReconciliationError(RuntimeError): """Raised when a stream resumption leaves a mutating call's outcome unknown and no idempotency warrant permits a safe retry.""" pass class CallOutcome(Enum): RESOLVED = "resolved" UNKNOWN = "unknown" # dispatched, no result observed, no gap signal GAP_UNKNOWN = "gap_unknown" # server rolled its buffer; outcome unrecoverable @dataclass class InFlightCall: request_id: str idempotency_key: str mutating: bool outcome: CallOutcome = CallOutcome.UNKNOWN @dataclass class ResumptionState: last_event_id: str server_supports_dedup: bool = False calls: dict[str, InFlightCall] = field(default_factory=dict) def reconcile_after_reconnect( state: ResumptionState, replayed_results: dict[str, str], # request_id -> result payload resumption_gap: bool, ) -> dict[str, str]: """ Apply replayed events to in-flight calls BEFORE any retry decision. Returns the set of calls that are safe to retry (empty in the safe case). """ # 1. Drain replay: any call with a replayed result is resolved; do not retry. for rid, payload in replayed_results.items(): call = state.calls.get(rid) if call is not None: call.outcome = CallOutcome.RESOLVED # 2. A resumption gap means the server could not honor Last-Event-ID. # Every still-unresolved mutating call now has an unrecoverable outcome. if resumption_gap: for call in state.calls.values(): if call.outcome is CallOutcome.UNKNOWN and call.mutating: call.outcome = CallOutcome.GAP_UNKNOWN # 3. Decide retry eligibility. Mutating calls may retry ONLY with a warrant. retryable: dict[str, str] = {} for rid, call in state.calls.items(): if call.outcome is CallOutcome.RESOLVED: continue if call.mutating and not state.server_supports_dedup: # No idempotency warrant: a retry is a new effect, not a repair. raise ResumptionReconciliationError( f"Call {rid} (idempotency_key={call.idempotency_key}) is mutating, " f"outcome={call.outcome.value}, and server advertises no dedup. " f"Refusing to retry on transport failure alone; escalate to " f"out-of-band reconciliation." ) # Safe: read-only, or server dedups on idempotency_key. retryable[rid] = call.idempotency_key return retryable ```