Skip to content

Let auth provider headers override requestInit Authorization#2223

Open
tarunag10 wants to merge 1 commit into
modelcontextprotocol:mainfrom
tarunag10:fix-auth-header-precedence
Open

Let auth provider headers override requestInit Authorization#2223
tarunag10 wants to merge 1 commit into
modelcontextprotocol:mainfrom
tarunag10:fix-auth-header-precedence

Conversation

@tarunag10
Copy link
Copy Markdown

Summary

  • merge requestInit headers before SDK-derived auth/session/protocol headers
  • apply the same precedence to streamable HTTP and legacy SSE transports
  • add an e2e regression proving an auth provider token overrides a stale configured Authorization header

Fixes #2208.

Verification

  • corepack pnpm --filter @modelcontextprotocol/test-e2e exec vitest run scenarios/client-auth.test.ts
  • corepack pnpm --filter @modelcontextprotocol/client run typecheck
  • corepack pnpm --filter @modelcontextprotocol/client run lint

Note: the local pre-push hook could not find pnpm on PATH, so I pushed with LEFTHOOK=0 after running the checks above via Corepack.

@tarunag10 tarunag10 requested a review from a team as a code owner May 31, 2026 20:49
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 31, 2026

⚠️ No Changeset found

Latest commit: 8e84c55

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 May 31, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2223

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2223

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 8e84c55

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.

One line change to enable fallback authentication

1 participant