Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 7 of 16

Authorisation & security

0 of 16 complete

Covers MCP 2026-07-28 authorisation · last verified 2026-11-17

Why it matters

An MCP connection is an unusual authorisation shape. A user is not calling the server directly: a host application, sometimes a third-party proxy, is calling on the user's behalf, with tools chosen by a model. Three parties need to agree on identity, and the party making the request is not the party that consented.

The specification's answer is to reuse OAuth rather than invent a scheme. On HTTP transports, the MCP server acts as an OAuth 2.1 resource server, the client acts as an OAuth client, and a separate authorisation server issues tokens. stdio servers are out of scope: they run as local processes and should read credentials from the environment instead.

That choice imports OAuth's known failure modes — audience confusion, token theft, redirect manipulation — into a setting where the client is often a desktop app and the resource is often a proxy for a fourth system.

Mental model

A building pass. The pass names the building it opens, the floors it reaches, and the person it was issued to. A guard at each door checks the pass against that door, not against the visitor's story.

The analogy breaks on bearer semantics and on delegation. A physical pass is checked by someone who can also look at you; an OAuth access token is a bearer credential — whoever holds it is treated as the subject. And the MCP server is frequently a deputy: it holds one credential to a downstream system while serving many users, which is exactly where confused-deputy attacks live.

How it works

Token chain: client → MCP server → downstream APIInteractive
no token passthrough
Step 1/6 · delegation
  1. untrusted · user + client
    delegationuntrusted
    User consents · files:read
    Bearer aud = server
  2. neutral · MCP server
    resource serverneutral
    Validates signature, aud, scope
    scope covers it
  3. tool callneutral
    Tool call · files.read
    returns
  4. untrusted contentneutral
    Tool output · text
    read as text
  5. untrusted · user + client
    contextuntrusted
    Model reads the result
  6. trusted · downstream API
    Tool call · files.read· forwards the client tokenno token passthrough · open
    Validates signature, aud, scope· own credentialno token passthrough · open
    downstreamtrusted
    Files API · own audience
trusted pathtainted pathcontrol openboundary holdspassespending approvaltrusted zoneuntrusted zoneneutral zone3 zones · 6 nodes · illustrative geometry

delegation. The user consents to a scope, and the client obtains a token whose resource is this MCP server. The party calling is not the party that consented.

Figure. The boundary is a refusal to pass the client's token through. Audience validation in the server node is always on and is not a control state; the drawn gate is the downstream passthrough. Blocked, the server uses its own downstream credential. It does not make tool output trustworthy, drawn as a separate path back to the model, and it does not replace per-call approval. Shown with passthrough open.

What to notice. Residual risk: an access token is a bearer credential, so a stolen one is replayable until expiry. Discovery SSRF, a confused deputy at a proxy, state-handle hijacking and scope step-up are not drawn.

Text version

Three zones: UNTRUSTED · USER + CLIENT holds the consent to files:read and the model that reads the result; NEUTRAL · MCP SERVER holds the resource server that validates signature, audience and scope, the files.read tool call, and the returned tool output text; TRUSTED · DOWNSTREAM API holds the Files API with its own audience. A solid path carries the bearer token from consent to the server, and a solid path runs from the check to the tool call as the scope covers it. Two paths reach the API: a solid one labelled own credential from the validation node, and a dashed red one labelled forwards the client token from the tool call. Both are under the no-token-passthrough control, while audience validation stays always on in the server node: open, the client token is replayed downstream; blocked, the passthrough is cut at a teal bar and the own-credential path passes with a teal tick. Separately, the tool result returns to the tool output and then to the model as a dashed red path, and is not affected by the passthrough gate.

  1. Unauthenticated request. The client calls the server without a token. The server replies 401 with a WWW-Authenticate: Bearer challenge containing resource_metadata and, ideally, the scope required for the operation.
  2. Resource metadata. The client fetches the protected resource metadata document (RFC 9728). It lists the authorization servers for this resource and the scopes the resource understands.
  3. Authorisation server discovery. The client reads the authorisation server's metadata via OAuth 2.0 metadata (RFC 8414) or OpenID Connect discovery, and records the issuer.
  4. Client registration. The client obtains a client ID by one of three routes: a Client ID Metadata Document (an HTTPS URL that identifies the client), pre-registration, or dynamic client registration. Dynamic registration is deprecated in the current revision and retained for older authorisation servers.
  5. Authorisation request. The client generates PKCE parameters, includes the resource parameter (RFC 8707) naming the MCP server, requests the narrowest scope set it can justify, and records the expected issuer alongside the PKCE verifier.
  6. Callback validation. The user approves. The client checks the iss parameter in the response against the issuer it recorded, then exchanges the code with the same resource value.
  7. Every request carries the token. Authorization: Bearer <token> on each HTTP request; never in a query string. The server validates signature, expiry, audience and scope before doing any work.
  8. Step-up on insufficient scope. A 403 with error="insufficient_scope" and a scope parameter tells the client which additional scopes the operation needs. The client re-authorises with the union of previously granted and newly challenged scopes, retries a bounded number of times, then treats it as a permanent failure.
POST /mcp HTTP/1.1
Host: mcp.example.com
Authorization: Bearer <access-token>
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/list

Designing scopes

Scopes should map to operations, not to the server as a whole. files:read and files:write give a host something to request narrowly and a user something to understand; files:* gives neither. Advertise a minimal scopes_supported set, challenge for more when an operation needs it, and log every elevation with a correlation ID.

Two design rules follow. First, emit the complete scope set required by an operation in a single challenge rather than one scope at a time — incremental challenges multiply round trips and consent prompts. Second, treat scope hierarchies explicitly: if admin implies read, the server must decide sufficiency with that in mind, while clients can keep accumulating the union.

Trade-offs

ApproachGood forCostFails when
No auth, stdio onlyLocal developer toolsRuns with the user's own privilegesThe server listens on a socket or is proxied
Static API keyInternal single-tenant servicesNo user identity, no scopes, hard to revokeMultiple users share the key
OAuth per userSaaS integrations on a user's behalfToken storage, refresh, consent UXClient registration is skipped or redirect URIs are loose
OAuth proxy with one static upstream clientBridging to APIs without dynamic registrationPer-client consent becomes mandatoryThe proxy relies on a third-party consent cookie
Trade-off mapInteractive

Good for

Local developer tools

Cost

Runs with the user's own privileges

Fails when

The server listens on a socket or is proxied

  1. The server listens on a socket or is proxied
  2. Multiple users share the key
  3. Client registration is skipped or redirect URIs are loose
  4. The proxy relies on a third-party consent cookie

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: No auth, stdio only is good for Local developer tools, costs Runs with the user's own privileges, and fails when The server listens on a socket or is proxied. Static API key is good for Internal single-tenant services, costs No user identity, no scopes, hard to revoke, and fails when Multiple users share the key. OAuth per user is good for SaaS integrations on a user's behalf, costs Token storage, refresh, consent UX, and fails when Client registration is skipped or redirect URIs are loose. OAuth proxy with one static upstream client is good for Bridging to APIs without dynamic registration, costs Per-client consent becomes mandatory, and fails when The proxy relies on a third-party consent cookie

Failure modes

  • Token passthrough. The server forwards the client's token downstream. Debug: inspecting outbound requests for an Authorization header that matches an inbound one; they should never be the same credential.
  • Missing audience check. Any valid token is accepted, so a token for another service works here. Debug: minting a token for a different resource and asserting a 401; if it succeeds, validation is incomplete.
  • Confused deputy at a proxy. A proxy uses one static client ID upstream and skips per-client consent, so an attacker's dynamically registered client inherits a consent cookie. Debug: registering a second client and confirming a fresh consent screen appears for it.
  • SSRF through discovery. A malicious server returns a resource_metadata URL pointing at an internal address or a cloud metadata endpoint, and the client fetches it. Debug: routing all discovery fetches through an egress policy that blocks private ranges, and by logging every outbound discovery URL.
  • State handle hijacking. A server mints a cart or task ID and treats possession as identity. Debug: presenting a valid handle under a different authenticated principal and asserting a rejection.

In production

Store tokens per user and per server, encrypted, and never in a shared cache keyed only by server URL. Refresh proactively, and treat refresh failure as a re-authorisation event rather than a retry storm. Revocation has to reach the server: a token that stays valid after a user disconnects is a support incident waiting to happen.

Put every HTTP MCP client behind an egress policy. Discovery fetches, redirects and token endpoints are all attacker-influenced URLs in the threat model; block private ranges, require HTTPS outside loopback, and do not follow redirects blindly.

Local servers need their own controls. A one-click install that runs npx something executes arbitrary code with the user's privileges; the host must show the exact command, require explicit consent, and sandbox where the platform allows. Prefer stdio over a local HTTP port, which any process on the machine can reach.

Finally, log authorization decisions, not tokens. Record subject, server, tool, scope used, and whether a human approved — enough to reconstruct an incident without creating a credential leak in the log store.

Common misconceptions

People think: MCP defines its own authentication scheme.

Actually: It profiles OAuth 2.1 for HTTP transports and adds discovery requirements. There is no MCP-specific token format; the tokens are ordinary OAuth access tokens with a resource audience.

People think: A valid token means the action is allowed.

Actually: A token proves the user delegated a scope to a client. Whether this particular tool call is acceptable is still a host policy decision, and high-impact actions deserve per-call approval.

People think: Tool results are safe because they come from an authorised server.

Actually: Authorisation covers the caller, not the content. A compromised or merely untrusted server can return text that tries to redirect the model; treat it as untrusted input.

Interview angle

"Design authorisation for an MCP deployment that serves many users through one host." Strong answers separate the three roles, walk the discovery and token flow, insist on audience binding and no passthrough, and design scopes that can be stepped up. Then they name the attacks they would test for: confused deputy at a proxy, SSRF during discovery, handle hijacking, and prompt injection through tool output. See untrusted input and the security interview category.

Sources