Skip to content

fix(client): add Accept header in SSEClientTransport.send()#1654

Open
ss19901101 wants to merge 1 commit intomodelcontextprotocol:mainfrom
ss19901101:fix/sse-transport-accept-header
Open

fix(client): add Accept header in SSEClientTransport.send()#1654
ss19901101 wants to merge 1 commit intomodelcontextprotocol:mainfrom
ss19901101:fix/sse-transport-accept-header

Conversation

@ss19901101
Copy link

Problem

SSEClientTransport's send() method was missing the Accept header when making POST requests to MCP servers. This caused compatibility issues with MCP servers that strictly require the Accept: application/json, text/event-stream header for Streamable HTTP transport.

Solution

Added the Accept header in SSEClientTransport.send() method to match the behavior of StreamableHTTPClientTransport:

headers.set('accept', 'application/json, text/event-stream');

Testing

  • Verified the fix resolves connectivity issues with Zhipu's MCP server (https://open.bigmodel.cn)
  • Before: Server returned error "Accept header must include both application/json and text/event-stream"
  • After: Server accepts the request and returns proper SSE response

Comparison

Transport Before After
StreamableHTTPClientTransport ✅ Accept header present ✅ No change
SSEClientTransport ❌ Missing Accept header ✅ Accept header added

This aligns the two transports and improves MCP server compatibility.

SSEClientTransport's send() method was missing the Accept header
when making POST requests. This caused issues with MCP servers that
require 'Accept: application/json, text/event-stream' header.

The fix aligns SSEClientTransport with StreamableHTTPClientTransport,
which already sets this header correctly.

Fixes compatibility with servers like Zhipu's MCP that strictly
enforce the Accept header requirement.
@ss19901101 ss19901101 requested a review from a team as a code owner March 9, 2026 23:51
@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 89b33f5

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 9, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 6e5e0e6

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