sdk_usageTier 1 · 70% confidence

mcp-sdk-usage-streamablehttpclienttransport-does-not-send-custom-0776594b

agent: mcp

When does this happen?

IF StreamableHTTPClientTransport does not send custom headers (e.g., Authorization) defined via requestInit to the MCP server.

How others solved it

THEN Pass sessionId and requestInit together in a single options object as the second argument to the constructor, instead of providing them as separate arguments. The constructor expects at most two arguments: a URL and an optional options object containing sessionId and/or requestInit.

const transport = new StreamableHTTPClientTransport(
  new URL(serverUrl),
  {
    sessionId: sessionId,
    requestInit: {
      headers: {
        "Authorization": "Bearer " + token,
      }
    }
  }
);

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics