What this thread does
Do first: when a protected tools/call request carries no valid bearer token, answer with an HTTP 401 and a WWW-Authenticate header from your HTTP handler, before the MCP SDK runs; if a valid token lacks a scope, return a 403 insufficient_scope challenge instead; a tool result that only contains an error message does not start sign-in. Claude lazy-auth doc
Short answer
For a remote MCP server whose tools need different OAuth scopes, the MCP authorization specification says to put the scopes needed for the current operation in the scope parameter of the WWW-Authenticate header. When a signed-in user's token lacks a scope at runtime, the server should answer 403 Forbidden with error="insufficient_scope" and the scopes needed; clients should attempt step-up authorization, but may handle the error differently, and client_credentials clients may abort immediately. MCP spec Claude's connector docs describe the same flow and say Claude prompts the user to re-authorize and then retries the same tool call. Claude lazy-auth doc
Choose / don't choose
Choose per-operation scope challenges when only some tools need extra permissions and users should consent when they first need them. MCP spec Choose lazy authentication, a 401 on protected tools only, when some tools work without an account. Claude lazy-auth doc
Not for deciding which OAuth library to use or for the first 401 and protected resource metadata setup. Client behavior can differ: the spec says clients should respond to scope errors with a step-up flow or handle them in other appropriate ways. MCP spec
Settings that matter
| Setting | Value / behavior | Applies to | Source |
|---|---|---|---|
| 401 challenge | WWW-Authenticate: Bearer with resource_metadata and an optional scope naming the minimum scopes your protected tools need | First sign-in | Claude lazy-auth doc |
| 403 challenge | error="insufficient_scope", scope="...", resource_metadata, optional error_description | Runtime scope errors | MCP spec |
| Scope list in one challenge | Include all scopes required for the current operation together; challenging one missing scope at a time forces several authorization round-trips | Server design | MCP spec |
| Scope union | Clients compute the union of previously requested scopes and the challenge's scopes | Client re-authorization | MCP spec |
Omitted scope on 401 | Claude requests every scope in scopes_supported, plus offline_access if listed, which can produce an over-broad consent prompt | Claude connectors | Claude lazy-auth doc |
| Discovery cache | Claude caches metadata for about five minutes by default, so allow that after changing scopes_supported | Claude connectors | Claude lazy-auth doc |
Order of operations
1. Split tools into those anyone can call and those that need the user's account; keep the public group safe without an identity. Claude lazy-auth doc 2. In the HTTP handler, check tools/call for protected tools and return 401 with WWW-Authenticate before the SDK handles the request when the request has no valid bearer token; return 403 insufficient_scope when a valid token lacks a scope. Claude lazy-auth doc MCP spec 3. For a tool that needs more scope than the token has, return 403 with error="insufficient_scope" and the full set of scopes still needed. Claude lazy-auth doc 4. Test with a client: Claude should show a sign-in prompt and then retry the call. Claude lazy-auth doc
Example 403 from the spec:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
scope="files:write",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
error_description="File write permission required for this operation"
Known failures and fixes
- Users see "please sign in" text instead of a Connect button: the server returned a
200withisError: trueinstead of a transport-level 401; Claude's docs say only a 401, or a 403 withinsufficient_scope, triggers re-authentication, and any other 403 is a terminal error. Claude lazy-auth doc - Scopes granted earlier are lost in a later step-up: Claude's docs say they are not reliably carried forward, so list every scope the user still needs in each 403. Claude lazy-auth doc
- The spec asks clients to limit retries and track scope upgrade attempts, so a permanently insufficient token ends in failure rather than a loop. MCP spec
Missing
- This draft provides no runtime test evidence, and how a specific client other than Claude behaves is not covered.
Evidence
MCP authorization specification for protocol revision 2026-07-28 and Claude's "Lazy authentication for MCP servers" page. 0 trials in this draft; not tried by WhatWorks.
Checked
2026-12-03; both pages were read as served on that date.
Started from a post by @Model Context Protocol, packaged by the editor. Original post