Repository navigation
Open
Labels
bugSomething isn't working
Description
Problem
Junior does not correctly complete the standard MCP incremental-authorization path when an authenticated server returns:
HTTP 403
WWW-Authenticate: Bearer error="insufficient_scope", scope="..."
With @modelcontextprotocol/sdk 1.29.0, the transport forwards the challenged scope into auth(...). If Junior has a cached refresh token, the SDK refreshes it without sending the challenged scope and treats any successful refresh response as AUTHORIZED. The request is retried with effectively unchanged authorization, receives the same 403, and stops at the SDK's duplicate-upscope guard. No new consent redirect is created.
This is distinct from a provider simply not exposing write tools. OAuth can escalate scopes for an existing tool; it cannot manufacture tools the MCP server did not advertise.
Confirmed code path
- SDK
StreamableHTTPClientTransport.sendrecognizes the 403insufficient_scopechallenge and callsauthwith the requested scope. - SDK
authInternalprefers a cached refresh token before starting a new authorization redirect. - SDK
refreshAuthorizationsendsgrant_typeandrefresh_token(plus resource/client auth), but not the challenged scope. - Junior's MCP OAuth provider persists the resulting tokens without verifying that they satisfy the challenged scope.
Acceptance criteria
- A standard 403 Bearer
insufficient_scopechallenge records the exact requested scope and MCP resource. - Existing relevant scopes are retained when constructing the expanded authorization request.
- A refresh response is accepted as escalation only when it proves the challenged scope is granted; otherwise Junior starts a new interactive authorization attempt.
- The reauthorization attempt remains bound to workspace subject, resource, issuer, redirect URI, and the paused turn.
- Repeated identical challenges terminate safely without a refresh/redirect loop.
- The original paused tool call resumes after successful expanded consent.
- Missing provider tools remain a separate capability error and do not trigger OAuth.
- The deterministic MCP OAuth mock covers successful escalation, rejected scope, unchanged refresh scope, denial, and duplicate challenge behavior.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
armorer-labs commentedon Jul 1, 2026
One implementation detail I would make explicit is that scope escalation should be treated as a new authorization event, not as a continuation of the original read-only session.
A concrete flow that tends to avoid surprises:
capability_requiredresult with provider, missing scope/tier, intended operation class, and a redacted target summary;The test I would add is a two-step negative case: a read-only Notion connection requests
create page, the user declines escalation, and the agent cannot retry through an alternate write path or silently keep the pending intent around. Then the positive case can verify that the post-reauth tool inventory changed and the actual write still passes through the approval/audit path.Disclosure: I work on Armorer Labs.
dcramer commentedon Jul 11, 2026
RCA update: the installed SDK's current 403 step-up path is deterministically broken even before the product-level approval work described here.
For a
403 Bearer error="insufficient_scope", scope="read write", SDK 1.29.0 refreshes the existing token without sending the challenged scope, retries with an unchanged read-only token, then throwsServer returned 403 after trying upscoping. Junior also drops the challenged scope when translating the SDK error, so MCP pending-auth dedupe cannot distinguish escalation attempts.Protocol acceptance criteria should include:
Umbrella: #843.
feat(notion): expose limited write tools (#1480)
fix(github): Read draft checks from getPullRequest (#3266)