What you will be able to do
- Decide whether an MCP connection should use OAuth or environment credentials, based on its transport
- Trace how an MCP client finds the authorization server and registers itself, and spot where that flow can be abused
- Find token audience gaps, such as tokens accepted for the wrong server or passed straight through to downstream APIs
- Tell a 401 from a 403 and design step-up authorization so scopes stay narrow
Key concept
Audience-bound access token — An MCP access token is issued for one specific MCP server, named by its canonical URI. That server must reject any token issued for another server, and it must never pass a token it received on to a different service.
1.The transport decides how an MCP server authenticates
Reviewing authentication for an MCP integration starts with one question: how does the client reach the server? A server reached over HTTP is a network service. Anyone who can reach its URL can send it requests, so it needs real authorization, and the MCP authorization specification is built on OAuth 2.1. A server launched locally over STDIO is a child process of the client. It has no network listener to protect, and the specification tells it to skip OAuth and retrieve credentials from the environment.
Each transport has its own typical gap. An HTTP server that accepts requests with no token, or with a static key everyone shares, has skipped the OAuth flow the specification expects of it. A STDIO server that tries to run browser-based OAuth is overbuilt. The real risk there is the environment itself: any secret it reads from an environment variable is visible to everything else running in that environment. The remaining sections apply to the HTTP case.
| Transport | Expected mechanism | Gap to look for |
|---|---|---|
| HTTP-based | OAuth 2.1 per the MCP authorization spec | Server reachable without a token, or with one shared static key |
| STDIO | Credentials retrieved from the environment | Secrets in the environment that other processes can also read |
| Alternative transports | Established security best practices for that protocol | No defined mechanism at all |
Checkpoint 1 of 6· Match them up
You are reviewing how an MCP integration authenticates. Match each transport to the authorization mechanism the MCP specification expects it to use.
Tap a term, then the definition that fits it.
Anyone who can reach an HTTP server's URL can send it requests, so it needs OAuth 2.1. A STDIO server is a local child process with no network listener, so it reads its credentials from the environment. Other transports are not covered by the spec and must follow their own protocol's best practices.
“Implementations using an STDIO transport SHOULD NOT follow this specification, and instead retrieve credentials from the environment.”Source: modelcontextprotocol.io
Sources1
2.How a client discovers the authorization server
The client does not need to know in advance where to get a token. Discovery begins with an unauthenticated request. The MCP server replies 401 Unauthorized with a WWW-Authenticate header, and that header carries a resource_metadata URL pointing to the server's OAuth 2.0 Protected Resource Metadata document. Every MCP server must publish this document, and clients must use it to find the authorization server. It can be served at a well-known URI, either at the root (/.well-known/oauth-protected-resource) or with the MCP endpoint's path appended.
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
scope="files:read"Next, the client fetches the authorization server's own metadata. The authorization server must offer at least one of OAuth 2.0 Authorization Server Metadata (/.well-known/oauth-authorization-server) or OpenID Connect Discovery (/.well-known/openid-configuration), and the client must support both. If the metadata has no code_challenge_methods_supported field, the client must stop. A missing field means the server does not support PKCE, and the client must not proceed without it.
These are the transport rules to check in an audit. Every authorization server endpoint must be served over HTTPS. Every redirect URI must be either localhost or HTTPS. A client that continues after any of these checks fails has an authentication gap, even if every token it later receives is valid.
Checkpoint 2 of 6· Check yourself
An audit log shows an MCP client receive a 401, follow the resource_metadata URL, and fetch the authorization server's metadata over HTTPS. That metadata has no code_challenge_methods_supported field. The client completes the authorization flow anyway and gets a valid token. What should the audit report?
If code_challenge_methods_supported is absent, the authorization server does not support PKCE, and the client must stop. A client that carries on has an authentication gap even if the token it gets is valid. Protected Resource Metadata is the required way to discover the authorization server, so skipping it is not the fix.
“If code_challenge_methods_supported is absent, the authorization server does not support PKCE and MCP clients MUST refuse to proceed.”Source: modelcontextprotocol.io
3.Registering a client the server has never seen
Before a client can request tokens, the authorization server has to know who that client is. The specification sets an order of preference:
- Use pre-registered client information, if the client and server already have a relationship.
- Use a Client ID Metadata Document, if the authorization server advertises
client_id_metadata_document_supported. This is the usual case when the two have no prior relationship. - Fall back to Dynamic Client Registration, if the server publishes a
registration_endpoint. - Otherwise, ask the user to enter client details.
With a Client ID Metadata Document, the client's client_id is itself an HTTPS URL with a path component. The JSON hosted at that URL must include client_id, client_name and redirect_uris, and its client_id must match the document URL exactly. The authorization server fetches the document and must check the redirect URI in each authorization request against the list in the document. Dynamic Client Registration now remains only for backwards compatibility: the specification calls it deprecated and keeps it for authorization servers that do not support metadata documents.
{
"client_id": "https://app.example.com/oauth/client-metadata.json",
"client_name": "Example MCP Client",
"client_uri": "https://app.example.com",
"logo_uri": "https://app.example.com/logo.png",
"redirect_uris": [
"http://127.0.0.1:3000/callback",
"http://localhost:3000/callback"
],
"grant_types": ["authorization_code"],
"response_types": ["code"],
"token_endpoint_auth_method": "none"
}Localhost redirects open the main impersonation path. An attacker can present the legitimate client's metadata URL as their own client_id and bind to a localhost port listed in its redirect URIs. When the user approves, the attacker's listener receives the authorization code. The specification responds on the consent screen. Authorization servers must clearly display the redirect URI hostname, should add warnings for localhost-only redirect URIs, and may require additional attestation. Servers that protect sensitive resources can also restrict which client domains they accept, using trusted-domain allowlists or reputation checks.
Checkpoint 3 of 6· Check yourself
Your MCP client connects to an authorization server for the first time and has no pre-registered credentials for it. The server's metadata advertises both client_id_metadata_document_supported and a registration_endpoint. How should the client identify itself?
With no pre-registration, the client should use a Client ID Metadata Document when the server supports one. Dynamic Client Registration is deprecated and is only a fallback for servers without metadata-document support. Asking the user is the last resort, for when no other option is available.
“Note that Dynamic Client Registration is deprecated and retained for backwards compatibility with authorization servers that do not support Client ID Metadata Documents.”Source: modelcontextprotocol.io
4.Binding tokens to one server, and never passing them on
Every token request names the server the token is for. The client sends a resource parameter in both the authorization request and the token request. The value must be the MCP server's canonical URI, which identifies the server the client intends to use the token with. That URI includes a scheme and has no fragment. For consistency, the specification prefers the form without a trailing slash.
| Value | Valid? | Reason |
|---|---|---|
| https://mcp.example.com/mcp | Yes | Scheme, host and path |
| https://mcp.example.com:8443 | Yes | A port is allowed |
| https://mcp.example.com/server/mcp | Yes | A path is used when it is needed to identify one server |
| mcp.example.com | No | Missing scheme |
| https://mcp.example.com#fragment | No | Contains a fragment |
Tokens must also travel in the right place. The client sends the token in the Authorization: Bearer <access-token> header and must never put it in the URI query string. Query strings end up in logs and browser history. Refresh tokens must be kept confidential both in transit and in storage. Clients must not assume a refresh token will be issued at all, because the authorization server decides that.
Audience binding fails in two ways. In the first, the server skips audience validation and so accepts tokens issued for other services. An attacker can then reuse a legitimate token against a service it was never meant for. The second, token passthrough, is worse: the server also forwards those unmodified tokens to downstream APIs. That creates a confused deputy. The downstream API may treat the token as if it came from the MCP server, or assume the upstream API already validated it. A safe server validates the audience of every incoming token and calls downstream services with a token issued for that call.
Checkpoint 4 of 6· Check yourself
A team's MCP server takes the bearer token each user sends it and attaches that same token, unchanged, to its calls to an internal billing API. Both services trust the same authorization server. What is the finding, and what fixes it?
Passing an unmodified token on to a downstream API is token passthrough. The API may trust the token as if it came from the MCP server, which is the confused deputy problem. Tokens are bound to one server's canonical URI, so the MCP server must check the audience of every token it receives and use its own token for the downstream call. A longer lifetime or a shared issuer does not fix this.
“forwards these unmodified tokens to downstream services, it can potentially cause the “confused deputy” problem”Source: modelcontextprotocol.io
5.401 versus 403, and asking for more scope only when needed
Each of these status codes calls for a different response from the client. A 401 means authorization is required or the token is invalid, so the client has to authenticate. A 403 means the token is valid but its scopes are insufficient. Signing in again with the same scopes will fail again. The client needs a token with more scope.
| Status | Meaning | Client response |
|---|---|---|
| 401 Unauthorized | Authorization required or token invalid | Run discovery and obtain a token |
| 403 Forbidden | Invalid scopes or insufficient permissions | Read the insufficient_scope challenge and step up |
| 400 Bad Request | Malformed authorization request | Fix the request; do not re-authorize |
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
scope="files:write",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
error_description="File write permission required for this operation"Step-up authorization lets a client start with a narrow grant and add scope only when an operation needs it. When a 403 challenge arrives, the client re-authorizes with the union of the scopes it already requested and the scopes named in the challenge, so permissions it already has are not lost. It then retries the original request. If the retry fails more than a few times, the client must treat it as a permanent authorization failure and stop looping.
The initial request is where over-broad scopes usually come from. The client uses the scope hint from the first 401, if the server sent one. If there is no hint, it requests every scope listed in scopes_supported. A server that never sends a scope hint therefore gets tokens carrying its full scope set on first contact. In an audit, look for servers whose 401 responses omit scope, and for tokens that already hold write scopes before any write has been attempted.
Both files:read and files:write: the union of the scopes it already requested and the scopes in the challenge. Requesting only files:write would drop the read permission it already had.
Checkpoint 5 of 6· Fill the gap
A client holds a valid token for this MCP server and tries a write operation, but the token lacks the needed scope. Which error value completes the server's response so the client knows to step up rather than sign in again?
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error=" ? ",
scope="files:write",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
error_description="File write permission required for this operation"A 403 with error="insufficient_scope" means the token is valid but lacks the scopes for this operation. The client then re-authorizes with the union of its existing scopes and the scope in the challenge. Signing in again with the same scopes would fail again.
Source: modelcontextprotocol.ioCheckpoint 6 of 6· Check yourself
Tokens issued to a newly connected MCP client already carry files:write, although the client has only read files so far. The server's 401 responses include resource_metadata but no scope parameter. What is the most likely cause?
For its first request, a client uses the scope hint from the 401 if there is one. Without a hint, it requests every scope in scopes_supported. A server that never sends a scope hint therefore gets tokens with its full scope set on first contact.
“If scope is not available, use all scopes defined in scopes_supported from the Protected Resource Metadata document”Source: modelcontextprotocol.io
Sources1
Sources
(3)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Implementations using an STDIO transport SHOULD NOT follow this specification, and instead retrieve credentials from the environment.”
↩︎ The transport decides how an MCP server authenticates“Implementations using an HTTP-based transport SHOULD conform to this specification.”
↩︎ The transport decides how an MCP server authenticates“Note that Dynamic Client Registration is deprecated and retained for backwards compatibility with authorization servers that do not support Client ID Metadata Documents.”
↩︎ Registering a client the server has never seen“MUST identify the MCP server that the client intends to use the token with.”
↩︎ Binding tokens to one server, and never passing them on“Access tokens MUST NOT be included in the URI query string”
↩︎ Binding tokens to one server, and never passing them on“Determine required scopes by computing the union of the client’s previously requested scope set and the scopes from the current challenge.”
↩︎ 401 versus 403, and asking for more scope only when needed“If scope is not available, use all scopes defined in scopes_supported from the Protected Resource Metadata document”
↩︎ 401 versus 403, and asking for more scope only when needed“Retry the original request with the new authorization no more than a few times and treat this as a permanent authorization failure”
↩︎ 401 versus 403, and asking for more scope only when needed“Invalid scopes or insufficient permissions”
↩︎ Exam trap 1 - 2.
“MCP clients MUST use OAuth 2.0 Protected Resource Metadata for authorization server discovery.”
↩︎ How a client discovers the authorization server“Use Dynamic Client Registration as a fallback if the Authorization Server supports it”
↩︎ Registering a client the server has never seen“Binding to any localhost port, and providing that address as the redirect_uri”
↩︎ Registering a client the server has never seen“MUST clearly display the redirect URI hostname during authorization”
↩︎ Registering a client the server has never seen“the downstream API may incorrectly trust the token as if it came from the MCP server”
↩︎ Binding tokens to one server, and never passing them on“it may accept tokens originally issued for other services”
↩︎ Exam trap 2“MCP servers MUST validate that tokens presented to them were specifically issued for their use”
↩︎ Prediction“forwards these unmodified tokens to downstream services, it can potentially cause the “confused deputy” problem”
↩︎ Checkpoint - 3.https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerationsOfficial docs
“If code_challenge_methods_supported is absent, the authorization server does not support PKCE and MCP clients MUST refuse to proceed.”
↩︎ How a client discovers the authorization server“All redirect URIs MUST be either localhost or use HTTPS.”
↩︎ How a client discovers the authorization server“MCP servers MUST validate that tokens presented to them were specifically issued for their use”
↩︎ Key concept