CSE Roadmap

Core tier · about 9 hours · 17 parts

Part 8 of 17 · 3 min read

The flow, in order

From a 401 to a working call, with the guarded steps along the way.

AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTozMzdmMGY3ZS1lOTQ0LTQ1YWEtODQxMi04NDJiNWY0NzVhNmYAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaPyR6Bvc2sKjNnVBn5tUQpAAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDpmNTk5MjNkYi03NzFhLTQ2MGMtYmExMC04NjllYjBlN2ZhNmNscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNov1vKOdYJr5GS+vAJ3rwfegAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFgg+tLInWHK88olikEIt/QZSJbe4gl/i7KvXl7a0LiqILmkZmFjdGlvbngdY29tLmFudGhyb3BpYy5jbGF1ZGUucHJvdmlkZWRqcGFyYW1ldGVyc6F4H2NvbS5hbnRocm9waWMub3JpZ2luLWNvbmZpZGVuY2VndW5rbm93bmtkZXNjcmlwdGlvbnhmQ2xhdWRlIHByb3ZpZGVkIHRoaXMgZmlsZSBhdCB0aGUgcmVxdWVzdCBvZiBhIHVzZXIgYW5kIG1heSBoYXZlIGNyZ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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQPcKHcFZJVxqa8K3cO07VzbrhZ/jKenX7pyaB0Ds92nIhF5aeJzobErD6yJqjcjWFqo+2F/rjCka/qWMRnsuVOM=From a 401 to a working call: what the client does, in orderClientMCP serverAuth serverPerson1 call without a token2 401 + WWW-Authenticate (resource_metadata, scope)3 GET protected resource metadata4 GET authorization server metadata (issuer check, S256)5 open authorize URL: PKCE, state, resource, scope6 consent (shows client name and redirect)7 redirect back: code, state, iss8 token request: code_verifier, resource9 access token (audience = this server, short life)10 call again with Authorization: Bearer11 403 insufficient_scope (scope=...) -> union, repeat 4-10Measured for one tool call: MCP statuses [401, 200], 1 authorization, 1 consent screen.Requests by host: mcp.example.com 3, auth.example.com 1, app.example.com 1.The client sends the token only to the MCP server. Every URL it fetched in steps 3-4 was chosen by a server, so it goes through a guard (see the SSRF figure).
From a 401 to a working call. Steps 3 and 4 fetch URLs that a server chose, so they are guarded

Step 1 and 2: the first call has no token, and the answer says where to go. The server answers 401 Unauthorized with a WWW-Authenticate header. Measured on a real socket in the example:

HTTP/1.1 401
WWW-Authenticate: Bearer scope="notes:read",
    resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource/mcp"

resource_metadata points at the server's Protected Resource Metadata. This is a small JSON document that says which authorization server issues tokens for this resource, which scopes exist, and how a bearer token may be presented. scope is the minimum needed to start.

Step 4: find the authorization server's own metadata and distrust it a little. The client tries addresses in a set order and checks that the issuer inside the document is identical to the issuer it used to build the address, rejecting a document from attacker.example that claims to be honest.example. The client must also check that the server offers PKCE with S256; if code_challenge_methods_supported is missing, the client must refuse to continue.

Who is the client? The authorization server has never heard of this client. Three ways to answer, in order of preference: pre-registered details, a Client ID Metadata Document (the client's id is an HTTPS URL the server fetches a JSON document from), or Dynamic Client Registration (now deprecated, kept for older servers).

Step 5 to 7: the authorization request. The client sends the PKCE challenge, a random state, the resource (the MCP server's canonical address) and the scope, and opens the authorization URL in the person's browser, which shows the client's name and where the result will be sent. The server redirects back with a short-lived, single-use code, the same state, and an iss parameter.

Step 8 to 10: token and use. The client sends the code and the original verifier plus resource again; the server hashes the verifier, compares, and issues a token carrying the audience, scope, subject and a short lifetime (300 seconds in the example). Every later request sends Authorization: Bearer <token>, never in the URL query.

Measured for one tool call from nothing: MCP statuses [401, 200], 1 authorization, and 1 consent screen. Requests by host were 3 to the MCP server, 1 to the authorization server, and 1 to the client's own metadata document.

Tip: the resource parameter is what makes tokens one-purpose

Without resource, an authorization server may issue a token good for anything it protects. With it, the token's audience is the one server the client named. The client must send it whether or not the server supports it, because the day a server does start enforcing audiences, every client that sent it is already correct.