[BUG] `mcp add` replaces env var names with actual env var value
Resolved 💬 4 comments Opened Nov 11, 2025 by dfaivre-pcs Closed Jan 12, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When I run claude mcp add playwright --scope project -- npx @playwright/mcp@latest it replaces this:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "${PLU_CONTEXT7_API_KEY}"
}
},
...
with:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "ACTUAL-API-KEY-VAL"
}
},
...
What Should Happen?
It should keep existing mcp configs the same
Error Messages/Logs
Steps to Reproduce
- Create .mcp.json
- Add a MCP that uses env var substitution
- use
claude mcp addto add another mcp server - .mcp.json - previous mcp server replaces env var name with actual value
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.37
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗