claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] MCP config: cwd field in .mcp.json is completely ignored

Open Valgard opened this issue 2 weeks ago • 0 comments

Environment:

  • Claude Code Version: 2.1.4
  • OS: macOS (Darwin 25.2.0)
  • Installation: Plugin via .claude-plugin/

Bug Description:

The cwd field in .mcp.json is documented in the official plugins reference but is completely ignored when starting MCP servers. The server always starts in the directory where Claude Code was launched.

Expected Behavior:

According to the documentation, the cwd field should set the working directory for the MCP server process.

Actual Behavior:

The cwd field is completely ignored in both forms:

Test 1: With ${CLAUDE_PLUGIN_ROOT} variable

{
  "test": {
    "command": "bash",
    "args": ["-c", "pwd >&2"],
    "cwd": "${CLAUDE_PLUGIN_ROOT}"
  }
}

Result: pwd outputs the launch directory, not the plugin directory.

Test 2: With absolute path

{
  "test": {
    "command": "bash",
    "args": ["-c", "pwd >&2"],
    "cwd": "/Users/username"
  }
}

Result: pwd still outputs the launch directory, not /Users/username.

This proves the field is completely non-functional, not just a variable expansion issue.

Impact:

  • Impossible to create portable plugins that work across different systems
  • Plugin authors cannot access pyproject.toml, .venv, or relative config files
  • Forces ugly, platform-specific workarounds

Current Workaround:

{
  "my-server": {
    "command": "bash",
    "args": [
      "-c",
      "cd \"${CLAUDE_PLUGIN_ROOT}\" && exec uv run my-mcp serve \"$@\"",
      "--"
    ]
  }
}

Request:

Please implement the documented cwd field or remove it from the documentation if it's not planned.

Valgard avatar Jan 11 '26 23:01 Valgard