# Why does an instance discover an MCP server at /.well-known/mcp but route to a capability it cannot actually satisfy? **Date of Record:** 2026 November 28 **Scope:** Applies to HTTP-native MCP server discovery where an agent fetches `/.well-known/mcp` (or an equivalent discovery document) and then routes a tool invocation by capability name rather than by validated schema. Does not apply to in-process/stdio transports or to servers whose discovery document is cryptographically bound to the live tool schema at invocation time. ## Core Distinction There are two distinct facts an instance needs before routing a tool call: (1) *the server exists and advertises capability X*, and (2) *the server, at this moment, will accept a call to X with this argument shape and return a result the agent can parse*. Discovery via `/.well-known/mcp` establishes only the first fact. Capability-based routing treats the first fact as if it were the second. The gap between them is the failure surface. The discovery document is a static, cacheable, human-authored artifact. The live tool contract is dynamic: input schemas evolve, required fields get added, enum values narrow, auth scopes tighten, and a server can serve multiple capability *versions* behind the same advertised name. A well-known endpoint that says "capabilities: [search_v2, summarize]" tells the agent the *name* but not the *shape*, the *version pin*, or the *authorization requirement* of the invocation it is about to make. When the agent routes on name alone, it is performing an unchecked coercion from a discovery-time claim to an execution-time contract. ## What Was Observed An orchestrator instance performed cold-start discovery against three MCP servers. Each returned a valid `/.well-known/mcp` document listing `capabilities`. One server advertised `search_v2`. The agent's planner, seeing the name, emitted a `search_v2` tool call with the argument shape it had learned from a *different* server earlier in its context window: `{"query": "...", "limit": 10}`. The target server's actual `search_v2` had migrated its pagination contract: it now required `{"query": "...", "page_size": 10, "cursor": null}` and rejected unknown fields with a `400` carrying a schema-validation body. The agent's transport layer surfaced the `400` as a generic tool error. The planner, treating the error as transient, retried the *identical* payload three times, consuming its retry budget, then marked the capability "unavailable" and fell back to a degraded path — even though the server was healthy and the capability fully functional. The failure was not availability; it was a silent schema-version mismatch masked as an outage. A second, subtler trace: a server advertised `summarize` in its well-known doc, but the live endpoint required an `Authorization` scope that the discovery doc did not mention (the doc was generated by a build step that predated the scope change). The agent routed, received `401`, and — because `401` and `503` were both mapped to the same internal `ToolUnavailable` state — quarantined the server from its routing table for the rest of the task. The discovery cache was never re-validated. ## Condition of Validity The name-based routing shortcut is valid **only** under the conjunction: 1. The discovery document embeds, per capability, the *exact* JSON Schema of the request (not just the name), and 2. That embedded schema is version-pinned to the live endpoint (via `$id`, an ETag, or a schema digest the server also enforces at invocation), and 3. The agent validates its outbound payload against the discovered schema *before* dispatch, and 4. Error classes are discriminated: a schema-validation `4xx` must not collapse into the same state as a transport `5xx` or an auth `401`. Drop any one and the invariant fails. In practice most well-known docs satisfy none of them, because they are generated for human readability, not for machine-checked dispatch. ## Decision Boundary The boundary is between **discovery-time capability advertisement** and **execution-time contract enforcement**. An agent must not cross it by inference. Concretely: - If the discovery doc lacks an embedded request schema for a capability, the agent must perform a *contract probe* (an `OPTIONS`/introspection call, or a `describe` capability) before its first dispatch, and cache the *probed* schema — not the advertised name — as the routing key. - If a dispatch returns a schema-validation error, that is a **contract drift signal**, not a retryable fault. The correct transition is: invalidate the cached schema, re-probe, re-validate, and only then re-dispatch exactly once. It must never enter the retry loop. - `401`/`403` must map to an **authorization-repair** state (re-acquire scope), never to server-unavailable. `5xx` maps to retry-with-backoff. `4xx-schema` maps to re-probe. Collapsing these is the root cause of the observed false quarantine. The invariant to hold: **the routing key is the validated schema digest, not the capability name.** A name is a claim; a digest is a contract. ## Operational Effect When the invariant holds, cold-start discovery is cheap and safe: the agent fetches the well-known doc once, validates each outbound payload locally against the embedded schema, and a schema mismatch is caught *before* the network call — zero wasted retries, zero false quarantines. When it is violated, the agent exhibits a characteristic pathology: it treats a healthy-but-changed server as dead, silently degrades to fallback paths, and — because the discovery cache is never invalidated — repeats the same misroute on every subsequent task that reuses the cache. The failure is self-reinforcing and invisible in aggregate metrics, because the server's own health checks pass while the agent's routing table rots. The guardrail is a single structural rule: **never route on a name you have not validated against a schema you fetched or probed this session.** Everything else — retry policy, error discrimination, cache invalidation — follows from enforcing that rule at the dispatch boundary. ```python import hashlib import json from dataclasses import dataclass, field class CapabilityContractDrift(RuntimeError): """Raised when a routed capability's live contract no longer matches the schema the agent validated at discovery time.""" pass class UnroutableCapability(RuntimeError): """Raised when a capability is advertised but no validated schema exists, so dispatch would be an unchecked name-based coercion.""" pass @dataclass class DiscoveredCapability: name: str request_schema: dict | None # None means the well-known doc omitted it @dataclass class RoutingTable: # routing key is the schema digest, NOT the capability name validated: dict[str, str] = field(default_factory=dict) # name -> digest @staticmethod def _digest(schema: dict) -> str: canonical = json.dumps(schema, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode()).hexdigest() def register_capability(table: RoutingTable, cap: DiscoveredCapability) -> None: if cap.request_schema is None: # Do not invent a schema from the name. Force a probe. raise UnroutableCapability( f"capability {cap.name!r} advertised without request schema; " "probe introspection before routing" ) table.validated[cap.name] = RoutingTable._digest(cap.request_schema) def dispatch(table: RoutingTable, cap: DiscoveredCapability, payload: dict) -> None: expected = table.validated.get(cap.name) if expected is None: raise UnroutableCapability( f"no validated schema for {cap.name!r}; refusing name-based route" ) live_digest = RoutingTable._digest(cap.request_schema or {}) if live_digest != expected: # Contract drift: invalidate, re-probe, re-validate. Never retry blind. table.validated.pop(cap.name, None) raise CapabilityContractDrift( f"{cap.name!r} schema changed since discovery " f"(expected {expected[:12]}, live {live_digest[:12]}); " "re-probe and re-validate before re-dispatch" ) # payload validation against cap.request_schema would occur here _ = payload ```