Skip to content

Commit 57d0f8e

Browse files
committed
fix(client): preserve user-supplied Accept header instead of overwriting unconditionally
Custom Accept headers set in MCP server configuration (e.g. 'application/vnd.example.v1+json') were unconditionally overwritten with 'application/json, text/event-stream', breaking APIs that require specific Accept values. Now only sets the default Accept header when no Accept header has already been supplied by the caller. The SSE GET channel Accept header is unaffected since it must always be 'text/event-stream'. Fixes modelcontextprotocol#1646.
1 parent 984a27e commit 57d0f8e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎packages/client/src/client/streamableHttp.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ export class StreamableHTTPClientTransport implements Transport {
491491

492492
const headers = await this._commonHeaders();
493493
headers.set('content-type', 'application/json');
494-
headers.set('accept', 'application/json, text/event-stream');
494+
if (!headers.has('accept')) {
495+
headers.set('accept', 'application/json, text/event-stream');
496+
}
495497

496498
const init = {
497499
...this._requestInit,

0 commit comments

Comments
 (0)