Skip to main content
The Model Context Protocol (MCP) specification (2025-11-25 and the draft revision) mandates OAuth 2.1 with PKCE for any MCP server that exposes tools over HTTP. The authorization layer is more involved than a typical app-login because the caller is an AI agent, not a human, and the chain of delegation must be auditable and revocable at every link.
Isometric diagram of an MCP client discovers, registers with and authorizes against the theAuth authorization server using PKCE S256, receives a token, and the MCP server validates that token.

The MCP client discovers, registers and authorizes with PKCE S256, then the MCP server validates the token.

What the MCP spec requires

  1. An OAuth 2.1 AS that mints RFC 9068 JWT access tokens bound to a specific resource via RFC 8707.
  2. Agent identities: Long-lived client credentials for the agents a user trusts (client_credentials grant).
  3. Delegation grants: A user-approved record that lets a specific agent act on a specific resource. Revoking the grant invalidates every derived token at the next introspection refresh.
  4. Token exchange (RFC 8693): When an agent acts on behalf of a user, the access token carries an act claim chain so the resource server can see the full delegation path and reject the request if any link is revoked.
  5. Resource server validation: The MCP tool server validates tokens, enforces audience binding, walks the actor chain, and emits the correct WWW-Authenticate header on failure (RFC 6750 + RFC 9728).
  6. Discovery documents: /.well-known/oauth-authorization-server (RFC 8414) and /.well-known/oauth-protected-resource (RFC 9728) so MCP clients can auto-configure.

How theauth-go covers the spec

Every step ships in theauth-go:

The one-import claim

The mcpresource module is a separately versioned, zero-dependency Go module. A consumer importing it does not transitively pull theauth core or any storage adapter. This matters for MCP tool servers that are operated independently of the AS.

Actor chain depth

The RFC 8693 act chain is capped at 3 links (configurable via AgentConfig.MaxChainDepth, hard ceiling 3). Deeper chains are rejected with invalid_request: actor chain depth exceeded. This prevents runaway delegation trees and limits blast radius if any agent is compromised.

Revocation propagation

When a user revokes a delegation grant:
  1. The delegation_grants.revoked_at field is set immediately.
  2. New introspection calls return active: false.
  3. The mcpresource validator refreshes its introspection cache within CacheTTL (default 60 seconds).
  4. After the TTL, every request using a derived token returns 401.
There is no immediate token blacklist push; the propagation window is the cache TTL. WithCacheTTL(d) only accepts positive values. Zero and negative values are ignored and the 60 second default stays, so WithCacheTTL(0) does not turn on per request introspection. The middleware also honors the Cache-Control: max-age header on introspection responses. When the introspection response carries a Cache-Control: max-age, that value replaces the cache TTL for that result, whether shorter or longer, parsed in whole seconds. To get tighter revocation, either:
  • Have the authorization server answer introspection with a short max-age, or
  • Install a revocation checker with mcpresource.WithRevocationChecker (or WithDeviceRevocationIntrospection for device tokens) that runs on every request. Keep it fast or cache it yourself.
See Resource server for the options.

Next steps

Last modified on October 17, 2026