[BUG] Incorrect handling of multiple environment variables in MCP server definitions

Resolved 💬 3 comments Opened Apr 22, 2025 by jalehman Closed Dec 7, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • Claude CLI version: 0.2.76 (Claude Code)
  • Operating System: macOS 15.3.1
  • Terminal: iTerm2

Bug Description

Adding an MCP server in the User scope with multiple environment variables causes the later environment variables to be treated as part of the first variable's value.

Steps to Reproduce

  1. claude mcp add
  2. Choose User scope
  3. Choose Stdio
  4. Server command: ENV_A=abcd ENV_B=efgh node /path/to/some/mcp/server.js

Expected Behavior

The definition of the MCP server in ~/.claude.json should be as follows:

{
  ...
  "mcpServers": {
    "some-server": {
      "type": "stdio",
      "command": "node",
      "args": [
        "/path/to/some/mcp/server.js"
      ],
      "env": {
        "ENV_A": "abcd",
        "ENV_B": "efgh"
      }
    }
  }
}

Actual Behavior

The definition of the MCP server in ~/.claude.json is:

{
  ...
  "mcpServers": {
    "some-server": {
      "type": "stdio",
      "command": "node",
      "args": [
        "/path/to/some/mcp/server.js"
      ],
      "env": {
        "ENV_A": "abcd ENV_B=efgh"
      }
    }
  }
}

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗