This lesson covers what an MCP client must implement for MCP authorization: discovery, pre-flight checks, the OAuth 2.1 authorization code flow with PKCE and resource, state and iss validation, secure token storage and renewal. The client does most of the work in the flow, so this is where most of the rules live.
In this lesson
Describe the client's responsibilities in each phase of the flow
Choose how the client identifies itself: pre-registration, CIMD, dynamic registration or the user
Follow a pseudocode skeleton of the full client flow
Explain why a client needs one access token per MCP server
Responsibilities by phase
Phase
The client must…
Discovery
Read resource_metadata from the 401; if absent, try the .well-known URL at the path and at the root. Then fetch the AS metadata: OAuth first, then OIDC (with the path variants). Check issuer.
Pre-flight
Refuse if there is no code_challenge_methods_supported. Choose how to identify itself: pre-registration → CIMD → (dynamic registration if nothing else works) → ask the user.
Authorization
Generate state and PKCE S256. Send resource. Record the expected issuer. Open the browser. Listen on loopback.
Callback
Check state. Apply the iss table. Exact comparison.
Exchange and storage
code_verifier + resource. Store tokens in secure storage, bound to the authorization server and the resource.
Use
Bearer on every request. Never interpret the access token. Never send it to another server.
Maintenance
Renew before expires_in. Handle rotation. On a 403, add scopes and reauthorize.
The "iss table" is the RFC 9207 decision table covered in lesson 3.8: what to do depending on whether the AS advertises authorization_response_iss_parameter_supported and whether iss is present in the response.
Note the order of the identification fallbacks: a pre-registered client_id wins, then the client's own metadata document URL if the AS advertises client_id_metadata_document_supported, and only then dynamic registration, which is deprecated in MCP 2026-07-28 and kept as a last resort.
Summary
Discover, verify, identify, authorize with PKCE + resource, check state/iss, exchange, store securely, renew.
One token per resource; never forward it to another server.
Refuse to continue if the AS does not advertise code_challenge_methods_supported, and record the expected issuer before redirecting.
quiz · 3 questions
1. The client holds tokens for https://a.example.com/mcp and connects to a new server, https://b.example.com/mcp, that uses the same authorization server. Does it reuse the access token?
One token per resource. Sending A's token to B would also hand B a token that is valid at A.
2. The AS metadata has no code_challenge_methods_supported field. What does the client do?
Clients rely on the metadata to verify PKCE support; if the field is absent, the AS does not support PKCE and the client must refuse to proceed.
3. In which order does the client try to obtain a client_id?
A pre-registered client_id is used first; otherwise the metadata document URL if the AS supports it; dynamic registration is deprecated and only a fallback.