CrabTalk
Blog

Remote MCP server authentication: OAuth vs API keys, and what each client supports

How remote MCP server auth works in the 2026-07-28 spec: the 401 challenge, OAuth discovery, client registration, and where an API key header still works.

CrabTalk Team

A remote MCP server authenticates its callers in one of two ways: an API key the client sends in a header, or OAuth, where the client discovers the server's authorization server and signs the user in. The MCP specification defines only the second. "A protected MCP server acts as an OAuth 2.1 resource server" (authorization, 2026-07-28), and the client that connects decides whether an API key is an option at all. This post walks through the OAuth flow step by step, what changed in the 2026-07-28 revision, and which clients take which method.

API key or OAuth

API key header OAuth
Setup Paste a key into the client's config Paste the server URL, sign in in a browser
Defined by MCP No Yes
Who holds the secret The person who pasted it The client, issued after sign-in
Works in ChatGPT No Yes
Works in scripts and CI Yes Only with a stored token

Local servers that run over stdio are outside both: "Implementations using an STDIO transport SHOULD NOT follow this specification, and instead retrieve credentials from the environment."

How MCP OAuth works, step by step

1. The client finds the server's metadata. A request without a token gets 401. The client then locates the server's Protected Resource Metadata (RFC 9728) one of two ways: a resource_metadata URL in the WWW-Authenticate header, or a well-known URI it falls back to when the header names none.

HTTP/2 401
www-authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource"

A 401 here is the start of discovery, not a verdict on the client's connection.

2. The client reads the metadata. The protected-resource document lists the server's authorization_servers. The client then fetches the authorization server's own metadata, through RFC 8414 or OpenID Connect discovery (authorization server discovery), for its endpoints and supported methods.

3. The client gets a client ID. The client registration page gives an order for clients that support every option:

  1. Client information registered in advance.
  2. A Client ID Metadata Document, if the authorization server advertises support: the client's ID is an HTTPS URL that serves its metadata.
  3. Dynamic Client Registration (RFC 7591), if the server advertises a registration_endpoint.
  4. "Prompt the user to enter the client information if no other option is available."

4. The user signs in, with PKCE. Clients "MUST use the S256 code challenge method when technically capable", and if the server's metadata lists no code_challenge_methods_supported, they "MUST refuse to proceed" (security considerations).

5. The token names its server. Clients "MUST implement Resource Indicators for OAuth 2.0" (RFC 8707), sending a resource parameter in both the authorization and token requests. The server checks that the token was issued for it, and "MUST NOT pass through the token it received from the MCP client" to anything upstream.

What changed in 2026-07-28

The changelog changes four things about authorization:

  • Dynamic Client Registration is deprecated in favour of Client ID Metadata Documents. It stays for backward compatibility.
  • Clients send application_type when they register dynamically.
  • Issuer validation. Authorization servers should return iss (RFC 9207), and when they do, clients must check it against the issuer they recorded. A client rejects a response without iss from a server that advertised it sends one.
  • Credentials belong to one authorization server. If it changes, the client registers again.

What each client supports

Client API key header OAuth
Claude Code --header "Authorization: Bearer …" Yes, stored per endpoint
Cursor headers in mcp.json Yes, with PKCE; a public client when it registers dynamically
ChatGPT No Yes, for tools that act as the user; public tools can be anonymous

ChatGPT "does not support machine-to-machine OAuth grants such as client credentials", "nor can it present custom API keys". A server whose ChatGPT tools act as the signed-in user has to run OAuth. Cursor also takes static OAuth client credentials in mcp.json in place of dynamic registration.

Support both

A server that serves both agents in chat apps and scripts takes both: OAuth for clients that sign people in, and API keys for everything else. The two only stay manageable if they end in the same thing. If sign-in issues a token with its own rules while keys carry another set, every permission is written twice.

How CrabTalk authenticates MCP clients

https://mcp.crabtalk.ai takes both, and both end in an API key.

  • API key header. claude mcp add --transport http crabtalk https://mcp.crabtalk.ai --header "Authorization: Bearer ck_…", or headers in a JSON config.
  • OAuth. The server answers 401 with its resource metadata, offers dynamic registration and requires S256 PKCE. Sign-in opens an approval page that shows the client's name, the account, its permissions and a daily budget, and approving it issues a dedicated API key for that connection.

A key made by OAuth is managed like any other: its permissions, priced-service grants, daily budget and revocation sit in one list under Settings → Access → API Keys.