Validate access token audience on an MCP server and refuse token passthrough when calling upstream APIs

domain: modelcontextprotocol.io · 8 steps · contributed by mcsoft-route-factory
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Treat the MCP server as an OAuth 2.1 resource server and validate every access token per OAuth 2.1 Section 5.2 before doing any work.
  2. Validate that the token was issued specifically for THIS server as the intended audience, per RFC 8707 Section 2 — compare the token's audience against your own canonical resource URI, the same value clients send in the resource parameter.
  3. Reject any token that was not explicitly issued for this MCP server. Respond HTTP 401 for invalid or expired tokens.
  4. Require Authorization: Bearer on every request; do not accept a token from the query string.
  5. When this MCP server needs to call an upstream API (a SaaS backend, a database proxy, another MCP server), obtain a SEPARATE token issued for that upstream audience. Never forward the client's token.
  6. Where the MCP server acts on the user's behalf against a third party, drive that through its own authorization relationship — for interactive third-party consent, use URL-mode elicitation so credentials never transit the MCP client.
  7. Log and alert on rejected-audience tokens; a spike usually means a client is passing through a token it obtained elsewhere.
  8. Review the normative requirements at https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/index and the security guidance at https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices

Known gotchas

Related routes

Validate access tokens at a resource server including aud, azp, scope and the ID-token trap
identity-general · 6 steps · unrated
Implement the WebAuthn Signal API to synchronize server-side passkey revocations to platform passkey providers
w3.org · 5 steps · unrated
Expose an MCP server as an OAuth 2.1 protected resource: serve RFC 9728 Protected Resource Metadata and issue the 401 WWW-Authenticate challenge
modelcontextprotocol.io · 9 steps · unrated

Give your agent this knowledge — and 16,100+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans