Claude Code rewrites .mcp.json and strips env configuration
Resolved 💬 3 comments Opened Jan 18, 2026 by jordandm Closed Jan 21, 2026
Description
When opening a project with an .mcp.json file that contains an env block, Claude Code appears to rewrite the file and strip the env section.
Steps to Reproduce
- Create a project with this
.mcp.json:
{
"mcpServers": {
"agency": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "claude/claude-desktop/agency-server/index.ts"],
"env": {
"PROJECT_ROOT": "${workspaceFolder}"
}
}
}
}
- Open the project in Claude Code
- Check the file - the
envblock has been removed:
{
"mcpServers": {
"agency": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "claude/claude-desktop/agency-server/index.ts"]
}
}
}
Expected Behavior
Claude Code should not modify .mcp.json files, or if it does normalize them, it should preserve all configuration including the env block.
Actual Behavior
The env configuration is stripped from the file, breaking MCP servers that rely on environment variables.
Evidence
Git diff showing the unwanted modification:
diff --git a/.mcp.json b/.mcp.json
index 3f1de26..902cd1b 100644
--- a/.mcp.json
+++ b/.mcp.json
@@ -3,10 +3,7 @@
"agency": {
"type": "stdio",
"command": "npx",
- "args": ["tsx", "claude/claude-desktop/agency-server/index.ts"],
- "env": {
- "PROJECT_ROOT": "${workspaceFolder}"
- }
+ "args": ["tsx", "claude/claude-desktop/agency-server/index.ts"]
}
}
}
Impact
- MCP servers that need environment variables (like
PROJECT_ROOTorworkspaceFolder) fail to work correctly /doctorreports:[Warning] [agency] mcpServers.agency: Missing environment variables: workspaceFolder- Users may not realize the config was modified and spend time debugging
Environment
- Claude Code version: 2.1.12
- Platform: macOS (Darwin 25.2.0)
Workaround
Run git restore .mcp.json to restore the original file after opening the project.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗