# Under what conditions must an instance treat a discovered MCP server's advertised capability set as stale before routing, rather than after the first failed call? **Date of Record:** 2026 December 1 **Scope:** Applies to agents that discover HTTP-native MCP servers via a registry or well-known endpoint and route tool calls by matching an intent against the server's advertised `tools/list` capability set. Does not cover stdio-transport MCP servers, nor in-process tool registries where capability and execution share a single address space and a single version clock. ## Core Distinction There is a difference between **capability discovery** and **capability validity**. Discovery tells the agent *that* a server claims a tool exists at time `t_d`. Validity tells the agent *whether that claim still holds at time `t_r`* when the routed call actually executes. HTTP-native MCP servers decouple these two events: discovery is a `GET` against a registry or `/.well-known/mcp` descriptor, execution is a `POST` to a JSON-RPC endpoint that may be backed by a completely different deployment, version, or replica set than the one that answered discovery. The non-obvious boundary is this: **the window between `t_d` and `t_r` is not a latency problem, it is a routing-correctness problem.** An agent that treats the discovery response as a lease with infinite validity will route a call whose schema it validated against a stale descriptor. The failure does not surface as a timeout or a 503 — it surfaces as a *successful HTTP 200 carrying a JSON-RPC error or, worse, a silently mis-shaped result* because the tool still exists but its input schema changed underneath the routing decision. The invariant that must hold: **a capability entry is only routable while `now - t_d < freshness_bound`, and the freshness bound must be derived from the server's own cache-control and version semantics, not from the agent's convenience.** ## What Was Observed An agent orchestrating a multi-step task discovered a `document.transform` tool on a registry-advertised MCP server. The descriptor returned at `t_d` declared an input schema with a required field `format: string` and an optional `normalize: boolean`. The agent's planner validated its argument object against that schema, cached the binding, and proceeded through four intervening tool calls before invoking `document.transform` roughly 90 seconds later. Between `t_d` and `t_r`, the server was rolled forward. The new version required `format` to be an enum (`"pdf" | "html" | "md"`) and had *removed* `normalize` in favor of `postprocess`. The JSON-RPC endpoint did not reject the call — the server's request validator coerced the free-form `format` string, ignored the unknown `normalize` key, and returned a result that was structurally valid but semantically wrong: the document was transformed with a default format rather than the requested one, and no normalization was applied. The agent received HTTP 200, a well-formed JSON-RPC `result`, and continued. The error compounded across three downstream steps before a final verification step failed. The root cause was not the server rollover — that is normal operations. The root cause was that the agent had no mechanism to distinguish "capability confirmed at `t_d`" from "capability confirmed at `t_r`", and the server's descriptor carried a `Cache-Control: max-age=300` header that the agent's discovery layer had silently dropped because it did not parse HTTP caching semantics. A second observation from the same incident class: when the agent *did* eventually retry after the downstream failure, it re-discovered the server and got the *new* schema — but it had already written the stale schema into its episodic memory as "the schema for this tool." On a later task, cold-started from that memory, it routed against the stale schema again. The staleness had been *distilled into memory* and outlived the deployment that caused it. ## Condition of Validity A discovered capability entry is valid for routing if and only if all of the following hold at the moment of routing: 1. **Temporal bound respected.** `now - t_d <= min(server_cache_max_age, agent_freshness_ceiling)`. The server's `Cache-Control: max-age` (or `Expires`) is an *upper* bound on how long the server itself considers the descriptor current; the agent's own ceiling is a lower bound on how much staleness it will tolerate. The effective bound is the minimum. An agent that ignores `max-age` and uses only its own ceiling will over-trust; an agent that uses only `max-age` with no ceiling will route against descriptors a server forgot to expire. 2. **Version identity preserved.** The descriptor carries a version token (an `ETag`, a `version` field, or a content hash). The agent must store this token alongside the cached schema and must be able to re-validate cheaply — a conditional `GET` with `If-None-Match` — before a high-stakes route. A 304 confirms freshness; a 200 with a new `ETag` invalidates the cached schema and forces re-planning. 3. **Schema shape not silently widened.** The critical failure is not schema *change* (which a version token catches) but schema *coercion tolerance*: a server that accepts a superset of the advertised schema will return 200 on inputs the agent believed were invalid, or accept inputs the agent believed were valid but interpret them differently. The invariant: **if the server's validator is more permissive than its descriptor, the descriptor is not a contract and must not be treated as one.** Agents must treat descriptor schemas as *advisory* unless the server enforces them strictly, and must not rely on a 200 as proof that the intended semantics were applied. 4. **Discovery and execution are co-located or explicitly reconciled.** If the registry that served discovery is a different origin than the JSON-RPC endpoint, the agent must confirm the endpoint's own descriptor (or a version header on the execution response) matches the registry's claim. Registry lag is a first-class staleness source distinct from server rollover. ## Decision Boundary The agent must make an explicit decision at the routing boundary, not defer it to the call result: - **Route with confidence** when `now - t_d` is within bound, the version token is present, and the tool is idempotent or cheap to verify. No re-validation needed. - **Re-validate before route** (conditional GET, cheap) when the tool is non-idempotent, mutating, or feeds a downstream chain of length > 1. The cost of one conditional GET is dominated by the cost of a compounded semantic error. - **Refuse to route and re-plan** when the version token changed, when `now - t_d` exceeds the bound and re-validation fails, or when the descriptor schema and the server's observed coercion behavior diverge (detected by a prior call returning 200 on input the descriptor said was invalid — this is the tell that the descriptor is advisory, and the agent must downgrade its trust and re-plan rather than proceed). The boundary is sharp: **staleness is decided before the call, using the descriptor's own freshness metadata; it is never inferred from the call's success or failure.** A successful call against a stale descriptor is the failure mode, not evidence against it. ## Operational Effect When this boundary is respected, the operational profile changes in three measurable ways: 1. **Semantic error rate drops, but call count rises.** Conditional re-validation adds one cheap round-trip per high-stakes route. The trade is favorable because the alternative — a compounded semantic error — costs an entire task replay plus a memory-poisoning cleanup. 2. **Memory writes must be version-stamped.** Any schema distilled into episodic or semantic memory must carry the `ETag`/version token it was derived from. On cold start, a memory entry whose version token no longer matches the live descriptor is *not* a valid routing source; it is a hint that triggers re-discovery. Without this, staleness survives the deployment that caused it and re-emerges on cold start — the distillation-loss variant of the same bug. 3. **The server's permissiveness becomes a monitored signal.** An agent that tracks "calls that returned 200 on inputs the descriptor marked invalid" is detecting descriptor drift in real time, before it causes a downstream failure. This counter, when it increments, is the trigger to re-fetch and re-plan, not to retry. The guardrail is a single function at the routing boundary that refuses to emit a call whose capability binding cannot be shown fresh under the four conditions above. It must raise, not warn — a warning at the routing boundary is a warning that gets logged and ignored while the call proceeds. ```python import time from dataclasses import dataclass from typing import Optional class StaleCapabilityError(RuntimeError): """Raised when a discovered MCP capability cannot be shown fresh at route time.""" pass @dataclass(frozen=True) class CapabilityBinding: server_id: str tool_name: str discovered_at: float # t_d, monotonic seconds server_max_age: float # from Cache-Control: max-age agent_freshness_ceiling: float version_token: Optional[str] # ETag / version / content hash schema_advisory: bool # True if server validator is known-permissive def assert_routable( binding: CapabilityBinding, now: float, live_version_token: Optional[str], non_idempotent: bool, downstream_chain_length: int, ) -> None: """Enforce the four validity conditions before emitting a routed call. Callers must invoke this immediately before the JSON-RPC POST, not at discovery time and not after a failed call. """ age = now - binding.discovered_at effective_bound = min(binding.server_max_age, binding.agent_freshness_ceiling) # Condition 1: temporal bound. if age > effective_bound: raise StaleCapabilityError( f"{binding.server_id}/{binding.tool_name}: age={age:.1f}s exceeds " f"bound={effective_bound:.1f}s (server_max_age={binding.server_max_age}, " f"ceiling={binding.agent_freshness_ceiling})" ) # Condition 2: version identity must be present for high-stakes routes, # and must match the live token if we were able to re-validate. high_stakes = non_idempotent or downstream_chain_length > 1 if high_stakes and binding.version_token is None: raise StaleCapabilityError( f"{binding.server_id}/{binding.tool_name}: high-stakes route " f"(non_idempotent={non_idempotent}, chain={downstream_chain_length}) " f"requires a version token; descriptor carried none" ) if live_version_token is not None and binding.version_token is not None: if live_version_token != binding.version_token: raise StaleCapabilityError( f"{binding.server_id}/{binding.tool_name}: version drift " f"(cached={binding.version_token}, live={live_version_token}); " f"re-plan required" ) # Condition 3: advisory schema cannot back a mutating route. if binding.schema_advisory and non_idempotent: raise StaleCapabilityError( f"{binding.server_id}/{binding.tool_name}: descriptor schema is " f"advisory (server coerces) but route is mutating; 200 is not proof " f"of intended semantics" ) def route( binding: CapabilityBinding, now: float, live_version_token: Optional[str], non_idempotent: bool, downstream_chain_length: int, post_fn, payload: dict, ): assert_routable( binding, now, live_version_token, non_idempotent, downstream_chain_length ) return post_fn(binding.server_id, binding.tool_name, payload) ```