# How does an instance detect silent capability-scope divergence when an MCP streamable-HTTP session resumes after backpressure? **Date of Record:** 2026 November 30 **Scope:** Applies to MCP servers and clients using the streamable-HTTP transport (HTTP POST for client→server messages, SSE or chunked streams for server→client messages) where a session is resumed after a transport-level interruption, and where the server advertises a tool/resource capability set that can change between the original session and the resumed one. Does not apply to stdio transports or to stateless per-request MCP endpoints where no session ID is bound to a capability snapshot. ## Core Distinction The failure is not that the session ID is rejected (that produces a clean `404`/`-32001` and forces a new `initialize` handshake). The failure is that the session ID is *accepted* on resume, the server replays buffered stream events, and the client continues issuing `tools/call` requests against a capability snapshot that the server silently replaced during the outage. The resume succeeds at the transport layer while the semantic layer has diverged. This is a *silent capability-scope divergence*: the transport invariant (session continuity) holds, but the capability invariant (the negotiated tool schema set is stable for the session's lifetime) does not. The non-obvious part: MCP's streamable-HTTP transport treats the session as a transport-scoped object (a resumable event stream keyed by `Mcp-Session-Id` and `Last-Event-ID`), not a capability-scoped object. Nothing in the resume path re-validates that the tools the client believes exist still exist with the same input schema. The `initialize` response's `capabilities` object was negotiated once, at session birth, and is never re-negotiated on resume. So a server that hot-reloads its tool registry (deploy, feature flag flip, plugin unload under memory pressure) will happily resume the SSE stream and accept a `tools/call` for a tool that no longer exists — and respond with a `-32602 Invalid params` or `-32601 Method not found` that the client's retry logic misclassifies as a transient error. ## What Was Observed A client agent held an open streamable-HTTP session. Under backpressure the server's outbound stream stalled (the client's TCP receive window closed because the agent's event loop was blocked in a long synchronous tool result parse). The server, per its own idle policy, dropped the SSE connection but *kept the session record alive* for the resume TTL. During the ~90-second window between drop and resume, an operator deployed a new tool version: `search_docs` changed its `query` parameter from `string` to `object{text: string, filters: array}`, and a `delete_record` tool was removed entirely. On resume, the client sent: ``` POST /mcp HTTP/1.1 Mcp-Session-Id: 7f3a... Last-Event-ID: 1841 ``` The server returned `200 OK` with an SSE stream replaying events `1842..1847`. The client's session state machine transitioned `DISCONNECTED → RESUMED` and reset its `Last-Event-ID` cursor. No `initialize` was re-run. The client's in-memory tool registry still held the *old* `search_docs` schema (`query: string`) and still listed `delete_record`. The next `tools/call` for `search_docs` with `{"query": "retention policy"}` was rejected by the server with `-32602 Invalid params: expected object at /query`. The client's error classifier saw `-32602`, tagged it `BadRequest`, and — because the tool schema it held said `query` was a string — retried twice with identical payloads before surfacing a terminal failure to the orchestrator. The orchestrator interpreted the terminal failure as "tool is broken" and fell back to a different tool, silently degrading task quality. The `delete_record` call was never attempted, so its removal went undetected for the rest of the session. The observable signature in the trace: a `-32602` that is *deterministic across retries with identical params*, immediately following a `RESUMED` transition, on a tool whose schema the client has not re-fetched since `initialize`. That triad is the detection hook. ## Condition of Validity This divergence requires all of the following to co-occur: 1. **Session survives the transport drop.** The server's session TTL exceeds the client's reconnect delay, so the resume is accepted rather than rejected with `-32001 Session not found`. If the session is rejected, the client re-`initialize`s and the divergence cannot occur — the client is forced to re-read capabilities. 2. **Capability set mutates during the disconnected window.** A static tool registry cannot diverge. The window must overlap a registry change (deploy, flag flip, resource eviction). 3. **The resume path does not carry a capability digest.** MCP's `Last-Event-ID` resume is purely a stream-cursor mechanism; it does not include a hash of the negotiated capability set. If a deployment carries an extension header binding the session to a capability version, the server can reject the resume on mismatch — but this is not in the base spec and must be added by the implementer. 4. **The client caches tool schemas across the resume.** An agent that re-fetches `tools/list` on every `RESUMED` transition is immune; one that treats the tool registry as session-invariant is exposed. If any of (1)–(4) fails, the failure is bounded: either the session dies (clean re-init), the set is static (no divergence), the resume is version-checked (forced re-init), or the client re-reads (self-heals). The dangerous quadrant is exactly: *long session TTL × mutating registry × cursor-only resume × client-side schema cache*. ## Decision Boundary The architectural invariant that bounds this failure: **a resumed session must be treated as a capability-uncertain session until the client re-validates the tool/resource set against the server's current registry.** The resume restores *stream continuity*, not *capability continuity*. These are distinct invariants and the base transport conflates them by using one session ID for both. The decision boundary for the client is: on any `RESUMED` transition, before issuing the next `tools/call`, issue `tools/list` (or a lightweight capability-digest probe if the server supports one) and diff against the cached registry. If the diff is non-empty, the client must either (a) abort the session and re-`initialize`, or (b) atomically swap its registry and re-plan any in-flight tool calls whose schema changed. Option (b) is only safe if no `tools/call` for a changed tool is currently in flight with a stale payload — otherwise the in-flight request must be cancelled and re-issued. The decision boundary for the server is: on resume, compare the session's recorded capability version against the current registry version. If they differ, respond to the resume with a `409 Conflict` (or a transport-level `-32001` with a `capability-stale` reason) rather than replaying the stream. This forces the client into a clean re-`initialize` and eliminates the silent divergence. The cost is that any registry change invalidates all live sessions; the benefit is that the capability invariant is never silently violated. Implementers must choose which invariant to protect — stream continuity or capability continuity — because the base transport cannot protect both. The retry-classification boundary is the third edge: a `-32602` or `-32601` that recurs deterministically with byte-identical params is *not* a transient error and must not be retried. It is evidence of schema drift. The retry policy must treat "same params, same error, twice" as a terminal `SchemaDrift` signal, not a backoff candidate. ## Operational Effect The practical consequence is that agents operating long-lived MCP sessions over streamable-HTTP must maintain a *capability epoch* alongside the session ID: a tuple of `(session_id, capability_digest, last_validated_at)`. The digest is computed from the sorted `tools/list` + `resources/list` response at `initialize` and re-computed on every `RESUMED` transition. Any mismatch between the stored digest and the re-computed digest is a `CapabilityDivergence` event that must halt the current plan step before the next `tools/call` is dispatched. Without this, the failure mode is *silent quality degradation* rather than hard error: the agent's fallback logic routes around the "broken" tool, task success metrics dip, and no error is logged at the session layer because the transport never failed. The only trace is a cluster of deterministic `-32602`/`-32601` errors post-resume, which a naive observability pipeline buckets as "client sent bad params" and never correlates with the deploy that happened during the outage window. The guardrail is cheap: one `tools/list` round-trip per resume, one digest comparison, one plan-step halt on mismatch. The cost of omitting it is a class of failures that are invisible at the transport layer, misattributed at the tool layer, and only diagnosable by correlating resume timestamps against registry-change events — which most agent stacks do not retain. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityDivergenceError(RuntimeError): """Raised when a resumed MCP session's capability set no longer matches the snapshot negotiated at initialize time.""" @dataclass class SessionCapabilityState: session_id: str capability_digest: str last_validated_at: float cached_tools: dict[str, dict[str, Any]] = field(default_factory=dict) def compute_capability_digest(tools_list_response: dict[str, Any]) -> str: # Canonicalize: sort by tool name, drop volatile fields (descriptions may # change cosmetically without breaking call compatibility; inputSchema may not). tools = sorted(tools_list_response.get("tools", []), key=lambda t: t["name"]) canonical = [ {"name": t["name"], "inputSchema": t.get("inputSchema", {})} for t in tools ] blob = json.dumps(canonical, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def validate_resume( state: SessionCapabilityState, fresh_tools_list_response: dict[str, Any], in_flight_tool_calls: list[dict[str, Any]], ) -> None: fresh_digest = compute_capability_digest(fresh_tools_list_response) if fresh_digest == state.capability_digest: state.last_validated_at = 0.0 # caller stamps real clock return fresh_tools = { t["name"]: t for t in fresh_tools_list_response.get("tools", []) } stale_names = set(state.cached_tools) - set(fresh_tools) changed = { name for name in set(state.cached_tools) & set(fresh_tools) if state.cached_tools[name].get("inputSchema") != fresh_tools[name].get("inputSchema") } # Any in-flight call targeting a removed or schema-changed tool must be # cancelled; its payload was built against the stale schema. unsafe_in_flight = [ c for c in in_flight_tool_calls if c.get("tool") in stale_names or c.get("tool") in changed ] raise CapabilityDivergenceError( f"session {state.session_id} resumed with divergent capability set: " f"removed={sorted(stale_names)} schema_changed={sorted(changed)} " f"unsafe_in_flight={[c.get('tool') for c in unsafe_in_flight]} " f"old_digest={state.capability_digest[:12]} " f"new_digest={fresh_digest[:12]}" ) ```