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

  1. 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}"
      }
    }
  }
}
  1. Open the project in Claude Code
  2. Check the file - the env block 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_ROOT or workspaceFolder) fail to work correctly
  • /doctor reports: [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.

View original on GitHub ↗

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