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

Resolved 💬 6 comments Opened Aug 20, 2025 by allurefx Closed Feb 7, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [X] 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

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗