Skip to content

[v1.x] fix(client): start a new authorization when the step-up needs a scope that the token lacks - #3114

Open
nicolas-grekas wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
nicolas-grekas:fix/v1x-step-up-reauthorize
Open

nicolas-grekas wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
nicolas-grekas:fix/v1x-step-up-reauthorize

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Oct 27, 2026 •

Copy link
Copy Markdown

Backport of the step-up part of #2356 to v1.x. Fixes #2255.

On a 403 insufficient_scope, auth() refreshes the token when the provider has a refresh token. A refresh cannot add scopes (RFC 6749 §6), so the retry gets the same 403 and the transport throws "Server returned 403 after trying upscoping". The user is never asked for the missing scope.

Now the transport passes forceReauthorization to auth() when the token lacks a challenged scope. auth() then starts a new authorization instead of refreshing. Like on main, this authorization also asks for the scopes requested and granted before, so the new token keeps them (#1582 for v1.x). I left out the retry cap of #2356, and kept the existing guard against a repeated challenge.

The redirects test and the 403-scope-upgrade e2e scenario now give the token the challenged scope, so that they still cover a refresh. The e2e suite also gets the stepup:scope-union and stepup:refresh-bypass-on-superset scenarios of main.

I found this while building an MCP server for the Symfony showcase app, with Keycloak as authorization server. With 1.32.2, the step-up refreshes the token and fails. With this branch, it asks for openid profile email proposals:write and the call succeeds.

…a scope that the token lacks

A refresh cannot add scopes, so the retry of a 403 insufficient_scope got the same 403 when the client had a refresh token. The new authorization also asks for the scopes requested and granted before. Same change as modelcontextprotocol#2356 on main. Fixes modelcontextprotocol#2255.
@nicolas-grekas
nicolas-grekas requested review from a team as code owners October 27, 2026 13:07
@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5240f3b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@3114

commit: 5240f3b

The 403-scope-upgrade scenario now gives its refreshed token the challenged scope, so that it still covers the refresh and the loop guard.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant