Skip to content

fix(client): preserve custom Accept headers in StreamableHTTPClientTransport#1655

Open
nielskaspers wants to merge 1 commit intomodelcontextprotocol:mainfrom
nielskaspers:fix/issue-1646-preserve-custom-accept-header
Open

fix(client): preserve custom Accept headers in StreamableHTTPClientTransport#1655
nielskaspers wants to merge 1 commit intomodelcontextprotocol:mainfrom
nielskaspers:fix/issue-1646-preserve-custom-accept-header

Conversation

@nielskaspers
Copy link
Contributor

Summary

StreamableHTTPClientTransport unconditionally overwrites custom Accept headers provided via requestInit.headers with SDK defaults. This change only sets the default Accept header when the user has not already provided one.

Issue

Fixes #1646

Changes

  • In send() (POST requests): only set accept: application/json, text/event-stream if no Accept header exists
  • In _startOrAuthSse() (GET SSE requests): only set accept: text/event-stream if no Accept header exists

Testing

  • Added test: custom Accept header is preserved on POST requests
  • Added test: custom Accept header is preserved on GET SSE requests
  • Added test: default Accept header is set when none provided
  • All 260 existing tests continue to pass
  • Lint passes

…ansport

The SDK unconditionally overwrites custom Accept headers provided via
requestInit.headers with its own defaults. This prevents users from
configuring MCP servers that require specific Accept header values.

Only set default Accept headers when the user has not provided one.

Fixes modelcontextprotocol#1646
@nielskaspers nielskaspers requested a review from a team as a code owner March 10, 2026 07:16
@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

⚠️ No Changeset found

Latest commit: 21b050f

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

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.

SDK overwrites custom Accept headers unconditionally

1 participant