Agents, Tool Use & MCP·Question 65 of 90Advanced

How does authorisation work for a remote MCP server, and what do teams get wrong when they implement it?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

A remote MCP server is an OAuth 2.1 resource server. The client discovers who issues tokens, obtains one scoped to this specific server on behalf of this specific user, and presents it on every request. The server validates it and never forwards it anywhere. stdio servers sit outside this model and take credentials from their environment.

Full worked answer with diagram

A remote MCP server is an OAuth 2.1 resource server. The client discovers who issues tokens, obtains one scoped to this specific server on behalf of this specific user, and presents it on every request. The server validates it and never forwards it anywhere. stdio servers sit outside this model and take credentials from their environment.

The flow:

  1. The client calls without a token and gets a 401 whose WWW-Authenticate header points to Protected Resource Metadata (RFC 9728), which names the authorisation server.
  2. The client reads that server's metadata, identifies itself (pre-registration, a client ID metadata document, or dynamic registration as a fallback), and runs authorization code with PKCE in the user's browser.
  3. The token request carries a resource parameter (RFC 8707) naming the MCP server, binding the token's audience to it.
  4. The server checks signature, expiry, scopes and audience on every request.

What teams get wrong:

  • Token passthrough. The server forwards the user's token to GitHub or an internal API. The spec forbids it: upstream calls use a token the server obtains for that upstream, or audience checks, rate limits and audit trails all break.
  • Skipping the audience check. Accepting any valid token from your identity provider means a token minted for a low-risk server unlocks a high-risk one.
  • One shared service credential. A remote server holding a single API key for every user is a confused deputy: a prompt-injected session for user A reaches whatever the key reaches. Per-user tokens make the downstream system enforce authorisation for you.
  • Static client IDs at proxies. A server proxying to a third-party OAuth provider under one static client ID can let an earlier consent be replayed for a malicious client. Require per-client consent at the proxy.
  • Scopes as an afterthought. Request the minimum and step up when a write tool is first needed.

Worth naming: the Enterprise-Managed Authorization extension (Stable) moves this decision to the identity provider. The client exchanges the user's SSO identity assertion for an ID-JAG (Identity Assertion JWT Authorization Grant, an IETF OAuth working group draft) at the enterprise IdP, which applies policy. The client then redeems the ID-JAG at the MCP server's authorisation server, so the IdP decides which users may reach which servers instead of each user consenting per server.

Worth sketching. The audience binding and the separate upstream token are the two arrows people leave out.

sequenceDiagram
    participant C as MCP client
    participant S as MCP server
    participant A as Auth server
    participant U as Upstream API
    C->>S: tools/call, no token
    S->>C: 401 with resource metadata URL
    C->>A: auth code + PKCE, resource = server URL
    A->>C: token, audience = this server
    C->>S: tools/call with bearer token
    S->>S: check signature, expiry, scope, audience
    S->>U: its own upstream token, never the client's

What a good answer covers

  • A remote MCP server is an OAuth 2.1 resource server
  • The client discovers who issues tokens, obtains one scoped to this specific server on behalf of this…
  • The server validates it and never forwards it anywhere
  • The client calls without a token and gets a 401 whose WWW-Authenticate header points to Protected…
  • The client reads that server's metadata, identifies itself (pre-registration, a client ID metadata…

Key terms: Token passthrough · Skipping the audience check · One shared service credential · Static client IDs at proxies · Scopes as an afterthought

Interviewer follow-ups to expect

  1. Your MCP server needs to call three upstream SaaS APIs for the user. How do you obtain and store those tokens?

  2. An agent runs unattended overnight and a token expires mid-run. What happens?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep