MCP OAuth

Updated November 24, 2026

MCP OAuth is the authorization flow that the Model Context Protocol defines for servers reached over HTTP, built on OAuth 2.1. The user signs in with the service and approves access, and the MCP client receives an access token that it sends with every request. The server accepts only tokens that were issued for it.

In short: MCP OAuth is the OAuth 2.1 based authorization flow that lets an MCP client get a scoped access token for a remote MCP server after the user signs in, without handling a static API key.

How MCP OAuth works

Authorization is optional in MCP, and the specification defines it for HTTP-based transports 1. Three parties take part. The MCP server is the OAuth 2.1 resource server, the MCP client is the OAuth 2.1 client, and an authorization server signs the user in and issues tokens 1. The authorization server may be hosted with the MCP server or run as a separate service 1.

When a client calls a protected server without a valid token, the server answers HTTP 401 and can put a resource_metadata URL in the WWW-Authenticate header 2. That URL points to the server's Protected Resource Metadata document, which must list at least one authorization server in its authorization_servers field 2. If the header carries no URL, the client falls back to well-known paths such as /.well-known/oauth-protected-resource 2.

Next the client reads the authorization server's own metadata, published under RFC 8414 or OpenID Connect Discovery 1.0, and clients must support both 1. Before the flow starts, the client needs a client ID from a Client ID Metadata Document, pre-registration or Dynamic Client Registration 1. The specification marks Dynamic Client Registration as deprecated and keeps it only for backward compatibility 1.

The user then signs in and approves access in the browser. The client uses PKCE, a secret verifier and challenge pair that stops anyone else from redeeming an intercepted authorization code 3. It also sends a resource parameter that names the exact MCP server the token is for, in both the authorization request and the token request 1.

Once it has a token, the client sends it as a Bearer token in the Authorization header on every HTTP request 1. The server validates the token and checks that it was issued for that server as the audience 1. A token with too few scopes gets HTTP 403 with an insufficient_scope error, and the client can run a step-up flow that asks for the missing scopes while keeping the ones already granted 1.

The whole flow applies to a remote MCP server. A server on the stdio transport should skip it and read credentials from its environment, such as an API key in an environment variable 1.

What the MCP authorization spec requires

The specification builds on a selected subset of OAuth standards and makes several of them mandatory 1. The main duties for clients and servers follow.

Protected Resource Metadata. MCP servers must implement RFC 9728, and clients must use it to discover the authorization server 1.

Authorization server metadata. Authorization servers must offer RFC 8414 metadata or OpenID Connect Discovery, and clients must support both 1.

PKCE. Clients must implement PKCE and must refuse to proceed if the authorization server metadata lacks code_challenge_methods_supported 3.

Resource indicators. Clients must include the RFC 8707 resource parameter in both authorization and token requests 1.

Issuer check. Clients must record the authorization server's issuer before redirecting the user and validate the iss value in the response before sending the code to any token endpoint 1.

Audience checks. Servers must accept only tokens valid for their own resources and must not accept or pass on any other tokens 1.

Transport security. All authorization server endpoints must use HTTPS, and redirect URIs must be localhost or HTTPS 3.

Token lifetime. Authorization servers should issue short-lived access tokens and must rotate refresh tokens for public clients 3.

Scopes follow least privilege. Servers should name the scopes a request needs in the WWW-Authenticate header, and clients should request only what their operations need 1.

Example of an MCP OAuth sign-in

A sales operations lead connects RichAPI to an MCP client for the first time. On the RichAPI MCP page the setup takes three steps 4.

text
Step 1   Paste https://mcp.richapi.ai/mcp into the MCP client
Step 2   Sign in when the client opens RichAPI in the browser
Step 3   Click Allow

The MCP authorization specification describes what a compliant client and server do behind steps like these.

text
1. Client calls the MCP endpoint without a token
2. Server replies 401 with a resource_metadata URL
3. Client reads the protected resource metadata
4. Client reads the authorization server metadata
5. Browser opens for sign-in and consent, using PKCE
6. Client exchanges the code for an access token
7. Client retries the call with a Bearer token

Steps 1 to 4 are discovery, which the authorization server discovery rules define 2. Step 5 is where PKCE protects the code, and step 6 includes the resource parameter so the token is bound to the server it was requested for 3. In step 7 the token travels in the Authorization header, never in the URL 1.

The lead never copies a key. The RichAPI page says there is no API key to copy, and signup includes 100 free credits with no credit card 4. When the token expires, the client uses a refresh token if one was issued or sends the lead back through sign-in, and the server answers any expired token with HTTP 401 1.

Later, the lead asks the assistant to research a list of accounts. Each tool call is an authenticated request to the same server, and the client shows a cost summary when each prompt finishes 4.

MCP OAuth vs API key

Both prove that a caller may use a server. An API key is a static secret copied into configuration, while MCP OAuth issues an access token after the user signs in, and that token must be bound to one MCP server 1.

MCP OAuthAPI key
What it answersWhich user approved this client, with which scopes?Which account owns this request?
InputA browser sign-in and consentA secret pasted into config or code
OutputAn access token for one serverThe same key sent on every call
Cost driverRunning an authorization serverStoring and rotating keys safely
Main riskMisconfigured scopes or redirect URIsA leaked key in a file or repository
Use it whenPeople connect apps to a hosted serverCode calls an API from a backend job
Read the reference →

Frequently asked questions

Does MCP require OAuth?

Authorization is optional in MCP 1. When an HTTP-based server supports it, the specification says it should follow the MCP authorization flow, which is built on OAuth 2.1 1. Servers on the stdio transport should take credentials from the environment instead 1.

What OAuth version does MCP use?

MCP authorization is based on the OAuth 2.1 draft, together with RFC 8414 for authorization server metadata, RFC 8707 for resource indicators and RFC 9728 for protected resource metadata 1. Clients without a prior relationship to the server can identify themselves with Client ID Metadata Documents 1.

What is protected resource metadata in MCP?

It is a JSON document, defined in RFC 9728, that an MCP server publishes to tell clients which authorization server issues its tokens 1. The server points to it from the WWW-Authenticate header on a 401 response or serves it at a well-known path 2.

Why does MCP OAuth use PKCE?

PKCE protects the authorization code. The client creates a secret verifier and challenge pair, so only the client that started the flow can exchange the code for a token 3. MCP clients must use the S256 method when technically capable and must stop if the server does not support PKCE 3.

The bottom line

MCP OAuth is the OAuth 2.1 based flow that remote MCP servers use to sign users in and issue tokens bound to one server 1. Servers publish RFC 9728 metadata, clients use PKCE and resource indicators, and tokens travel in the Authorization header on every request 1. Prefer it over static keys whenever people connect assistants to shared business data.

Sources

  1. Authorization (specification, version 2026-07-28), Model Context Protocol
  2. Authorization server discovery (specification, version 2026-07-28), Model Context Protocol
  3. Authorization security considerations (specification, version 2026-07-28), Model Context Protocol
  4. RichAPI MCP server, RichAPI

More terms