Lesson 07.07 · Phase 07 · Model Context Protocol
Auth for remote servers
A remote MCP server is an OAuth 2.1 resource server. It tells clients where to get a token, accepts only tokens minted for it, asks for more scope when an operation needs it, and never hands a user's token to anyone else. Each of those rules closes a specific attack.
Learning objectives
- Implement the discovery chain: 401 with WWW-Authenticate, Protected Resource Metadata (RFC 9728), then authorization server metadata (RFC 8414).
- Run the authorization code flow with PKCE (S256), the resource parameter (RFC 8707), state and iss checks, and a Client ID Metadata Document as the client id.
- Validate tokens on the server: signature, issuer, expiry, and audience, with the token only accepted from the Authorization header.
- Handle insufficientscope with step-up authorization, and explain why token passthrough is forbidden.
The Lesson 6 server answered anyone who could reach it. That's fine on localhost and wrong for a server holding a user's notes, email or company data. A remote server needs to know who's calling and what they're allowed to do.
Loading the full lesson…