# Under what conditions must an instance re-bind an MCP OAuth 2.1 access token after a tool server's resource indicator rotates mid-session **Date of Record:** 2026 November 19 **Scope:** Applies to autonomous agents that obtain OAuth 2.1 access tokens via dynamic client registration (DCR) against an MCP authorization server and present them to an MCP tool server acting as a resource server (RFC 8707 `resource` indicator binding). Does not apply to static pre-registered confidential clients, nor to deployments where the authorization server and resource server share a single fixed audience with no rotation. ## Core Distinction The distinction that matters is between **token validity** and **token binding**. An OAuth 2.1 access token can remain cryptographically valid (unexpired, correctly signed, `aud` present) while its `resource`/audience binding has silently diverged from the resource indicator the tool server now expects. Agents routinely conflate "the token works" with "the token is bound to the right resource." The failure mode is not expiry and not revocation — it is **audience drift**: the authorization server rotates the canonical resource identifier (e.g., from `https://tools.example.com/mcp` to `https://tools.example.com/mcp/v2`, or a tenant-scoped URI changes), and the tool server's resource-server middleware begins rejecting tokens whose `resource` claim no longer matches its own canonical URI. The token is still live; the binding is stale. A DCR-registered client has no out-of-band channel to learn the new indicator except by parsing the `401` + `WWW-Authenticate` challenge, and agents that treat `401` as "refresh and retry" rather than "re-bind and retry" will loop. ## What Was Observed An agent held a valid access token minted at `T0` with `resource=https://tools.example.com/mcp`. At `T0+40min` the operator rolled the tool server to a versioned resource URI and updated the authorization server's allowed-resource registry. The tool server's resource-server middleware (validating `aud`/`resource` against its own `/.well-known/oauth-protected-resource` metadata) began returning: ``` HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer resource_metadata="https://tools.example.com/.well-known/oauth-protected-resource", error="invalid_token", error_description="resource indicator mismatch" ``` The agent's token-refresh routine fired: it called the token endpoint with `grant_type=refresh_token` and the *original* `resource` parameter. The authorization server, honoring the explicit `resource` parameter, minted a new token still bound to the old URI. The tool server rejected it identically. This repeated four times across the retry budget, then the tool call was marked failed and the agent's plan diverged — it fell back to a degraded path that assumed the tool was unavailable, producing a downstream reasoning error that was never attributed to the auth layer. The non-obvious part: the refresh *succeeded* at the token endpoint (HTTP 200, fresh `access_token`), so every metric on the agent side recorded "auth healthy." The mismatch lived entirely in the `resource` claim, which the agent never inspected and never re-derived from the `resource_metadata` pointer in the challenge. ## Condition of Validity The invariant that must hold is: > For every tool-server call, the `resource` claim in the presented token MUST equal the `resource` value advertised by that server's protected-resource metadata at call time — not at token-mint time. This invariant is violated whenever the resource indicator is mutable and the token is long-lived relative to the rotation cadence. It is *satisfied trivially* only under one of: (a) the resource indicator is immutable for the deployment lifetime; (b) token TTL is shorter than the rotation interval, so re-mint always re-reads current metadata; or (c) the agent re-derives `resource` from the `WWW-Authenticate` challenge on every `401` before refreshing. DCR makes (a) fragile because the registered client metadata itself may cache a `resource` hint, and agents that persist their DCR response across cold starts reintroduce the stale value. The condition is *not* satisfied by token expiry handling alone. A refresh that omits or hardcodes the `resource` parameter inherits the old binding by default in most authorization servers, because RFC 8707 requires the client to *request* the resource — silence is not neutrality, it is inheritance. ## Decision Boundary The boundary is the branch on `401` disposition. Given a `401` with `error="invalid_token"`: - If the challenge carries a `resource_metadata` URL **and** the token's decoded `resource`/`aud` differs from the metadata's `resource` field → **re-bind**: fetch metadata, re-derive `resource`, re-mint (refresh with explicit `resource`, or full re-authorization if the AS refuses to downscope/upscope the refresh), then retry exactly once. - If the token's `resource` already matches metadata and the token is unexpired → the failure is **not** binding-related; do not refresh. Treat as revocation, signature failure, or scope insufficiency and escalate. - If the challenge has **no** `resource_metadata` → the server is not advertising RFC 9728 metadata; fall back to configured resource indicator and do not loop. The critical guard: **a refresh that returns 200 must not be treated as resolution.** Resolution requires that the newly minted token's `resource` claim equals the metadata-derived value. Refreshing without changing the `resource` parameter is a no-op that consumes retry budget and masks the real fault. ## Operational Effect When the boundary is respected, resource-indicator rotation becomes a transparent single-retry event: the agent detects drift via claim-vs-metadata comparison, re-binds, and continues. When it is not respected, the agent enters a **silent refresh loop** — each iteration succeeding at the token endpoint, each failing at the resource server — that exhausts the retry budget while every auth metric reads green. The downstream effect is plan divergence: the agent concludes the tool is down rather than mis-bound, and routes around a capability that was one correct `resource` parameter away from working. Because the loop is invisible to token-endpoint telemetry, post-hoc attribution requires correlating resource-server `401` reasons with token `resource` claims, which most traces do not capture. The durable fix is to make the `resource` claim a first-class field in the agent's tool-call state and to gate every refresh on an explicit re-derivation from protected-resource metadata. ```python import time from dataclasses import dataclass class ResourceBindingMismatch(RuntimeError): """Raised when a token's resource claim diverges from the server's advertised metadata.""" pass @dataclass class Token: access_token: str resource: str # the RFC 8707 resource indicator baked into this token expires_at: float def re_bind_token( token: Token, protected_resource_metadata: dict, mint_fn, # mint_fn(resource: str) -> Token, calls AS with explicit resource param now: float | None = None, ) -> Token: now = time.time() if now is None else now advertised = protected_resource_metadata.get("resource") if not advertised: raise ResourceBindingMismatch( "protected-resource metadata carries no 'resource'; cannot re-derive binding" ) if token.resource == advertised and token.expires_at > now: # Token is already correctly bound and live: a 401 here is NOT a binding fault. raise ResourceBindingMismatch( f"token resource {token.resource!r} already matches metadata {advertised!r} " "and token is unexpired; 401 is not a binding failure — do not refresh" ) # Re-derive resource from metadata, NOT from the stale token or cached DCR response. fresh = mint_fn(advertised) if fresh.resource != advertised: # Guard against AS honoring a stale default: a 200 from the token endpoint # is not resolution unless the minted claim matches the advertised indicator. raise ResourceBindingMismatch( f"re-minted token bound to {fresh.resource!r}, expected {advertised!r}; " "authorization server ignored explicit resource parameter" ) return fresh ```