MCP authorization: how OAuth works for MCP servers

Secure and govern
HoneyHive Engineering

MCP authorization is optional OAuth 2.1 for HTTP servers: the server is a resource server, clients discover its auth server, and tokens must be audience-bound.

MCP authorization is the optional OAuth 2.1 flow that lets an MCP client call a protected MCP server over HTTP on a user’s behalf. The server acts as an OAuth resource server, a separate authorization server issues tokens, and the client discovers both through metadata documents. The spec calls the whole mechanism optional. For the wider threat picture, see MCP security, and for the protocol itself, Model Context Protocol.

When you need it

The MCP tutorial strongly recommends authorization when a server works with user-specific data, when you need to audit who did what, when it grants access to APIs that need user consent, when enterprise access controls apply, or when you want per-user rate limits. A server using the stdio transport should not follow this flow and should take credentials from the environment instead.

The three roles

Role Does Does not
MCP server Acts as an OAuth 2.1 resource server: publishes Protected Resource Metadata, validates tokens Issue tokens
MCP client Acts as an OAuth 2.1 client: discovers, registers, runs the flow, sends the token on every request Send tokens from other issuers
Authorization server Authenticates the user and issues access tokens for the MCP server Have to live in the MCP server (it may be hosted with it or separately)

All three roles are defined in the spec, which leaves the authorization server’s implementation out of scope.

The flow, step by step

Client            MCP server        Auth server
  | request, no token  |                 |
  |------------------->|                 |
  | 401 + WWW-Auth.    |                 |
  |<-------------------|                 |
  | GET resource metadata                |
  |------------------->|                 |
  | GET auth server metadata             |
  |------------------------------------->|
  | browser: PKCE + resource + scope     |
  |------------------------------------->|
  | code (+ iss), then token request     |
  |<-------------------------------------|
  | request + Bearer token               |
  |------------------->|                 |
  1. Challenge. A request without a valid token gets a 401. The server must either put a resource_metadata URL in the WWW-Authenticate header or serve the metadata at a well-known URI, and it should include a scope in the header.
  2. Protected Resource Metadata. This RFC 9728 document must list at least one entry in authorization_servers. Without the header, the client tries /.well-known/oauth-protected-resource with the MCP endpoint path, then at the root.
  3. Authorization server metadata. Clients must support both RFC 8414 and OpenID Connect Discovery. If the metadata lacks code_challenge_methods_supported, the client must refuse to proceed, because that means no PKCE.
  4. Client registration. See the next section.
  5. User authorization. The client opens a browser with a PKCE challenge using S256, the resource parameter and the chosen scope. The spec requires resource in both the authorization and token requests, set to the canonical URI of the MCP server, and prefers the form without a trailing slash.
  6. Token use. The client sends Authorization: Bearer <token> on every HTTP request and never in the query string.

How clients identify themselves

Method Status in the 2026-07-28 spec Use when
Pre-registration Clients should support static credentials The client and authorization server already have a relationship
Client ID Metadata Document (CIMD) Clients and authorization servers should support it No prior relationship, which the tutorial calls the most common case
Dynamic Client Registration (RFC 7591) Deprecated, kept for older authorization servers Only as a fallback

With CIMD the client’s client_id is an HTTPS URL with a path, and the JSON document there must include client_id, client_name and redirect_uris. The authorization server fetches it, checks that client_id matches the URL and that the redirect URI is listed, and advertises support with client_id_metadata_document_supported. The spec also warns that CIMD alone cannot stop another app from impersonating a client on a localhost redirect URI, and that fetching client-supplied URLs raises SSRF risk for the authorization server. A client that supports several methods tries them in this order: pre-registered, CIMD, DCR, then asking the user.

Status codes and scopes

Status When Notes
401 No token, or an invalid or expired one Include resource_metadata and scope in WWW-Authenticate
403 Valid token, missing scope Use error="insufficient_scope" and the scope the operation needs
400 Malformed authorization request

The status codes are from the spec’s error table. For the initial scope, a client uses the scope from the 401 challenge, else every scope in scopes_supported, else it omits scope. After a 403, the client runs step-up authorization: it takes the union of the scopes it requested before and those in the challenge, re-authorizes, and retries only a few times.

What changed between 2025-11-25 and 2026-07-28

Both versions share the core design. The differences that touch an implementation:

Area 2025-11-25 2026-07-28
Dynamic Client Registration Optional, kept for backwards compatibility Deprecated
Issuer check No iss validation section Clients must record the issuer and validate iss (RFC 9207) before sending the code, including on error responses
Insufficient-scope challenge Recommended approach is existing plus new scopes Scope describes the current operation; the client merges scopes
Refresh tokens No dedicated section Servers should not list offline_access in challenges or scopes_supported

The 2026-07-28 spec adds that a future revision is expected to make iss in authorization responses a MUST for authorization servers, so emitting it now eases the move.

Mistakes the spec and tutorial warn about

  • Skipping audience checks. The server must validate that a token was issued for it and must not accept or transit any other token. Forwarding the client’s token to a downstream API is the passthrough problem described in MCP security.
  • Writing token validation by hand. The tutorial says to use well-tested libraries, to accept access tokens only (never ID tokens) and from one issuer.
  • An authorization server that hides PKCE support. The tutorial notes that some products support PKCE but omit code_challenge_methods_supported, so spec-following clients refuse to connect. Open the real metadata document before choosing one.
  • 401 during an outage. If the server cannot reach the JWKS or introspection endpoint, the tutorial says to return a 5xx, because a 401 makes users log in again without fixing anything.
  • Open Dynamic Client Registration. The tutorial says anyone can register a client against an open registration_endpoint, so disable it or restrict it.
  • Plain HTTP. All authorization server endpoints must use HTTPS, and redirect URIs must be localhost or HTTPS. Access tokens should be short-lived.

Testing and observing it

The tutorial suggests two quick checks: curl -i -X POST on the MCP URL should return a 401 with a WWW-Authenticate header, and the well-known metadata URL should return the Protected Resource Metadata. The MCP Inspector runs the full login flow. To build a server first, see build an MCP server.

Once a server is live, auth failures show up as 401 and 403 responses on tool calls. HoneyHive’s MCP tracing guide shows how to instrument MCP servers and clients, which gives you the calls to look at when a client keeps looping through step-up. See also MCP observability.

The optional extensions for OAuth client credentials and enterprise-managed authorization are listed as Stable at revision 2026-07-28. They cover machine-to-machine and enterprise cases that the core user flow does not.

FAQ

Does MCP require authorization?

No. The spec calls it optional. HTTP-based servers should follow it, and stdio servers should instead take credentials from the environment.

Is an MCP server an OAuth authorization server?

No, it is the resource server. It validates access tokens and does not issue them. The tutorial advises using an existing identity provider, because client registration happens between the client and the authorization server.

Is Dynamic Client Registration deprecated in MCP?

Yes, as of protocol version 2026-07-28. The tutorial says new implementations should use Client ID Metadata Documents, and existing clients can still fall back to DCR.

What is the resource parameter in MCP OAuth?

An RFC 8707 value naming the MCP server the token is for. The spec requires clients to send it in both the authorization and token requests, even if the authorization server does not support it.

Can an MCP server pass the client's token to another API?

No. The spec says an MCP server that calls upstream APIs must not pass through the token it received. The upstream token is a separate one, issued by the upstream authorization server.

What does an MCP server return for a missing scope?

A 403 with a WWW-Authenticate challenge carrying error="insufficient_scope" and the needed scope, per the spec. The client then runs a step-up authorization flow.

Share