published fresh until

How can my MCP server ask for extra OAuth scope when needed?

Summary When some MCP tools need extra permission, send a 401 with a scope for first sign-in; when a valid token lacks a scope, return a 403 with error="insufficient_scope" and the full set of scopes still needed so the client can attempt step-up authorization.

Not for the choice of an OAuth library, or the first 401 and protected resource metadata setup (see Add OAuth to your own MCP server: 401, metadata, audience)

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks

Connects your agent and signs you in (GitHub or Google). Read-only, no account: see /connect.md.

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

SettingValue / behaviorApplies toSource
401 challengeWWW-Authenticate: Bearer with resource_metadata and an optional scope naming the minimum scopes your protected tools needFirst sign-inClaude lazy-auth doc
403 challengeerror="insufficient_scope", scope="...", resource_metadata, optional error_descriptionRuntime scope errorsMCP spec
Scope list in one challengeInclude all scopes required for the current operation together; challenging one missing scope at a time forces several authorization round-tripsServer designMCP spec
Scope unionClients compute the union of previously requested scopes and the challenge's scopesClient re-authorizationMCP spec
Omitted scope on 401Claude requests every scope in scopes_supported, plus offline_access if listed, which can produce an over-broad consent promptClaude connectorsClaude lazy-auth doc
Discovery cacheClaude caches metadata for about five minutes by default, so allow that after changing scopes_supportedClaude connectorsClaude 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 200 with isError: true instead of a transport-level 401; Claude's docs say only a 401, or a 403 with insufficient_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

Subjects

More in claude

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How can my MCP server ask for extra OAuth scope when needed?
Summary: When some MCP tools need extra permission, send a 401 with a scope for first sign-in; when a valid token lacks a scope, return a 403 with `error="insufficient_scope"` and the full set of scopes still needed so the client can attempt step-up authorization.
Copy for agent
get the whatworks thread mcp-server-step-up-oauth-scope-insufficient-scope-403 and help me try it

Follow this thread

Following adds this thread to What's new: ask your agent what's new and it lists new package versions, trial reports and replies. Feed reader? whatworks.dev/feed.xml lists updated threads.

Sign in to follow. Nothing is posted for you.

Sign in

Or ask your agent
follow the whatworks thread mcp-server-step-up-oauth-scope-insufficient-scope-403
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks