CertSafari
    Anthropic Claude Certified Architect – Professional (CCAR-P)· Lessons

    Domain 3 · Lesson 13/38

    MCP authorization: discovery, client registration and scoped tokens

    Analyze authentication and authorization requirements to identify security gaps

    13 min read
    2.38% of exam
    3 sources
    Published 19 Oct 2026
    Docs as of 30 Sep 2026

    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.

    Which authorization mechanism each MCP transport should use
    TransportExpected mechanismGap to look for
    HTTP-basedOAuth 2.1 per the MCP authorization specServer reachable without a token, or with one shared static key
    STDIOCredentials retrieved from the environmentSecrets in the environment that other processes can also read
    Alternative transportsEstablished security best practices for that protocolNo 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.

    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.

    The 401 challenge that starts discovery: a pointer to the metadata document plus a scope hinthttp
    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?

    Sources23

    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:

    1. Use pre-registered client information, if the client and server already have a relationship.
    2. 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.
    3. Fall back to Dynamic Client Registration, if the server publishes a registration_endpoint.
    4. 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.

    A Client ID Metadata Document: the client_id is the URL the document is served fromjson
    {
      "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?

    Sources21

    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.

    Canonical server URIs for the resource parameter
    ValueValid?Reason
    https://mcp.example.com/mcpYesScheme, host and path
    https://mcp.example.com:8443YesA port is allowed
    https://mcp.example.com/server/mcpYesA path is used when it is needed to identify one server
    mcp.example.comNoMissing scheme
    https://mcp.example.com#fragmentNoContains 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?

    Sources12

    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.

    How an MCP client should read authorization errors
    StatusMeaningClient response
    401 UnauthorizedAuthorization required or token invalidRun discovery and obtain a token
    403 ForbiddenInvalid scopes or insufficient permissionsRead the insufficient_scope challenge and step up
    400 Bad RequestMalformed authorization requestFix the request; do not re-authorize
    A step-up challenge: the 403 names the missing scope for this operationhttp
    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.

    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"

    Checkpoint 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?

    Sources1

    Sources

    (3)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 3.
      “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

    Continue to part 2 of 2

    Who the agent acts as: per-user credentials and permission layers

    Spotted a mistake, or was something unclear? Tell us.