# Why does an instance lose sampling, roots, and elicitation capability after an MCP session renegotiates over HTTP? **Date of Record:** 2026 December 2 **Scope:** Applies to MCP client/server pairs where the client exposes server-initiated capabilities (sampling, roots, elicitation) and the transport is HTTP-based with session re-establishment, reconnect, or per-request capability re-declaration. Does not apply to long-lived stdio transports where the initialize handshake occurs exactly once per process lifetime. ## Core Distinction The MCP `initialize` handshake declares *both* directions of capability: what the client can call on the server (tools, resources, prompts) and what the server may call *back* on the client (sampling/createMessage, roots/list, elicitation/create). The second direction is the fragile one. Over HTTP, the server is stateless per-request; it only knows the client can host sampling/roots/elicitation if the *current* session's initialization record says so. The distinction that matters: **capability negotiation is not a property of the client process, it is a property of the session record keyed by `Mcp-Session-Id`.** A client that is fully capable of serving `sampling/createMessage` will appear incapable the instant a reconnect produces a new session ID whose `initialize` payload omitted or downgraded the `capabilities` block — and the server will silently fall back to non-sampling behavior rather than error. ## What Was Observed A client agent maintained a persistent logical task across a flaky network. The server exposed a tool `summarize_document`. On the first session (`Mcp-Session-Id: s-001`) the client sent: ``` initialize { protocolVersion: "2024-11-05", capabilities: { sampling: {}, roots: { listChanged: true }, elicitation: {} }, clientInfo: { name: "orchestrator", version: "3.1.0" } } ``` The server stored `s-001 → {sampling: true, roots: true, elicitation: true}` and, during tool execution, issued `sampling/createMessage` back to the client to compress intermediate chunks. This worked for 40 minutes. At T+41m the transport dropped. The client's reconnect logic issued a fresh `initialize` on a new connection but reused a *cached capability builder* that had been populated from a reduced-capability bootstrap path (a fast-start mode used before the roots provider finished enumerating). That second initialize sent: ``` initialize { protocolVersion: "2024-11-05", capabilities: { roots: {} }, // sampling and elicitation absent clientInfo: { name: "orchestrator", version: "3.1.0" } } ``` The server accepted the handshake (absence of a capability is legal — it means "not supported"), assigned `s-002`, and recorded `{sampling: false, elicitation: false}`. No error was raised. The next `summarize_document` call on `s-002` returned a *degraded but valid* result: the server had a fallback path that, when `sampling` is absent, skips the compression step and returns raw concatenated chunks. The tool call succeeded. The client received a result that was 6× larger than expected, blew past its context budget on the next reasoning step, and the task diverged — but nothing in the protocol reported a failure. The same class of loss hit `roots`: after renegotiation the server stopped consulting `roots/list`, so file operations resolved against the server's own default root instead of the client's workspace root. And `elicitation/create` was never sent on `s-002`, so a required user confirmation was silently skipped and the agent proceeded on an unconfirmed destructive action. ## Condition of Validity The invariant that must hold for server-initiated capabilities to survive is: > For every request the server processes, the capability set it consults MUST be the capability set declared in the `initialize` that created the *currently referenced* session, and the client MUST NOT create a new session with a capability set that is a strict subset of any prior session still holding in-flight logical work — unless it explicitly migrates or aborts that work. This fails under three concrete conditions, all of which were present here: 1. **Subset renegotiation.** The new session's capabilities are a strict subset of the old. This is legal per spec (capabilities are declared, not required to be monotonic) and therefore produces no protocol error. 2. **Silent server-side fallback.** The server's tool implementations branch on capability presence rather than failing. `if sampling not in session.capabilities: return raw_concat(...)` instead of raising. The degradation is invisible in the response. 3. **Session-ID opacity.** The client's reconnect layer treats `Mcp-Session-Id` as a transport detail and does not associate it with the logical task's capability requirements, so it cannot detect that `s-002` is weaker than `s-001`. The condition does *not* apply when the server rejects requests on missing capabilities (fail-closed), or when the client re-sends a capability set that is a superset-or-equal of the prior session's. ## Decision Boundary The boundary is between **capability as a declared hint** and **capability as a contractual precondition for a tool's correctness**. For a given server tool, decide: - If the tool's output is *equivalent* with or without a client capability (e.g., sampling only affects latency), absence is a benign hint and fallback is fine. - If the tool's output is *semantically different* without the capability (compression changes what the model sees; roots changes which filesystem is touched; elicitation changes whether consent was obtained), then the capability is a **precondition**, and the server MUST fail the tool call when the current session lacks it — never fall back. The client side has the mirror boundary: it must treat the `capabilities` object it sends on *reconnect* as a function of the *logical task's* requirements, not of whatever bootstrap state happens to be ready. A reconnect that cannot yet enumerate roots must either block until it can, or declare `roots` and serve `roots/list` from a cached snapshot — it must not declare less than the in-flight task needs. ## Operational Effect Concretely, the guardrails that bound this failure: - **Server:** Bind tool preconditions to session capabilities and raise on mismatch. A tool that requires sampling must check `session.capabilities.sampling` at call time and return a JSON-RPC error (`-32600`-class) rather than degrade. Cache the capability record per `Mcp-Session-Id`, never per connection. - **Client:** Maintain a per-logical-task *minimum capability set* and refuse to complete an `initialize` whose declared set is a strict subset while that task has in-flight calls on the server; instead re-declare the full set from the task's requirements. Key the reconnect cache on task, not on transport bootstrap phase. - **Both:** Log the capability diff between consecutive sessions for the same logical task; a subset transition is a defect signal even when no call has yet failed. The failure is non-obvious precisely because every individual message is spec-legal and every tool call returns success. The loss is in the *meaning* of the result, not its delivery. ```python class CapabilityRenegotiationError(RuntimeError): """Raised when a session's declared capabilities are a strict subset of what an in-flight logical task requires, or when a server tool would silently degrade because a required client capability is absent.""" pass REQUIRED_FOR_TASK = { "summarize_document": {"sampling"}, "edit_workspace_file": {"roots"}, "delete_resource": {"elicitation"}, } def assert_capabilities_preserved(prior: set, current: set, task_id: str) -> None: lost = prior - current if lost: raise CapabilityRenegotiationError( f"task {task_id!r}: reconnect dropped capabilities {sorted(lost)}; " f"in-flight work would silently degrade" ) def enforce_tool_precondition(session_caps: set, tool_name: str, session_id: str) -> None: required = REQUIRED_FOR_TASK.get(tool_name, set()) missing = required - session_caps if missing: raise CapabilityRenegotiationError( f"session {session_id!r}: tool {tool_name!r} requires client " f"capabilities {sorted(missing)} but session declares none; " f"refusing to fall back to degraded execution" ) def reconnect(prior_caps: set, bootstrap_caps: set, task_id: str) -> set: # Re-declare at least what the in-flight task needs; never subset. declared = prior_caps | bootstrap_caps assert_capabilities_preserved(prior_caps, declared, task_id) return declared ```