Apply custom HTTP headers to remote MCP server requests #1081
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Apply custom HTTP headers to remote MCP server requests
Problem: Custom HTTP headers configured for remote MCP servers were stored but never applied to HTTP requests, preventing authentication to servers that require API keys, bearer tokens, or other header-based auth.
Root cause: In commit 814d46a ("MCP Oauth rework"), when migrating from mark3labs/mcp-go to the official MCP SDK, header support was accidentally dropped. The createHTTPClient() method only wrapped requests with OAuth support, ignoring the stored headers.
Summary
remoteMCPClientinpkg/tools/mcp/remote.gohandles connections to remote MCP servers over HTTP (SSE and Streamable transports) and accepts custom HTTP headers for authentication or other purposes.newRemoteClientare stored in the struct but never applied to HTTP requests sent to the remote MCP server.remoteMCPClient.headersfield, but thecreateHTTPClientmethod creates an HTTP client that ignores these headers. Expected behavior is that all HTTP requests to the MCP server should include these custom headers.Code with bug
In
pkg/tools/mcp/remote.go: