MCP authorization, from the first 401 to the Bearer token.
MCP Authorization. OAuth 2.1 for the Model Context Protocol, from the first 401 to the 2026-07-28 spec. How an MCP client that has never seen your server ends up with a short-lived, scoped token bound to it: OAuth 2.1 from scratch, the RFCs MCP builds on, what every revision changed, and the attack behind each rule. With hands-on labs and a quiz in every lesson.
Anyone securing an MCP server or client
Developers who build or connect remote MCP servers over HTTP and need to understand the authorization flow, not just copy it. No prior OAuth knowledge needed: parts 1 and 2 build it from scratch.
Every rule has an attack behind it
PKCE, the resource parameter, the audience check, the iss comparison: each rule is taught next to the attack it stops, so you know what breaks when you skip it.
2024-11-05 to 2026-07-28
MCP authorization changed in every revision. Part 4 walks through each one and compares them, so you can tell which rules apply to the clients and servers you talk to.
Labs that run in your browser.
Each lab sits inside the lesson that explains it. Nothing leaves your browser and nothing is stored. Flows are also walked step by step, actor by actor.
- lesson 2.5PKCE labGenerate a real code_verifier and S256 challenge, redeem the code, then try it as the attacker.
- lesson 2.10JWT labEdit the claims of an access token and watch how an MCP server accepts or rejects it.
- lesson 3.4Discovery URL builderType an MCP server URL and get every .well-known URL a client tries, in order.
- lesson 3.6CIMD validatorCheck a Client ID Metadata Document against the rules an authorization server applies.
- lesson 3.8iss decision tableWhat a client must do for each combination of advertised support and iss in the response.
- lesson 2.8Incremental scopesTrigger a 403 insufficient_scope and see which scopes the next authorization asks for.
- lesson 2.7redirect_uri checkSee which redirect URIs an authorization server accepts under exact matching.
- lesson 4.9Revision explorerPick two MCP revisions and compare every authorization requirement side by side.
- lesson 6.4Decision wizardOAuth 2.1, a custom mechanism or no auth at all: answer a few questions about your server.
- lesson 6.5Error finderFrom the symptom you see to the cause and the fix.
7 parts, 46 lessons.
Read in order, or jump in where you need it. Every lesson ends with a quiz; the exam draws from all of them, and the glossary defines every term.
What each part covers.
- 1
Foundations: before OAuth
Authentication vs. authorization, why a static token is not enough, the classic HTTP credentials, 401/403 with WWW-Authenticate, and discovery under /.well-known/.
- 2
OAuth 2.1 from scratch
The four roles, what OAuth 2.1 removed, access and refresh tokens, the authorization code grant with PKCE, client credentials, redirect_uri and state, scopes, and how a resource server validates a token.
Start with 2.1 The four OAuth roles →10 lessons
- 3
The satellite RFCs MCP relies on
How a client gets a client_id, Authorization Server Metadata (RFC 8414), OpenID Connect Discovery, Protected Resource Metadata (RFC 9728), Dynamic Client Registration, Client ID Metadata Documents, Resource Indicators (RFC 8707) and iss (RFC 9207).
Start with 3.1 Client identity: the client_id and how to get one →8 lessons
- 4
MCP authorization, revision by revision
Where authorization fits in MCP, the transports, the three valid paths, and what each revision changed: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25 and 2026-07-28, compared side by side.
Start with 4.1 What MCP is and where authorization fits →9 lessons
- 5
Security: the attack behind each rule
Code interception, token reuse across servers, token passthrough and the confused deputy, mix-up attacks, and the non-optional rules each one explains.
Start with 5.1 Authorization code theft and interception →5 lessons
- 6
In practice
The complete flow end to end, building a protected MCP server and the client side, when a custom mechanism makes sense, and how to debug authorization errors.
- 7
Reference
A cheat sheet of endpoints and parameters, a map of the RFCs and specifications, a non-optional checklist per revision, and the primary sources.
Start with 7.1 Cheat sheet: endpoints and parameters →4 lessons
Before you start.
Is OAuth mandatory in MCP?
No. Authorization is optional in MCP, and it only applies to HTTP transports (stdio servers take credentials from the environment). If an HTTP server does protect itself, the specification says it SHOULD conform to the MCP authorization rules, which are built on OAuth 2.1; a custom mechanism stays valid but generic clients cannot discover it.
If I already have an API key, why OAuth?
The Bearer header looks the same in both cases. The difference is everything before it: OAuth lets a client that has never seen your server discover who issues tokens, get the user's consent, and receive a short-lived token limited to some scopes and bound to one server, with no manual configuration.
What changed in MCP 2025-06-18?
The roles split: the MCP server became an OAuth resource server only, advertising its authorization servers through Protected Resource Metadata (RFC 9728). Clients must send the resource parameter (RFC 8707) and servers must reject tokens issued for someone else; token passthrough is forbidden.
Do I need to know OAuth before starting?
No. Parts 1 and 2 build HTTP authentication and OAuth 2.1 from scratch. If you already know OAuth well, start at part 3 (the RFCs MCP adds) or part 4 (the per-revision changes).
Want the specification, rule by rule?
The MCP Guide for Governance reads the whole protocol at the level of its normative requirements.