Skip to content

fix(client/auth): use .set() for prompt=consent instead of .append() to avoid duplicating#1958

Open
mhegazy wants to merge 2 commits intomodelcontextprotocol:mainfrom
mhegazy:fix-prompt-param-duplicate
Open

fix(client/auth): use .set() for prompt=consent instead of .append() to avoid duplicating#1958
mhegazy wants to merge 2 commits intomodelcontextprotocol:mainfrom
mhegazy:fix-prompt-param-duplicate

Conversation

@mhegazy
Copy link
Copy Markdown

@mhegazy mhegazy commented Apr 24, 2026

Problem

When the authorization server's authorization_endpoint metadata already includes a prompt query parameter, startAuthorization appends a second prompt=consent (when scope contains offline_access), producing a request with two prompt parameters. Azure AD rejects this with AADSTS9000411: The parameter 'prompt' is duplicated.

Real-world example: Anthropic's hosted Microsoft 365 MCP server publishes authorization_endpoint: "https://login.microsoftonline.com/.../authorize?prompt=select_account". The resulting URL contains both prompt=select_account and prompt=consent.

Spec

  • RFC 6749 §3.1: "Request and response parameters MUST NOT be included more than once."
  • OIDC Core 1.0 §3.1.2.1 defines prompt as space-delimited, but Azure AD rejects that form too (AADSTS90023: Unsupported 'prompt' value) — it only accepts a single value.
  • OIDC Core §11: when offline_access is requested, prompt=consent MUST be used. So consent is the value that needs to win.

Fix

.append().set(). If the endpoint already carries a prompt value, consent overwrites it — this is the only portable choice given Azure's single-value constraint, and consent is the value OIDC §11 mandates for the offline_access flow this branch guards.

References

… duplicating

When the AS metadata's authorization_endpoint already includes a prompt
query parameter (permitted by RFC 6749 §3.1, which says clients MUST
retain it), startAuthorization's offline_access handling appended a
second prompt=consent. RFC 6749 §3.1 also states parameters MUST NOT be
included more than once; Azure AD enforces this and rejects the request
with AADSTS9000411.

OIDC Core §3.1.2.1 defines prompt as a space-delimited list, so merge
consent into the existing value as a single parameter.

Ref: anthropics/claude-code#31089
@mhegazy mhegazy requested a review from a team as a code owner April 24, 2026 18:22
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

⚠️ No Changeset found

Latest commit: 7d8ecd3

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
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1958

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1958

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1958

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1958

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1958

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1958

commit: 7d8ecd3

@mhegazy mhegazy changed the title fix(client/auth): merge consent into existing prompt param instead of duplicating fix(client/auth): use .set() for prompt=consent instead of .append() to avoid duplicating Apr 24, 2026
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