mcpServers config gets corrupted with nested "mcpServers" key in ~/.claude.json
Resolved 💬 1 comment Opened May 14, 2026 by V-dev-388 Closed Jun 12, 2026
Bug Report: Claude Code corrupts global mcpServers config in ~/.claude.json
Summary
Claude Code 2.1.133 incorrectly creates a nested mcpServers.mcpServers key inside the global mcpServers object when writing ~/.claude.json at session end, causing MCP config parsing errors in subsequent sessions.
Environment
- Claude Code version: 2.1.133
- OS: macOS 13 (Darwin 22.6.0)
- Shell: zsh
Steps to Reproduce
- Configure a user-level MCP server in
~/.claude.json:
"mcpServers": {
"PaddleOCR-VL": {
"command": "uvx",
"args": ["--from", "paddleocr-mcp", "paddleocr_mcp"],
"env": { ... }
}
}
- Use Claude Code normally in a project that has
"mcpServers": {}in its project entry under theprojectsobject. - End the session. Claude Code atomically writes
~/.claude.json. - Start a new session →
/doctorshows:
[Failed to parse] User config (available in all your projects)
Location: /Users/davidyao/.claude.json
└ [Error] mcpServers.mcpServers: Does not adhere to MCP server configuration schema
Observed Behavior
After session end, ~/.claude.json contains BOTH the correct flat entry AND a nested mcpServers key:
"mcpServers": {
"PaddleOCR-VL": { ... },
"mcpServers": {
"PaddleOCR-VL": { ... }
}
}
Root Cause Hypothesis
The projects object in ~/.claude.json contains per-project entries that each have their own "mcpServers": {} key. Claude Code's config serializer appears to incorrectly deep-merge a project's mcpServers key INTO the global mcpServers object during serialization, rather than keeping them at separate levels.
Reproducibility
- Reproduced across 4+ sessions
- Backup files in
~/.claude/backups/also show the corruption - Debug log confirms two sequential writes to
.claude.jsonat session end, with the second write (larger file size) corrupting the structure
Impact
- MCP servers are unavailable in all projects until the file is manually fixed
- Error message appears every session
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗