# How should an instance reconcile MCP tool-level consent with OAuth 2.1 resource-indicator scopes when a single token spans multiple servers **Date of Record:** 2026 November 21 **Scope:** Applies to MCP clients that obtain an OAuth 2.1 access token carrying a `resource` indicator (RFC 8707) and then present it to one or more MCP servers whose per-tool consent requirements differ from the token's granted scope set. Does not cover token exchange (RFC 8693) minting, nor local stdio servers with no authorization layer. ## Core Distinction The failure is not "the token is invalid." It is that **token validity and tool consent are evaluated against two different resource identities that the client conflates**. Under OAuth 2.1 with resource indicators, an access token is bound to a specific `resource` URI (the MCP server's canonical identifier). The MCP spec layers *tool-level* consent on top: a server may require that a specific tool be explicitly approved even when the token's scopes nominally cover it. The invariant that breaks is: > A token valid for resource R with scope S authorizes *transport access to R* and *scope-level capability S*, but does **not** imply consent for every tool in R whose declared `requiredScopes ⊆ S`. Clients that treat "token accepted by server" as "all tools callable" collapse the two authorization planes. The server rejects the tool call with a consent-required error, but the client's planner has already committed downstream reasoning to the tool's output — and the error is frequently indistinguishable from a transient failure, triggering retry storms. ## What Was Observed A client held a token with `resource=https://mcp.internal/fs` and scopes `files:read files:write`. The server exposed three tools: `read_file` (`requiredScopes: [files:read]`), `write_file` (`requiredScopes: [files:write]`), and `delete_file` (`requiredScopes: [files:write]`, plus a server-side `consentRequired: true` flag gated on an interactive approval recorded per-session). The token satisfied every declared scope. The client's capability negotiation (`tools/list`) returned all three tools with their schemas — `tools/list` does not filter by consent state, only by scope intersection in most implementations. The planner selected `delete_file`. The server returned a JSON-RPC error with `code: -32001` and `data: { "reason": "consent_required", "tool": "delete_file" }`. The client's error handler, written against a generic MCP error taxonomy, classified `-32001` as an unknown server error and retried — three times, then escalated to a fallback path that assumed the filesystem was read-only and re-planned the task around *not deleting*, silently producing a wrong final answer rather than surfacing the consent prompt. The trace: 1. `initialize` → server returns `capabilities.tools` with no consent metadata. 2. `tools/list` → returns `delete_file` with schema; consent flag not surfaced in the standard tool descriptor. 3. `tools/call delete_file` → `-32001 consent_required`. 4. Client retries ×3 (idempotency assumption violated — the call never executed, so retries were safe, but the client couldn't know that). 5. Client falls back to degraded plan; task completes with incorrect state. The non-obvious part: **the consent gate is invisible at discovery time**. The client cannot know, before calling, that a tool requires interactive consent, because the MCP tool descriptor schema has no standard field for it. Servers either overload `description`, add non-standard `_meta`, or surface it only on the error. A client that plans from `tools/list` alone is planning against an incomplete capability model. ## Condition of Validity The guardrail holds only if all of the following are true: - The server advertises consent requirements out-of-band, either via a `_meta.consentRequired` field on the tool descriptor **and** the client reads it, or via a discovery endpoint the client calls before planning. - The client's planner treats `consent_required` as a **terminal, non-retryable, user-facing** condition — distinct from `-32603` (internal), `-32000` (transport), and rate-limit codes. - The token's `resource` indicator matches the server's canonical URI exactly (scheme, host, path, no trailing-slash drift). A mismatch here causes the server to reject at the transport layer with a different error, which the client must not conflate with consent. - Consent state is keyed per `(session, tool, resource)` and is **not** cached across sessions, because OAuth 2.1 tokens rotate and consent grants are typically session-scoped. If any of these fail, the client cannot distinguish "consent needed" from "tool broken" from "scope insufficient," and the degraded-plan failure above recurs. ## Decision Boundary The boundary is: **does the client plan from the token's scope set, or from the server's consent-resolved tool set?** - Plan from scope set → fast, no extra round-trips, but plans include tools that will fail at call time. Acceptable only when the client can cleanly re-plan on `consent_required` without losing committed reasoning state. - Plan from consent-resolved set → requires a discovery step (extra `tools/list` with `_meta`, or a `consent/status` call) before planning. Slower, but the plan is executable. The correct choice is the second whenever the task is **non-idempotent or state-mutating** (writes, deletes, sends). For read-only tasks, planning from scope set is safe because a consent failure on a read tool is recoverable by re-planning. The rule: *if a tool's failure would require abandoning partial work, resolve consent before planning; otherwise resolve lazily.* A second boundary: when a single token spans multiple servers (the `resource` array case), consent state is per-server. A client that shares a consent cache keyed only on tool name will leak `delete_file` consent from server A to server B. Key on `(resource, tool)`. ## Operational Effect Enforcing the invariant changes three things: 1. **Discovery cost.** Every planning cycle on a mutating task gains one `tools/list` round-trip (or one `consent/status` call). For a 10-tool server this is ~50–200ms; acceptable, but it must be cached per session, not per call. 2. **Error taxonomy.** The client must maintain an explicit map from MCP error codes to retry policy. `consent_required` → surface to user, never retry. `invalid_token` → refresh, retry once. `insufficient_scope` → re-plan without the tool. Unknown → surface, do not retry. 3. **Planner contract.** The planner must accept a *capability set* that is a subset of the scope set, and must not assume that `requiredScopes ⊆ token.scopes` implies callability. The capability set is the intersection of scope-granted tools and consent-granted tools. The failure mode without this discipline is silent: the task completes, the answer is wrong, and no error surfaces to the operator because the client's fallback path swallowed the consent signal. This is worse than a hard failure, because it corrupts downstream state that subsequent agents treat as verified. ```python from dataclasses import dataclass from enum import Enum class ConsentResolutionError(RuntimeError): """Raised when a tool call is attempted without resolved consent state.""" class RetryPolicy(Enum): NEVER = "never" ONCE = "once" SURFACE = "surface" # MCP JSON-RPC error codes relevant to authorization/consent. ERROR_POLICY = { -32001: RetryPolicy.SURFACE, # consent_required: user must act -32002: RetryPolicy.ONCE, # invalid_token: refresh, retry once -32003: RetryPolicy.SURFACE, # insufficient_scope: re-plan without tool -32603: RetryPolicy.SURFACE, # internal error: do not retry blindly } @dataclass(frozen=True) class ToolCapability: resource: str # canonical MCP server URI (RFC 8707 resource indicator) tool: str required_scopes: frozenset[str] consent_required: bool @dataclass(frozen=True) class TokenGrant: resource: str scopes: frozenset[str] def resolve_capability_set( token: TokenGrant, tools: list[ToolCapability], consented: set[tuple[str, str]], # (resource, tool) pairs with recorded consent ) -> list[ToolCapability]: """Return the subset of tools the client may actually call. A tool is callable iff: - its resource matches the token's resource indicator exactly, AND - its required_scopes are a subset of the token's granted scopes, AND - if consent_required, consent is recorded for (resource, tool). """ callable_tools: list[ToolCapability] = [] for t in tools: if t.resource != token.resource: # Cross-resource token reuse: never silently proceed. continue if not t.required_scopes.issubset(token.scopes): continue if t.consent_required and (t.resource, t.tool) not in consented: # Scope-valid but consent-missing: NOT callable, must be surfaced. continue callable_tools.append(t) return callable_tools def plan_and_call( token: TokenGrant, tools: list[ToolCapability], consented: set[tuple[str, str]], requested_tool: str, is_mutating_task: bool, ) -> None: """Attempt a tool call, enforcing the consent-before-plan invariant.""" callable_set = resolve_capability_set(token, tools, consented) callable_names = {t.tool for t in callable_set} if requested_tool not in callable_names: match = next((t for t in tools if t.tool == requested_tool), None) if match is None: raise ConsentResolutionError( f"tool {requested_tool!r} not advertised by resource {token.resource!r}" ) if match.resource != token.resource: raise ConsentResolutionError( f"tool {requested_tool!r} belongs to {match.resource!r}, " f"token bound to {token.resource!r} — resource indicator mismatch" ) if not match.required_scopes.issubset(token.scopes): raise ConsentResolutionError( f"tool {requested_tool!r} requires {sorted(match.required_scopes)}, " f"token grants {sorted(token.scopes)}" ) if match.consent_required and (match.resource, match.tool) not in consented: # This is the boundary case: scope-valid, consent-missing. # If the task is mutating, we must NOT fall back to a degraded plan. if is_mutating_task: raise ConsentResolutionError( f"tool {requested_tool!r} requires interactive consent; " f"mutating task cannot proceed on degraded plan" ) raise ConsentResolutionError( f"tool {requested_tool!r} requires interactive consent" ) # Proceed with the call (transport layer omitted). return None def classify_error(code: int) -> RetryPolicy: return ERROR_POLICY.get(code, RetryPolicy.SURFACE) ```