1. Request without a token
MCP client → MCP server
POST /mcp HTTP/1.1
Host: mcp.example.com
Content-Type: application/json
{"jsonrpc":"2.0","id":1,"method":"tools/list"}
No initialize first: the protocol is stateless.
2. 401
MCP server → MCP client
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
scope="files:read"
If the header were missing, the client would try /.well-known/oauth-protected-resource/mcp and then the root.
3. Resource metadata
MCP client → MCP server
{ "resource": "https://mcp.example.com/mcp",
"authorization_servers": ["https://auth.example.com"],
"scopes_supported": ["files:read","files:write"] }
4. Authorization server metadata
MCP client → Authorization server
The client tries /.well-known/oauth-authorization-server, and if that fails, /.well-known/openid-configuration. It checks that:
issuer matches.
code_challenge_methods_supported is present and includes S256 (otherwise it refuses to continue).
client_id_metadata_document_supported: true.
authorization_response_iss_parameter_supported.
5. Client identification
There is no pre-registration, so the client uses its metadata document: client_id=https://app.example.com/oauth/client-metadata.json. It generates state, code_verifier and code_challenge, and records the expected issuer: https://auth.example.com.
6. Redirect to the authorization server
MCP client → User
GET https://auth.example.com/authorize?response_type=code
&client_id=https%3A%2F%2Fapp.example.com%2Foauth%2Fclient-metadata.json
&redirect_uri=http%3A%2F%2F127.0.0.1%3A33418%2Fcallback
&scope=files%3Aread%20offline_access
&state=af0ifjsldkj&code_challenge=E9Mel...&code_challenge_method=S256
&resource=https%3A%2F%2Fmcp.example.com%2Fmcp
7. The AS fetches the client's document
Authorization server → Client website
It checks that the client_id inside the JSON equals the URL it was fetched from, and that the redirect_uri is listed in redirect_uris.
8. Login and consent
User → Authorization server
"Example MCP Client (app.example.com) wants to read your files."
9. The way back
Authorization server → MCP client
Location: http://127.0.0.1:33418/callback?code=SplxlOBe&state=af0ifjsldkj&iss=https%3A%2F%2Fauth.example.com
The client checks state and iss (exact comparison).
10. Code exchange
MCP client → Authorization server
POST /token with code, code_verifier, redirect_uri, client_id and resource.
11. Tokens
Authorization server → MCP client
{ "access_token":"eyJ...", "token_type":"Bearer", "expires_in":3600,
"refresh_token":"8xLO...", "scope":"files:read offline_access" }
The client stores the refresh token in secure storage, bound to this authorization server.
12. Retry with Bearer
MCP client → MCP server
tools/list with Authorization: Bearer eyJ....
13. Validation and response
MCP server → MCP client
Signature, iss, aud=https://mcp.example.com/mcp, exp, scope → 200.
14. Step-up
MCP server → MCP client
When the client tries to write: 403 insufficient_scope with scope="files:write". The client adds the new scope to the ones it already had and reauthorizes with files:read files:write offline_access.
15. Refresh
MCP client → Authorization server
When the access token expires: grant_type=refresh_token (with resource). With rotation, a new refresh token comes back.