# MCP authorization: how OAuth works for MCP servers

> 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.

Source: https://www.honeyhive.ai/learn/mcp-authorization (updated 2026-11-17)

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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) calls the whole mechanism optional. For the wider threat picture, see [MCP security](/learn/mcp-security), and for the protocol itself, [Model Context Protocol](/learn/model-context-protocol).

## When you need it

The MCP [tutorial](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) in the spec, which leaves the authorization server's implementation out of scope.

## The flow, step by step

```text
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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/authorization-server-discovery) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) list at least one entry in `authorization_servers`. Without the header, the client [tries](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/authorization-server-discovery) `/.well-known/oauth-protected-resource` with the MCP endpoint path, then at the root.
3. **Authorization server metadata.** Clients [must support](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) both RFC 8414 and OpenID Connect Discovery. If the metadata lacks `code_challenge_methods_supported`, the client [must refuse](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) `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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration) 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](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) calls the most common case |
| Dynamic Client Registration (RFC 7591) | [Deprecated](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization), 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration) `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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization). For the initial scope, a client [uses](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization), kept for backwards compatibility | [Deprecated](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) |
| Issuer check | No `iss` validation section | Clients [must record](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) the current operation; the client merges scopes |
| Refresh tokens | No dedicated section | Servers [should not](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) list `offline_access` in challenges or `scopes_supported` |

The 2026-07-28 spec adds that a future revision is [expected](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](/learn/mcp-security).
- **Writing token validation by hand.** The [tutorial](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations) use HTTPS, and redirect URIs must be localhost or HTTPS. Access tokens should be short-lived.

## Testing and observing it

The [tutorial](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) 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](/learn/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](https://docs.honeyhive.ai/v2/tracing/mcp-tracing.md) 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](/learn/mcp-observability).

The optional [extensions](https://github.com/modelcontextprotocol/ext-auth) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) 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](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations) 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](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization). The client then runs a step-up authorization flow.
