[BUG] Desktop app does not expand ${VAR} in .mcp.json env block
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?
Environment variable expansion (${VAR}) in .mcp.json works in the CLI but not in the Claude Code Desktop app (Mac). The MCP server receives the literal string ${SOME_API_TOKEN} instead of the resolved value, causing HTTP 401 auth failures.
Environment
- Claude Code version: 2.1.29
- Platform: macOS (Darwin 25.3.0, arm64)
- Shell: zsh
- Desktop app: Claude for Mac
What Should Happen?
${VAR} expansion in .mcp.json should work identically in the Desktop app and CLI, per the [docs](https://code.claude.com/docs/en/mcp#environment-variable-expansion-in-mcp-json). If the variable is defined in both ~/.zshenv and settings.local.json env, it should be available for expansion regardless of how Claude Code is launched.
Error Messages/Logs
Tool 'some_tool_here' execution failed: HTTP 401: Auth method is not supported
Steps to Reproduce
- Set an env var in
~/.zshenv:
export SOME_API_TOKEN="your-token-here"
- Reference it in
.mcp.json:
{ "mcpServers": { "server1": { "type": "stdio", "command": "npx", "args": ["@server1/mcp"], "env": { "API_TOKEN": "${SOME_API_TOKEN}" } } } }
- Launch Claude Code CLI — MCP server starts, auth works, tools available.
- Launch Claude Code Desktop app — MCP server gets literal
${SOME_API_TOKEN}, returns HTTP 401.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude 1.1.9310 (cb30ac) 2026-03-27T17:11:42.000Z
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 ↗