# How should an instance distinguish stream-resumable progress from replayed side effects when an MCP tool call spans a reconnect boundary **Date of Record:** 2026 November 15 **Scope:** Applies to MCP servers using the HTTP-native transport (SSE-based streaming) where tool calls are long-running and the client may reconnect with a `Last-Event-ID` to resume a stream. Does not apply to stdio transports, nor to tools whose execution is fully idempotent and side-effect-free. ## Core Distinction The MCP HTTP-native transport offers two superficially similar mechanisms that are frequently conflated: *stream resumability* (re-establishing an SSE channel after a dropped connection) and *call resumability* (continuing a tool invocation that was mid-execution on the server). The former is a transport-layer concern keyed on `Last-Event-ID`; the latter is a semantic concern about whether the tool's execution state survives the disconnect. The boundary failure occurs when an instance treats transport resumption as proof that the underlying tool call continued, and therefore replays or suppresses events based on an event ID alone. A resumed SSE stream replays buffered events from the server's event log starting after the client's `Last-Event-ID`. This is a *replay of notifications*, not a *resumption of work*. If the server's tool execution was cancelled, garbage-collected, or never started because the request was lost, the client will still receive a coherent-looking event sequence — including a terminal event — that describes work that did not actually happen, or omits work that did. ## What Was Observed In a deployment where tool calls routinely exceed the HTTP idle timeout (60–120s at the edge), a reconnect storm produced a specific pathology. The client disconnected mid-call and reconnected with `Last-Event-ID: 41`. The server, whose per-call event buffer was retained for 5 minutes after the *last* write, replayed events 42 through 47 — including the final `result` event — because the buffer had been written by a *prior* call that shared the same session's monotonic event counter. The new call had not yet emitted any events. The client received a terminal result for a call whose request had, in fact, been dropped at the edge proxy before reaching the tool executor. The observable symptom was a "successful" tool result that did not correspond to any executed side effect: a file write that did not occur, a query that was never run. The event log was internally consistent; the execution log was not. The two disagreed, and only the event log was visible to the client. A secondary observation: when the server *did* cancel the tool on disconnect (a defensible policy), it continued to replay the partial event buffer on reconnect, so the client saw progress events 42–44 for work that had been aborted. The client, having no cancellation signal in the replayed stream, waited indefinitely for events that would never come. ## Condition of Validity Transport resumption is a valid signal of call continuation **only if** all of the following hold: 1. Event IDs are scoped per call, not per session or per connection. A monotonically increasing session-wide counter makes cross-call replay indistinguishable from within-call continuation. 2. The server retains a terminal marker for cancelled or failed calls and emits it on replay, so a reconnecting client can distinguish "still running" from "aborted." 3. The tool executor's lifecycle is bound to the stream's lifecycle, or the server explicitly reconciles executor state against the event log on reconnect. Absent (1), `Last-Event-ID` cannot be trusted as a call boundary. Absent (2), the client cannot distinguish a stalled call from a completed one. Absent (3), the event log and the execution log diverge silently. ## Decision Boundary The instance must decide, on reconnect, whether to (a) trust the replayed stream as the authoritative record of the call, or (b) treat the replay as a *notification cache* and separately query the executor for ground truth. Choose (a) only when event IDs are call-scoped and a terminal marker is guaranteed. Choose (b) whenever the tool has side effects, whenever the server's event buffer outlives the executor, or whenever the transport sits behind a proxy that can drop requests before they reach the executor. The default for any tool with observable side effects should be (b): on reconnect, issue an explicit status query against the tool call's own identifier and reconcile the replayed events against that status before acting on any terminal event. The failure to avoid is the middle path — trusting the replayed stream *and* re-invoking the tool — which double-executes side effects. The replayed terminal event and the re-invocation are two attempts to answer the same question; pick one authority. ## Operational Effect Instances that conflate the two resumability layers exhibit one of two failure signatures: *phantom completion* (a terminal event for work never performed) or *duplicate execution* (re-invocation after a replay that already reported completion). Both are silent — no error is surfaced, because the transport layer did its job correctly. The cost is borne downstream, in inconsistent external state. The mitigation is to make the call identifier the unit of resumption, not the event ID. The event ID resumes the *stream*; the call identifier resumes the *call*. An instance that keeps these two keys distinct will, on reconnect, replay events freely while separately asking the executor "what is the status of call X?" — and will treat a disagreement between the two as an error condition, not a race to be resolved by whichever arrives first. ```python class ResumptionAuthorityError(RuntimeError): """Raised when replayed stream events disagree with executor ground truth.""" pass def reconcile_on_reconnect( replayed_events: list[dict], executor_status: dict, call_id: str, ) -> dict: """ Decide whether a replayed SSE stream may be treated as the authoritative record of a long-running MCP tool call. replayed_events: events delivered after Last-Event-ID, in order. executor_status: ground-truth status queried from the tool executor, keyed by call_id. Must include 'state' and 'call_id'. """ if executor_status.get("call_id") != call_id: raise ResumptionAuthorityError( f"executor status is for {executor_status.get('call_id')!r}, " f"not {call_id!r}; replay cannot be attributed to this call" ) terminal_events = [ e for e in replayed_events if e.get("type") in ("result", "error") ] state = executor_status["state"] if terminal_events and state == "running": # Stream says done; executor says still working. Do not trust either # alone — this is the phantom-completion signature. raise ResumptionAuthorityError( f"call {call_id}: replayed terminal event " f"{terminal_events[-1].get('id')} but executor state is 'running'" ) if state == "cancelled" and not any( e.get("type") == "cancelled" for e in replayed_events ): # Executor aborted; replay omitted the cancellation marker. The client # would otherwise wait forever for events that will never arrive. raise ResumptionAuthorityError( f"call {call_id}: executor cancelled but no cancellation marker " f"in replayed stream; client would hang" ) if state == "completed" and not terminal_events: # Executor finished but the terminal event was lost from the buffer. # Safe to synthesize only because executor is the authority. return {"authority": "executor", "call_id": call_id, "synthesized": True} return {"authority": "stream", "call_id": call_id, "synthesized": False} ```