Skip to content

[BUG] MCP headers with environment variable substitution not being sent from .mcp.json #6204

@allurefx

Description

@allurefx

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other: MCP
  • Claude CLI version: Claude Code v1.0.85
  • Operating System: WSL on Windows 11
  • Terminal: bash

Bug Description

When configuring an MCP server in .mcp.json with headers that use environment variable substitution, Claude Code is not sending these headers to the MCP server.

Steps to Reproduce

  1. Set environment variables: export MCP_TOKEN="token-value" and export MCP_USER_ID="user-id"
  2. Configure .mcp.json:
  {
    "mcpServers": {
      "df-core": {
        "transport": {
          "type": "http",
          "url": "http://localhost:8002",
          "headers": {
            "x-mcp-token": "${MCP_TOKEN}",
            "x-mcp-user-id": "${MCP_USER_ID}"
          }
        }
      }
    }
  }
  1. Connect to MCP server via /mcp command
  2. Server logs show headers are not received

Expected Behavior

Headers should be sent with environment variables expanded

Actual Behavior

No custom headers are sent (confirmed via server debug logs)

Additional Context

  • Environment variables are properly set (confirmed via env | grep MCP)
  • Server works correctly when headers are sent via curl
  • Documentation states environment variable substitution is supported in headers

Metadata

Metadata

Labels

area:mcpbugSomething isn't workingplatform:windowsIssue specifically occurs on Windows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions