Authorization: OAuth 2.1 for Remote Servers
MCP authorization (revision 2026-07-28) is OAuth 2.1 for HTTP transports: the MCP server is a resource server that publishes Protected Resource Metadata, the client discovers the authorization server, registers, runs authorization code with PKCE and the resource parameter, validates iss, and sends an audience-bound bearer token on every request. stdio servers take credentials from the environment instead.
Key points
- 1
Authorization is OPTIONAL. HTTP-based transports SHOULD follow the spec; stdio implementations SHOULD NOT and should take credentials from the environment (per-server
env, narrowly scoped tokens). - 2
Roles: MCP server = OAuth 2.1 resource server, MCP client = OAuth client, authorization server = issues tokens (co-hosted or separate). In 2025-03-26 the server could also act as the authorization server with
/authorize,/tokenand/registerfallbacks; 2025-06-18 made servers resource servers with Protected Resource Metadata and required RFC 8707. - 3
Discovery chain: unauthenticated request, then
401withWWW-Authenticate: Bearer resource_metadata=..., then the RFC 9728 PRM document (MUST list at least oneauthorization_serversentry), then RFC 8414 or OIDC Discovery metadata. Without the header, try/.well-known/oauth-protected-resource/<path>and then the root. - 4
Authorization server metadata for issuer
https://as/t1is tried as/.well-known/oauth-authorization-server/t1, then/.well-known/openid-configuration/t1, then/t1/.well-known/openid-configuration. The document'sissuerMUST be identical to the issuer used to build the URL, or it is rejected. - 5
Registration priority: pre-registered info, then Client ID Metadata Documents (HTTPS URL with a path as
client_id, advertised viaclient_id_metadata_document_supported), then Dynamic Client Registration (deprecated in 2026-07-28, earliest removal in the first revision on or after 2027-07-28), then asking the user. - 6
DCR clients MUST send
application_type(nativefor desktop, CLI and localhost apps,webfor remote browser apps); under OIDC the defaultwebclashes with loopback redirect URIs. Pre-registered and DCR credentials MUST be keyed by issuer and re-registered when the authorization server changes; CIMD IDs are portable. - 7
PKCE is mandatory with
S256when technically capable. Ifcode_challenge_methods_supportedis missing from the metadata, the client MUST refuse to proceed. - 8
The RFC 8707
resourceparameter (the server's canonical URI: scheme, no fragment, usually no trailing slash) MUST be sent in both the authorization and token requests, even if the authorization server ignores it. Servers MUST reject tokens whose audience is not themselves. - 9
RFC 9207: record the issuer before redirecting, then validate
issbefore redeeming the code. If metadata advertises support andissis absent, reject; ifissis present, compare by exact string match (no normalization); if neither, proceed. Ignore error details from a mismatched response. - 10
Tokens go in
Authorization: Beareron every HTTP request, never in the query string. Invalid or expired tokens get401; insufficient scope gets403witherror="insufficient_scope",scopeandresource_metadata; malformed requests get400. - 11
Scopes: use the challenge
scope, else all ofscopes_supported(so keep that list minimal). Step-up: request the union of previous and challenged scopes, retry a few times, and track attempts. Servers emit all scopes an operation needs in one challenge and MUST honour scope hierarchies. - 12
Extensions: OAuth Client Credentials for no-user workloads (JWT bearer assertion recommended) and Enterprise-Managed Authorization (ID token, then ID-JAG from the IdP, then an access token from the MCP authorization server). Both are negotiated via the
extensionscapability.
Common traps
Saying the MCP server must issue its own tokens. Since 2025-06-18 it is a resource server; the authorization server may be separate.
Treating PKCE as a defence against mix-up attacks. The client hands its
code_verifierto the attacker's token endpoint; onlyissvalidation stops mix-up.Forwarding the client's token to a downstream API (token passthrough). The server MUST use a separate token issued for the upstream API.
Requesting only the newly challenged scope on step-up and losing earlier permissions; request the union.
Calling DCR removed. In 2026-07-28 it is deprecated but still in the spec for authorization servers without CIMD support.
Validating signature and expiry but not audience. In Python SDK 2.3,
AuthSettings.validate_token_resourceleft unset behaves as False.Asking for API keys in chat, in tool arguments or through form-mode elicitation. Use URL-mode elicitation so secrets never reach the model or the client.
Read the source
Further reading
Suggest a resourceNo extra reading for Authorization: OAuth 2.1 for Remote Servers yet. Found a guide, video or cheat sheet that made it click? Share it and help the next learner.
Test yourself on Authorization: OAuth 2.1 for Remote Servers
Ten questions, with the answer and explanation after each one.