Skip to content

HttpClientTransportOptions.AdditionalHeaders not applied to all MCP requests in MCP client #1217

@ijamshed99

Description

@ijamshed99

When HttpClientTransport is created with HttpClientTransportOptions.AdditionalHeaders (e.g. Authorization: Bearer ), the header is applied for the initial handshake but is missing on subsequent MCP requests (tools/list, tools/call). Server receives requests without the Authorization header.

  1. Create transport with HttpClientTransportOptions.AdditionalHeaders = { ["Authorization"] = "Bearer " }.
  2. Create MCP client with that transport.
  3. Call ListToolsAsync() and then CallToolAsync(...).
  4. Observe server-side middleware: initial request may show token, later MCP calls report missing Authorization.

Headers provided in AdditionalHeaders (especially Authorization) should be present on every HTTP request the transport issues, not only during the initial handshake.

• Client logs: token created and initial request shows header present.
• Server logs: later requests report No Bearer token provided and incomplete session context.
• Pattern: different connection/RequestId used for later requests that lack the header.
• Likely cause: transport creates or uses multiple HttpClient instances and does not apply AdditionalHeaders to every outgoing HttpRequestMessage.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions