[Bug] Claude Code destructively removes env block when rewriting .mcp.json

Resolved 💬 3 comments Opened Mar 21, 2026 by jordan-of Closed Apr 19, 2026

Bug Description
Bug Report: Claude Code Destructively Rewrites .mcp.json, Stripping env Configuration

From: Jordan Dea-Mattson
GitHub: @jordan-of (OrdinaryFolk), @jordandm (personal)
Email: jordan-of@users.noreply.github.com
Previous reports: #18952 (closed as dup of #13281), #13281 (closed as dup of #3321), #3321 (closed as NOT_PLANNED)

Why This Is Being Filed Again

The original report (#18952, filed Jan 2026) was auto-closed by a bot as a duplicate of #13281, which was itself auto-closed as a duplicate of #3321, which was closed as "not planned." No human
reviewed whether these were actually the same issue. They are not:

  • #3321 — ".mcp.json is not read" (read path — config ignored)
  • #13281 — "Manual edits not recognized" (read path — edits ignored)
  • #18952 — "Claude Code rewrites .mcp.json and strips env" (write path — data destroyed)

Our issue is about destructive data loss: Claude Code actively overwrites .mcp.json and removes the env block. This is not the same as "file not read" — the file is read fine, but when Claude Code
writes it back, it drops fields it doesn't understand. The env configuration is silently deleted from disk.

The bot-driven duplicate chain closed a data loss bug as "not planned" by conflating it with a read-path issue. The locked issues prevent us from commenting or reopening.

Steps to Reproduce

  1. Create .mcp.json with an env block:

{
"mcpServers": {
"my-server": {
"type": "stdio",
"command": "npx",
"args": ["my-server"],
"env": {
"API_KEY": "secret",
"PROJECT_ROOT": "${workspaceFolder}"
}
}
}
}

  1. Open Claude Code
  2. Check .mcp.json — the env block is gone

Impact

MCP servers that require environment variables silently break. The user has no indication that their config was rewritten. The env block must be manually re-added after every Claude Code session
that touches MCP configuration.

Expected Behavior

Claude Code should preserve all fields in .mcp.json that it doesn't manage. If it needs to rewrite the file, it should round-trip unknown fields rather than dropping them.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.81
  • Feedback ID: 9bf26a92-1a25-452c-be5e-e6afaf45e7e8

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/jordan_of/.local/share/claude/versions/2.1.81 (expected in multi-process scenarios)\n    at TET (/$bunfs/root/src/entrypoints/cli.js:2724:2174)\n    at fgq (/$bunfs/root/src/entrypoints/cli.js:2724:1318)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-03-21T06:27:37.768Z"}]

View original on GitHub ↗

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