Skip to content

fix(client): accumulate scopes across 401/403 auth challenges#1618

Closed
stakeswky wants to merge 1 commit intomodelcontextprotocol:mainfrom
stakeswky:fix/issue-1582-scope-union
Closed

fix(client): accumulate scopes across 401/403 auth challenges#1618
stakeswky wants to merge 1 commit intomodelcontextprotocol:mainfrom
stakeswky:fix/issue-1582-scope-union

Conversation

@stakeswky
Copy link

@stakeswky stakeswky commented Mar 3, 2026

Summary

  • fix StreamableHTTPClientTransport scope handling to merge (union) scopes from new WWW-Authenticate challenges instead of overwriting existing scope
  • apply this for both 401 auth challenges and 403 insufficient_scope upscoping
  • add/adjust tests to verify progressive scope accumulation behavior

Why

Servers with per-operation scopes may return only the scope needed for the current resource (RFC 6750). Overwriting client scope causes previously granted scopes to be dropped and can lead to re-authorization loops.

Fixes #1582.

@stakeswky stakeswky requested a review from a team as a code owner March 3, 2026 10:03
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 544c07b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1618

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1618

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1618

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1618

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1618

commit: 62d946a

@pcarleton
Copy link
Member

hi thanks for this, going to close this in favor of #1604

@pcarleton pcarleton closed this Mar 4, 2026
@pcarleton
Copy link
Member

hi thanks for this, going to close this in favor of #1604

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.

Scope overwrite in 403 upscoping prevents progressive authorization for servers with per-operation scopes

2 participants