[BUG] MCP headers with environment variable substitution not being sent from .mcp.json
Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Aug 20, 2025 · 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
- Set environment variables: export MCP_TOKEN="token-value" and export MCP_USER_ID="user-id"
- 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}"
}
}
}
}
}
- Connect to MCP server via /mcp command
- 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
6 Comments
For what it's worth - I'm also having this issue on a Mac when trying to use the new plugin system.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
this issue still persists with the latest version in mac.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.