[BUG] /doctor falsely reports valid .mcp.json as 'not a valid JSON'

Resolved 💬 4 comments Opened Mar 2, 2026 by materemias Closed Mar 31, 2026

Bug description

/doctor reports [Error] MCP config is not a valid JSON for a perfectly valid .mcp.json file, even though the MCP server defined in it loads and works correctly.

Reproduction steps

  1. Create a valid .mcp.json in the project root:
{
  "mcpServers": {
    "my-server": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "SOME_VAR",
        "some/image",
        "-t",
        "stdio"
      ],
      "env": {
        "SOME_VAR": "https://example.com"
      }
    }
  }
}
  1. Start a Claude Code session — the MCP server connects and all tools work correctly
  2. Run /doctor

Expected behavior

/doctor should report the MCP config as valid, since it is valid JSON and the server loads successfully.

Actual behavior

[Failed to parse] Project config (shared via .mcp.json)
 Location: /home/user/project/.mcp.json
  └ [Error] MCP config is not a valid JSON

Validation

The file passes validation with all standard JSON parsers:

  • jq . .mcp.json — valid
  • python3 -c "import json; json.load(open('.mcp.json'))" — valid
  • node -e "JSON.parse(require('fs').readFileSync('.mcp.json', 'utf8'))" — valid
  • file .mcp.jsonJSON text data (UTF-8, no BOM)
  • No trailing commas, no comments, Unix line endings, no hidden characters

The MCP server defined in the config works correctly — all tools are available and functional. Only /doctor reports the error.

Investigation

Traced the error to the internal h3H function which reads the file and parses it with an internal JSON parser (i1). The parser returns falsy for this valid JSON, triggering the error path. This appears to be a false positive in the diagnostic check only — the actual MCP config loading path works fine.

Environment

  • Claude Code version: 2.1.63
  • Platform: Linux (Arch Linux, kernel 6.18.9)
  • Shell: zsh

View original on GitHub ↗

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