Skip to content

[v1.x] fix(client/auth): avoid duplicate prompt query parameter in startAuthorization - #3275

Open
naufalfx805-source wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
naufalfx805-source:fix/v1-start-authorization-prompt
Open

naufalfx805-source wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
naufalfx805-source:fix/v1-start-authorization-prompt

Conversation

@naufalfx805-source

Copy link
Copy Markdown

Summary

Backports the fix from #1958 onto v1.x to resolve #3274.

When startAuthorization is called with offline_access scope against an authorization server whose advertised authorization_endpoint metadata already contains a prompt query parameter (such as Okta/Brex ?prompt=consent or Entra ID ?prompt=select_account), authorizationUrl.searchParams.append('prompt', 'consent') emitted two prompt parameters on the resulting URL. That violates RFC 6749 §3.1 and causes authorization servers to reject the request before sign-in.

All other OAuth query parameters in startAuthorization (response_type, client_id, code_challenge, code_challenge_method, redirect_uri, state, scope, resource) already use searchParams.set(). Changing .append('prompt', 'consent') to .set('prompt', 'consent') aligns the offline_access branch with the rest of startAuthorization and ensures a single prompt=consent parameter per OIDC Core §11.

Fixes #3274

Changes

  • src/client/auth.ts: Use authorizationUrl.searchParams.set('prompt', 'consent') inside the offline_access branch in startAuthorization.
  • test/client/auth.test.ts: Added regression coverage verifying a single prompt=consent parameter when authorization_endpoint already includes ?prompt=consent or ?prompt=select_account, and preserving existing prompt query parameters when offline_access is omitted.
  • .changeset/fix-v1-start-authorization-prompt.md: Added patch changeset for @modelcontextprotocol/sdk.

Verification

  • npm run lint (eslint src/ + prettier --check .) — passed
  • npx tsc --noEmit — passed
  • npm run build (build:esm + build:cjs) — passed
  • npx vitest run --maxWorkers=2 test/client/auth.test.ts — 161/161 passed

@naufalfx805-source
naufalfx805-source requested review from a team as code owners December 4, 2026 14:44
@changeset-bot

changeset-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c7d287

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T14:46:11.779214Z 6c7d287 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 6c7d287

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c7d287c19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/client/auth.ts
// we need to set the prompt to "consent" to ensure the user is prompted to grant offline access
// https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess
authorizationUrl.searchParams.append('prompt', 'consent');
authorizationUrl.searchParams.set('prompt', 'consent');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve account-selection prompts when adding consent

When offline_access is requested and the advertised authorization endpoint has prompt=select_account, this replaces that directive with only consent, so the provider no longer receives the request to show an account picker and may authorize the default signed-in account. OIDC allows compatible prompt directives to share a space-delimited value, so keep the existing directive in the single parameter rather than discarding it.

Useful? React with 👍 / 👎.

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