[BUG] claude mcp add -e API_KEY=xxx my-server -- npx my-mcp-server fails
Resolved 💬 3 comments Opened Apr 10, 2026 by Pike Closed May 24, 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 trying to add a local MCP via
claude mcp add -e API_KEY=xxx my-server -- npx my-mcp-server
I get the following
Invalid environment variable format: my-server, environment variables should be added as: -e KEY1=value1 -e KEY2=value2
Just
claude mcp add my-server -- npx my-mcp-server
works fine.
The behaviour occurs in 2.1.100 and 2.1.89.
What Should Happen?
When passing environment variables via the CLI, they should be added to ~/.claude.json.
Error Messages/Logs
claude -d --verbose mcp add -e API_KEY=xxx my-server -- npx my-mcp-server
Invalid environment variable format: my-server, environment variables should be added as: -e KEY1=value1 -e KEY2=value2
Steps to Reproduce
claude mcp add -e API_KEY=xxx my-server -- npx my-mcp-server
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.100
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗