Skip to content

[TypeScript] MCPToolProvider sse transport passes headers option that SSEClientTransport ignores #640

Description

@cornelcroi

Problem

mcpToolProvider.ts constructs the SSE transport as:

transport = new SSEClientTransport(new URL(serverConfig.url), {
  headers: serverConfig.headers ?? {},
});

But the SDK's SSEClientTransportOptions has no top-level headers key — it takes authProvider / eventSourceInit / requestInit. So custom headers configured on a TS sse server (e.g. Authorization) are most likely silently dropped. The Python side passes headers correctly (sse_client(url, headers=...)), so this is a TS-only parity bug.

Found during review of #632, where the new streamable-http branch does it correctly via requestInit.

Proposal

Pass headers through both requestInit.headers (POST requests) and eventSourceInit (the SSE GET stream needs a custom fetch/EventSource init to carry headers — check the SDK version's exact mechanism), with a test asserting the constructed options shape.

Behavioral note for the changelog: users' headers on TS SSE configs will start being sent — that is the documented intent, but it is a change in effective behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions