Environment
Bug Description
Environment variables defined in the env section of claude_desktop_config.json are not being passed correctly to MCP servers, causing servers that require API keys or tokens to fail during initialization. The MCP server crashes because it receives an invalid/empty token instead of the configured environment variable value.
Steps to Reproduce
- Configure an MCP server in
~/Library/Application Support/Claude/claude_desktop_config.json with environment variables:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"MOTHERDUCK_TOKEN"
],
"env": {
"MOTHERDUCK_TOKEN": "actual_token_value"
}
}
}
}
- Restart Claude Desktop
- Try to use the MCP server (or import it to Claude Code using
claude mcp add-from-claude-desktop)
Expected Behavior
The environment variable MOTHERDUCK_TOKEN should be available to the MCP server process with the configured value, and the server should initialize successfully.
Actual Behavior
The MCP server crashes during initialization with authentication errors, indicating it's not receiving the environment variable properly.
Claude Desktop logs (~/Library/Logs/Claude/mcp*.log):
2025-05-23T06:36:31.993Z [info] [mcp-server-motherduck] Client transport closed
2025-05-23T06:36:31.993Z [info] [mcp-server-motherduck] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-05-23T06:36:31.993Z [error] [mcp-server-motherduck] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging)
2025-05-23T06:36:31.993Z [info] [mcp-server-motherduck] Client transport closed
Additional Context
The MCP server works perfectly when run directly from command line:
❯ uvx mcp-server-motherduck --db-path md: --motherduck-token $MOTHERDUCK_TOKEN
[mcp_server_motherduck] INFO - 🦆 MotherDuck MCP Server v0.5
[mcp_server_motherduck] INFO - Ready to execute SQL queries via DuckDB/MotherDuck
[mcp_server_motherduck] INFO - Waiting for client connection...
[mcp_server_motherduck] INFO - Starting MotherDuck MCP Server
[mcp_server_motherduck] INFO - Using MotherDuck token to connect to database `md:`
[mcp_server_motherduck] INFO - Database client initialized in `motherduck` mode
[mcp_server_motherduck] INFO - 🔌 Connecting to motherduck database
[mcp_server_motherduck] INFO - ✅ Successfully connected to motherduck database
Workaround that works:
Hardcoding the token directly in the args array works fine:
{
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"hardcoded_token_here"
]
}
Additional notes:
- I used
claude mcp add-from-claude-desktop to import the configuration to Claude Code
- The issue affects both Claude Desktop and Claude Code when using the same configuration
- I've tried different variations of the env variable syntax but none work
- Not sure if I'm doing something wrong with the configuration format - or even if this is the correct place to report?
Environment
Platform (select one):
Claude CLI version:
1.0.2 (Claude Code)(Claude Desktop: Version 0.9.3)Operating System: macOS
Terminal: Ghostty
Bug Description
Environment variables defined in the
envsection ofclaude_desktop_config.jsonare not being passed correctly to MCP servers, causing servers that require API keys or tokens to fail during initialization. The MCP server crashes because it receives an invalid/empty token instead of the configured environment variable value.Steps to Reproduce
~/Library/Application Support/Claude/claude_desktop_config.jsonwith environment variables:{ "mcpServers": { "mcp-server-motherduck": { "command": "uvx", "args": [ "mcp-server-motherduck", "--db-path", "md:", "--motherduck-token", "MOTHERDUCK_TOKEN" ], "env": { "MOTHERDUCK_TOKEN": "actual_token_value" } } } }claude mcp add-from-claude-desktop)Expected Behavior
The environment variable
MOTHERDUCK_TOKENshould be available to the MCP server process with the configured value, and the server should initialize successfully.Actual Behavior
The MCP server crashes during initialization with authentication errors, indicating it's not receiving the environment variable properly.
Claude Desktop logs (
~/Library/Logs/Claude/mcp*.log):Additional Context
The MCP server works perfectly when run directly from command line:
Workaround that works:
Hardcoding the token directly in the
argsarray works fine:{ "args": [ "mcp-server-motherduck", "--db-path", "md:", "--motherduck-token", "hardcoded_token_here" ] }Additional notes:
claude mcp add-from-claude-desktopto import the configuration to Claude Code