The big picture
OAuth 2.1 (a tightened version of OAuth 2.0) governs how a client gets a token, and how the server validates it. MCP layers on:
- Protected Resource Metadata (RFC 9728, SEP-985) — the server advertises which authorization server to use.
- Dynamic Client Registration — clients register on demand.
- Client ID Metadata Documents (SEP-991) — URL-based client identity that avoids per-server registration.
- OAuth Client Credentials (SEP-1046) — machine-to-machine flows.
- Enterprise-Managed Authorization (SEP-990) — IdP-enforced policy controls.
The authorization flow
- Client makes an MCP request without a token.
- Server responds
401with aWWW-Authenticateheader pointing at Protected Resource Metadata. - Client fetches the metadata, learns the authorization server URL.
- Client registers (DCR) or uses a Client ID Metadata Document URL.
- Client kicks off the authorization code flow with PKCE; user grants consent.
- Client exchanges code for an access token.
- Client retries the original MCP request with
Authorization: Bearer ….
Client ID Metadata Documents (SEP-991)
Pre-registration doesn't scale: AI clients connect to servers they've never seen. DCR works but requires the auth server to store every client's metadata. MCP's answer is the Client ID Metadata Document: the client's identifier IS a URL that returns its metadata.
- No database of registered clients.
- Auth server fetches metadata on demand.
- Document signing prevents tampering (Client ID Metadata Document Security).
Error responses
| Code | Meaning |
|---|---|
| 401 | Authorization required or token invalid. |
| 403 | Insufficient scopes or permissions. |
| 400 | Malformed authorization request. |
Local clients = public OAuth 2.1 clients
MCP treats every local client (Claude Desktop, IDE plug-ins) as a public OAuth 2.1 client. That has consequences:
- PKCE is mandatory.
- Client secrets MUST NOT be embedded in shipped binaries.
- Localhost redirect URIs need protection against port collisions and DNS rebinding.
Quick summary
- OAuth 2.1 + PKCE is the baseline
- Discover the auth server via Protected Resource Metadata (RFC 9728)
- Client ID Metadata Documents solve "no pre-existing relationship"
- Local clients are public — no embedded secrets, no skipping PKCE