401 loop even though I just authenticated |
The token has a different audience (resource differs from the server's canonical URL) or the server expects a different iss. |
Decode the JWT: compare aud with the resource in the resource metadata and with what the server validates (trailing slash, /mcp path). |
2.10, 3.7 |
invalid_grant when exchanging the code |
A code_verifier that does not match, a code already used or expired, or a redirect_uri different from the one used at /authorize. |
Send exactly the same redirect_uri; don't retry with the same code; keep the verifier for this specific flow. |
2.4, 2.5 |
redirect_uri mismatch / invalid redirect |
The URI does not match the registered one exactly (trailing slash, port, http vs https, case). |
Compare character by character with the registration or with redirect_uris in the metadata document. |
2.7, 3.6 |
| The client says the issuer does not match |
The issuer in the metadata differs from the URL used to fetch it; typical with a trailing slash or a tenant path. |
Check how the .well-known URL is built (insertion vs. appending) and the exact issuer value. |
1.5, 3.2, 3.3 |
Authorization response rejected because of iss |
iss differs from the recorded issuer (trailing slash, case), or the AS advertises iss support and does not send it. |
Exact comparison; check authorization_response_iss_parameter_supported. |
3.8, 5.4 |
404 when fetching the resource metadata |
The client looks at the root but the server publishes it at the path, or vice versa; or WWW-Authenticate is missing. |
Publish both locations (path and root) or include resource_metadata in the 401. |
3.4 |
404 on /.well-known/oauth-authorization-server |
The AS only publishes OIDC Discovery, or the issuer has a path and the URL was built wrongly. |
Try /.well-known/openid-configuration and the path variants (2025-11-25 onwards). |
3.3 |
| The client refuses: PKCE not supported |
The AS metadata does not include code_challenge_methods_supported. |
Configure the AS to advertise S256 (some support it but don't advertise it). |
2.5, 3.2 |
403 insufficient_scope repeats after reauthorizing |
The client requested only the new scope and lost the previous ones, or the server asks for scopes one at a time. |
The client must accumulate scopes; the server must ask for all the scopes of the operation in a single 403. |
2.8 |
Works for a while, then 401 invalid_token |
The access token expired and is not being renewed. |
Use the refresh token before expires_in; request offline_access if the AS requires it to issue refresh tokens. |
2.9 |
invalid_grant when refreshing |
Rotation: an old refresh token was used (for example, two processes refreshing at once) or it was revoked. |
Always store the latest refresh token atomically and avoid concurrent refreshes. |
2.9 |
The AS rejects the URL-shaped client_id |
Metadata document without a path, without HTTPS, with a client_id different from its URL, or the AS does not support CIMD. |
Validate the document and check client_id_metadata_document_supported. |
3.6 |
The AS answers invalid_target or ignores resource |
The AS does not support RFC 8707 or does not have that resource registered. |
Register the MCP server as a resource/audience in the AS; the client must keep sending it. |
3.7 |
| My server accepts tokens from another MCP server |
The audience (aud) is not checked. |
Validate the audience when verifying the JWT, or aud in the introspection response. |
2.10, 5.2 |
The 401 has no WWW-Authenticate and the client gets stuck |
Server without the header and a 2025-06-18 client (where it was mandatory) or a client without a fallback. |
Add resource_metadata to the 401; from 2025-11-25 the client can try the .well-known locations. |
1.4, 3.4 |
| Works with cookies in the browser but not in the MCP client |
A custom cookie-based mechanism: MCP clients don't manage cookies like a browser. |
Use OAuth 2.1 or a Bearer token in the header. |
1.3, 6.4 |
| The token shows up in the proxy logs |
It is being sent in the URL (?access_token=) or the Authorization header is being logged. |
Token only in the header; mask Authorization in logs. |
2.3, 5.5 |