[BUG] /doctor falsely reports valid .mcp.json as 'not a valid JSON'
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
- Create a valid
.mcp.jsonin 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"
}
}
}
}
- Start a Claude Code session — the MCP server connects and all tools work correctly
- 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— validpython3 -c "import json; json.load(open('.mcp.json'))"— validnode -e "JSON.parse(require('fs').readFileSync('.mcp.json', 'utf8'))"— validfile .mcp.json→JSON 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
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗