CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

MCP Streamable HTTP transport lacks custom headers support for authentication

Open Oliver-ZPLiu opened this issue 6 months ago • 0 comments

Problem

The McpServerConfig struct has no headers field, so HTTP-based MCP servers that require authentication headers (e.g. Authorization: Bearer <token>, X-API-Key) cannot be configured.

Multiple public MCP services require custom HTTP headers:

Service Required Header
Hugging Face MCP Authorization: Bearer <HF_TOKEN>
GitHub MCP Authorization: Bearer <GITHUB_TOKEN>
Atlassian Rovo MCP Authorization: Basic <base64> or Authorization: Bearer <api_key>
Generic HTTP MCP Authorization: Bearer <token>

This is a standard feature across other MCP clients:

  • Claude Code: mcp.json supports headers field
  • Codex: .codex/config.toml supports env_http_headers
  • OpenCode: opencode.json supports Authorization field

Proposed solution

Add an optional headers: HashMap<String, String> field to McpServerConfig, and pass them through to the StreamableHttpTransport so they are included in every HTTP request to the MCP server.

The config would look like:

{
  "mcpServers": {
    "myserver": {
      "url": "https://api.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${TOKEN}"
      }
    }
  }
}

Oliver-ZPLiu avatar May 11 '26 14:05 Oliver-ZPLiu