modelcontextprotocol / modelcontextprotocol/servers
Filesystem MCP server modified .env without permission and did not back it up
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 90.5k
- Forks
- 11.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 5
Description
Describe the bug
Claude Desktop (via the Filesystem MCP server) modified my .env file without consent when I asked a question about a Docker-related ConnectionRefusedError. It tried to “fix” a Tortoise ORM connection string issue by overwriting my file using the write_file command. However, it didn’t even read the .env file before modifying it, nor did it back it up. This led to loss of important config data I hadn’t committed.
To Reproduce
Steps to reproduce the behavior:
-
Ask Claude (with the MCP server using filesystem) a question involving Docker and a Tortoise ORM connection string error.
-
Claude tries to “fix” it automatically using write_file, modifying .env directly.
-
File is overwritten without confirmation or backup.
Expected behavior
Claude or the MCP server should:
-
Never modify important user files like .env without explicit confirmation.
-
At minimum, back up the original file before overwriting.
Logs
Error I originally asked about:
/Users/gpt/projects/rustapp/mcp-linker-api/docker-compose.yml
ConnectionRefusedError: [Errno 111] Connection refused
Claude’s attempted “fix”:
# Creates a .env file with a guessed Tortoise ORM connection string
Additional context
This issue could lead to silent data loss in projects where .env is not committed. Claude needs user confirmation step before file operations via MCP servers like filesystem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue identifies the Filesystem MCP server and its write_file command, but names no source file or test. Start by locating the write_file handling and tracing how file-operation requests are processed. Done means the reported overwrite scenario is prevented unless explicitly confirmed, with the expected protection against losing the original .env contents verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100