# In what scenarios must an instance refuse to resume a streamable MCP session whose `Last-Event-ID` predates a server-side tool-call commit boundary **Date of Record:** 2026 November 22 **Scope:** Applies to MCP servers implementing the HTTP-native "streamable" transport (POST for client→server messages, GET/SSE for server→client streams, `Last-Event-ID` based resumption) where a client reconnects mid-session after a transport drop. Does not apply to stdio transports, nor to stateless HTTP servers that never emit an event ID. ## Core Distinction The distinction that matters here is between **event-log resumability** and **side-effect resumability**. The streamable MCP transport guarantees the former: the server retains an SSE event buffer keyed by monotonic event IDs, and a reconnecting client presenting `Last-Event-ID: N` receives every event with ID > N. It does *not* guarantee the latter. A tool call that mutated external state (wrote a file, charged a card, sent an email, committed a database transaction) is a *side effect* whose completion was announced in an event the client may or may not have received before the socket died. When the client resumes from an event ID that predates the server's commit of that tool call, the server's replay will re-emit the `tools/call` *request* event (or the client will re-send the request because it never saw the response), and the tool will execute a second time. The stream is continuous; the world is not. Naive implementations treat `Last-Event-ID` as a high-water mark for "safe to replay," which conflates these two notions of continuity. ## What Was Observed A server exposes a `deploy_artifact` tool that pushes a build to a staging registry and returns a digest. The client issues `tools/call` with `id: "call-7"`. The server executes the tool, commits the registry write, and enqueues two SSE events: `event: message` with `id: 41` carrying the tool result, and `id: 42` carrying a `notifications/progress` update. The connection drops after the server has flushed `id: 41` to the kernel but before the client's TCP stack acknowledges it — the client's last *received* event ID is `40`. On reconnect the client sends `GET /mcp` with `Last-Event-ID: 40`. The server replays `41` and `42`. This is correct and harmless: the client now learns the result of `call-7`. The failure appears in a *second* scenario. The client had timed out waiting for `call-7` and, per its own retry policy, re-issued the same `tools/call` with a fresh request ID `call-8` before the reconnect completed. The server sees `call-8` as a new request, executes `deploy_artifact` again, and pushes a second build. The registry now holds two artifacts with different digests, and the client's session state references the digest from `call-7` while the deployment pipeline downstream references `call-8`. The trace: 1. Client sends `call-7`; server begins execution. 2. Server commits registry write; enqueues event `41` (result) and `42` (progress). 3. TCP connection drops; client last-acked `40`. 4. Client's request timeout fires at T+30s; retries as `call-8`. 5. Client reconnects `GET /mcp` with `Last-Event-ID: 40`. 6. Server replays `41`, `42`; concurrently handles `call-8` and re-executes the tool. 7. Two side effects; one client-visible result (`call-7`'s digest via replay) and one orphaned effect (`call-8`). The invariant that broke: **the client's resumption cursor and its request-retry logic were not coordinated.** The replay mechanism assumed the client would not independently re-issue requests during the gap; the client's retry mechanism assumed the server would deduplicate. Neither assumption was enforced anywhere. ## Condition of Validity Resuming from `Last-Event-ID: N` is only safe when, for every tool call whose *request* event has ID ≤ N, the server has either (a) not yet begun execution, or (b) durably recorded the outcome under a client-supplied idempotency key that the client will reuse on retry. Condition (a) is trivially satisfiable by rejecting resumption cursors that fall inside an in-flight tool-call window. Condition (b) requires the client to attach a stable `idempotency_key` to `tools/call` params and the server to maintain a dedup table keyed on it, returning the recorded result for duplicate keys rather than re-executing. Absent either condition, the resumption cursor is a lie: it says "everything up to N is settled" when in fact the settle boundary is the *commit* boundary, which lives at a different offset in the event log than the *request* boundary. The gap between them — the window from "server received `tools/call`" to "server durably recorded the side effect" — is the danger zone. A cursor landing in that window must be refused, not honored. ## Decision Boundary The server must classify each reconnect's `Last-Event-ID` against a per-session **commit watermark**: the highest event ID such that every tool call with a request event at or below that ID has a durably recorded outcome. Three cases: - **Cursor ≤ commit watermark:** replay is safe; honor it. - **Cursor > commit watermark but ≤ last emitted event:** the cursor falls inside an in-flight or uncommitted tool-call window. Do **not** replay silently. Respond with a `409`-equivalent JSON-RPC error carrying `data: {"reason": "uncommitted_window", "commit_watermark": W, "oldest_safe_id": W}` so the client can either re-sync from `W` (accepting that it will re-receive the request event and must dedup via idempotency key) or abandon the session and start fresh. - **Cursor references an ID the server has garbage-collected** (buffer eviction): respond with `data: {"reason": "cursor_expired"}`; the client must not assume continuity. The client's retry policy must be subordinate to this: it must not re-issue a `tools/call` whose request event ID exceeds the last *acknowledged* commit watermark, and it must attach an idempotency key derived from the original request ID so that a re-issue after a `409` is deduplicated server-side. ## Operational Effect Without this boundary, the failure mode is silent: the stream looks continuous, the client believes it resumed cleanly, and the duplicate side effect surfaces only downstream (a double charge, a second deployment, a duplicated row). Because the event log itself is consistent, standard SSE resumption tests pass. The bug is invisible to transport-level monitoring and only detectable by reconciling external side effects against the event log — which most deployments do not do. With the boundary enforced, the worst case degrades from "duplicate side effect" to "client must re-sync from the commit watermark and dedup one in-flight call," which is recoverable and observable. The cost is that the server must maintain a commit watermark per session and refuse cursors in the gap, and the client must carry idempotency keys. Both are cheap; the alternative is a class of bugs that only appear under network partition during tool execution, which is exactly when you cannot reproduce them. ```python class UncommittedResumptionWindow(RuntimeError): """Raised when a client's Last-Event-ID lands inside an uncommitted tool-call window.""" def __init__(self, cursor: int, commit_watermark: int, oldest_safe_id: int): self.cursor = cursor self.commit_watermark = commit_watermark self.oldest_safe_id = oldest_safe_id super().__init__( f"Last-Event-ID {cursor} exceeds commit watermark {commit_watermark}; " f"re-sync from {oldest_safe_id}" ) def resolve_resumption( last_event_id: int, commit_watermark: int, oldest_retained_id: int, last_emitted_id: int, ) -> int: """Return the event ID from which the server may safely replay. Raises UncommittedResumptionWindow if the cursor falls in the gap between the commit watermark and the last emitted event, where a tool call may have executed but not yet been durably recorded. """ if last_event_id < oldest_retained_id: raise UncommittedResumptionWindow( cursor=last_event_id, commit_watermark=commit_watermark, oldest_safe_id=oldest_retained_id, ) if last_event_id <= commit_watermark: return last_event_id if last_event_id <= last_emitted_id: # Cursor is in the uncommitted window: a tool call whose request event # is at or below this ID may have executed without a recorded outcome. raise UncommittedResumptionWindow( cursor=last_event_id, commit_watermark=commit_watermark, oldest_safe_id=commit_watermark, ) # Cursor beyond what was emitted: client is confused; treat as fresh sync. return commit_watermark ```