[BUG] .mcp.json env var substitution: unset variables silently suppress trust prompts for ALL servers

Open 💬 1 comment Opened May 27, 2026 by zerschmetterling

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 a project-scoped .mcp.json exists and contains e.g. API-tokens via env substitution, any unset env variable leads to a suppression of the MCP approval prompt.

What Should Happen?

  • Either show a clear error when Claude launches
  • Or (better): prompt for all correctly configured MCP servers, skip the incorrect ones.

Error Messages/Logs

Steps to Reproduce

  1. Make a new directory for a new Claude project
  2. In it, create .mcp.json with content
{
	"mcpServers": {
		"mcp-server-1": {
			"command": "bash",
			"env": {
				"TOKEN_SERVER_1": "${TOKEN_SERVER_1}"
			}
		},
		"mcp-server-2": {
			"command": "bash",
			"env": {
				"TOKEN_SERVER_2": "${TOKEN_SERVER_2}"
			}
		}
	}
}
  1. export TOKEN_SERVER_1=""
  2. Start Claude -> No prompt for any of the configured MCP servers, even the one with token. /doctor shows a warning for unknown env variable, but no way of fixing this.
  3. Stop Claude, export TOKEN_SERVER_2=""
  4. Start Claude -> Prompt appears

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.152

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗