claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

MCP Configuration Unexpectedly Deleted From File During Auto-Update

Open amcaplan opened this issue 5 months ago • 16 comments

Bug Description Claude Code seems to frequently delete my MCP server configuration in ~/.claude.json, and I need to rebuild it from scratch. It's incredibly irritating, as I don't necessarily have offhand the information to recreate the servers, because I don't expect Claude Code to delete it! I suspect it's happening when there's an auto-update, but there isn't really indication of this... I do know that I will also get prompted with some basic setup info (color scheme, trust files, terminal-setup) and then I'll run /mcp and all of a sudden no servers are found.

Otherwise, awesome tool, love you all! ❤

Environment Info

  • Platform: macos
  • Terminal: Apple_Terminal
  • Version: 1.0.17
  • Feedback ID:

Errors

[{"error":"AxiosError: Request failed with status code 401\n    at uH (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:528:1070)\n    at IncomingMessage.wA (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:529:9969)\n    at IncomingMessage.emit (node:events:519:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)\n    at ec.request (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:531:2081)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async qV5 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1945:600)\n    at async Promise.all (index 0)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1931:19563","timestamp":"2025-06-08T11:57:51.449Z"}]

(I think the errors are from the failure to submit a bug report through /bug but aren't related to this)

amcaplan avatar Jun 08 '25 12:06 amcaplan

This happened to me running claude code cli in wsl. Figured I'd provide the additional info. Unbelievable coding agent!!!

bradyounge avatar Jun 11 '25 11:06 bradyounge

Can confirm this has happened to me after an update this morning.

beyondoscar avatar Jun 11 '25 23:06 beyondoscar

Happens to me too, we should be able to kick off @claude on this issue to help them fix it!

doogie-bigmack avatar Jun 13 '25 13:06 doogie-bigmack

Hi, sorry to hear this. Did it just happen randomly during a session?

ashwin-ant avatar Jun 13 '25 13:06 ashwin-ant

I'm having the same issue. To recreate: Start WSL CLI and set up MCP server. Then start new WSL session on another window/tab and it'll be gone.

TrainerHol avatar Jun 15 '25 00:06 TrainerHol

Just had this happen to me too, I thought I was going crazy

I simply opened a new Claude Code session in another tab in WSL. Maybe some concurrency issues, older tab taking over, etc etc?

dinhphieu avatar Jun 15 '25 09:06 dinhphieu

Related - https://github.com/issues/created?issue=anthropics%7Cclaude-code%7C1983

beyondoscar avatar Jun 15 '25 23:06 beyondoscar

Same here!

I had imported the mcp from Claude desktop and fortunately it doesn't delete the config file there.

For anyone suffering this issue, here's at least a quick way to get your mcp working again (IF it's an mcp in claud desktop):

claude mcp remove mcp-name
claude mcp add-from-claude-desktop -s user

# then, pick the mcp from the list

lasergoat avatar Jun 16 '25 21:06 lasergoat

Same here!

I had imported the mcp from Claude desktop and fortunately it doesn't delete the config file there.

For anyone suffering this issue, here's at least a quick way to get your mcp working again (IF it's an mcp in claud desktop):

claude mcp remove mcp-name
claude mcp add-from-claude-desktop -s user

# then, pick the mcp from the list

That's interesting; I assumed this was linux specific. Have done similar in the interim though (saved mcp json body to file and run a bash script to re-add it to config).

beyondoscar avatar Jun 16 '25 23:06 beyondoscar

Can confirm.

Not only lost mcp server configurations but all project data saved inside ~/.claude.json on MacOS 15.5 running Claude Code under zsh+iterm. Claude Code is installed locally under ~/.claude/local. My ~/.claude/settings.json is just an empty obj.

After the problematic update, claude.json contained only:

{
  "autoUpdaterStatus": "migrated"
}

I used a Time Machine backup to get the last working configuration replacing the above, ran claude update where latest version 1.0.25 was confirmed as already installed, started inside a project and it was "back to normal". File size is quite large though:

~|⇒ du -h .claude.json
656K	.claude.json
~|⇒

sdsys-ch avatar Jun 17 '25 14:06 sdsys-ch

OK this is killing me now. Very consistently when a new terminal is opened all existing terminals lose their mcps. Anyone have a workaround?

khairm avatar Jun 18 '25 01:06 khairm

This happened to me today.

I can add back my old ~/.claude.json then run the claude executable and watch the file get deleted again.

But I did figure out why it’s happening.

If you have a JSON error in your config when you run claude, it immediately exits, and shows you this:

Image

However, if you scroll up, you’ll see this:

Image

This is moot at this point, because your config has already been deleted and claude already exited.

It took me about 5 times to realize this dialog was displaying above the prompt in my shell.

tldr, look for an error in your config file

mine was actually a commented out line, which is invalid JSON in most cases! I had forgotten that since vscode allows comments in JSON config files.

also could be root cause of #1983

mculp avatar Jun 19 '25 00:06 mculp

When this happens, are you using multiple Claude Code sessions in different terminal tabs?

ashwin-ant avatar Jun 19 '25 00:06 ashwin-ant

No. Give me a bit and I’ll post a screen recording.

mculp avatar Jun 19 '25 00:06 mculp

@ashwin-ant probably should’ve shown the ps aux at the beginning instead of end, but just trust me, no other claude was running

the configuration error is really hard to notice! (and pointless since claude’s already dead at that point)

https://github.com/user-attachments/assets/09c64fff-9ab4-4476-95b4-0fa08243f13e

mculp avatar Jun 19 '25 00:06 mculp

@mculp thank you, really appreciate the detailed bug report. We have a fix on the way, I'll update this issue once it's released.

ashwin-ant avatar Jun 19 '25 06:06 ashwin-ant

Hey all, this should be fixed in version 1.0.31. Sorry for the delay here, please keep the feedback coming!

ashwin-ant avatar Jun 20 '25 21:06 ashwin-ant

@ashwin-ant just happened to me during update to 1.0.34

mintmcqueen avatar Jun 26 '25 06:06 mintmcqueen

Same here!

I had imported the mcp from Claude desktop and fortunately it doesn't delete the config file there.

For anyone suffering this issue, here's at least a quick way to get your mcp working again (IF it's an mcp in claud desktop):

claude mcp remove mcp-name
claude mcp add-from-claude-desktop -s user

# then, pick the mcp from the list

You saved my life, MCPs dissapeared after todays update too but luckily I also had them in claude desktop

Joe-Simo avatar Jul 01 '25 01:07 Joe-Simo

Is this back? My mcps are wiping every terminal load again (was working fine past few days).

khairm avatar Jul 01 '25 21:07 khairm

Is this back? My mcps are wiping every terminal load again (was working fine past few days).

Every new update claude code wipes all my MCP so im constantly having to have a backup on my claude desktop so I can re-add them

claude mcp add-from-claude-desktop -s user

# then, pick the mcp from the list

Joe-Simo avatar Jul 03 '25 12:07 Joe-Simo

Is it strictly your MCP servers that get wiped, or is it also that you're getting logged out completely? We have a known issue with people getting fully logged out that sometimes occurs when you have multiple Claude sessions running. Is that what you're seeing @josephsimo?

ashwin-ant avatar Jul 03 '25 14:07 ashwin-ant

Is it strictly your MCP servers that get wiped, or is it also that you're getting logged out completely? We have a known issue with people getting fully logged out that sometimes occurs when you have multiple Claude sessions running. Is that what you're seeing @josephsimo?

Everything is fine, then I see on x that there is a new update, I open terminal, type Claude and I'm logged out...I can see an update was made, I login again and all my mcps are gone, everything else including the .md is intact.

Has happened 3 times in a row now, new update, I'm logged out, login and MCPs are wiped.

Joe-Simo avatar Jul 03 '25 18:07 Joe-Simo

Same here, happened multiple times already - after logging out my MCPs get wiped out. 1.0.43 (Claude Code)

eugeneoshepkov avatar Jul 07 '25 07:07 eugeneoshepkov

This just started happening out of the blue for me yesterday on both macOS and Linux.

noops888 avatar Jul 24 '25 10:07 noops888

yea, my MCPs keep disappearing everytime i close and reopen WSL. It remembers my account and other settings tho! The .claude.json file still exists at the same location with the same file content (even including the MCP conf) but claude code doesnt load the MCPs.

Motaphe avatar Jul 28 '25 02:07 Motaphe

Everyday my sub-agents get super confused when I tell them to use MCP. Turns out MCP’s been deleted 😂

blueberry6401 avatar Aug 01 '25 06:08 blueberry6401

My MCPs are getting cleared after several hours. I imported them from claude desktop.

blueberry6401 avatar Aug 01 '25 07:08 blueberry6401

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 08 '25 14:08 github-actions[bot]