OAuth 2.1 is not always worth it for an MCP server. This lesson helps you decide when MCP authorization should use OAuth 2.1 and when a custom mechanism (environment credentials, a static token or API key, or mTLS) is the better fit, depending on transport, who the clients are and whether users need their own permissions.
In this lesson
Decide between OAuth 2.1 and a custom mechanism for a given MCP deployment
Explain why stdio servers fall outside the authorization spec
Recognize the scenarios where OAuth 2.1 is the only practical option
Decision assistant
Answer a few questions about your deployment and the assistant suggests a mechanism. The logic behind it is simple:
How does the client connect? A local process over stdio → credentials from the environment. Over HTTP → keep going.
Who will use the server? Only you, on your machine (localhost) → no auth or a static token. A small set of clients you control → keep going. Clients or users you don't control (public or multi-user) → OAuth 2.1.
Are there different users who need different or revocable permissions? Yes → OAuth 2.1. No, it is a service or integration → keep going.
Do you have certificate infrastructure (PKI) between services? Yes → mTLS (or client credentials). No → API key / static Bearer.
For OAuth 2.1: is there a human who approves access? Yes → authorization code + PKCE. No, it is a machine → client credentials.
Interactive exercise: it loads in your browser.
What each recommendation means in practice:
Credentials from the environment. The authorization spec does not apply to stdio. Pass secrets through environment variables or protected configuration files (see lesson 4.1).
No auth or a static token. Valid under the spec. Listen only on 127.0.0.1 and consider a static token if other local apps could call the server (see lesson 4.3).
API key / static Bearer. Simple and acceptable if you control the clients. Make it rotatable, keep it in a secrets manager, and remember it is outside the standard: configuration is manual (see lessons 1.3 and 4.3).
mTLS (or client credentials). Strong identity between services without secrets in headers. If you already have an authorization server, client credentials with private_key_jwt is a standard alternative (see lesson 2.6).
OAuth 2.1 with authorization code + PKCE. The standard path that any MCP client knows how to complete. Use an existing authorization server and follow the server checklist in lesson 6.2.
OAuth 2.1 with client credentials. For machines without a user and confidential clients. Tokens with resource and a short lifetime.
Scenarios at a glance
Scenario
Recommendation
Why
Local server over stdio
Credentials from the environment
The authorization spec does not apply to stdio
HTTP server on localhost, just for you
No auth or a static token
No third parties; still, watch out for other local apps
Internal, one known client, no distinct users
API key / static Bearer (rotatable)
Simplicity; manual configuration is acceptable
Service to service with PKI
mTLS (or client credentials)
Strong identity without secrets in headers
Distinct users, per-user permissions
OAuth 2.1
Delegation, scopes, revocation
Public server for clients you don't control
OAuth 2.1
The only path standard clients can discover
Summary
A custom mechanism is valid when you control the clients and there is no delegation.
OAuth 2.1 is the choice when there are unknown clients, distinct users or you need narrowly scoped permissions.
stdio servers take credentials from the environment; the MCP authorization spec does not apply to them.
quiz · 3 questions
1. You are going to publish an MCP server for clients such as Claude Desktop or Cursor to use with no manual steps. What do you choose?
With any other option, every user would have to configure the credential by hand in every client. OAuth 2.1 with discovery is the only path standard clients can follow on their own.
2. Your MCP server runs as a local process launched over stdio. How should it get its credentials?
The MCP authorization spec does not apply to the stdio transport; secrets are passed through the environment.
3. Two internal services with an existing PKI need to talk to each other, with no end users involved. What fits best?
mTLS gives strong service identity without secrets in headers; client credentials is the standard OAuth alternative for machine-to-machine access.