A Claude Code user built mcp-guard after an MCP server leaked their .env
TastePrestigious4419 · reddit · 2026-07-24
A Reddit user found that their MCP filesystem server could leak a live .env file to Claude, including AWS keys and a Postgres connection string, simply because the agent asked to inspect a broken config.
They built mcp-guard, a local Go shim that sits between Claude Code and any MCP server to provide defense-in-depth:
- masks secrets on the way back, including API keys, DB passwords, PEM keys, and JWTs
- strips invisible Unicode and defangs common prompt-injection phrasing
- blocks writes to sensitive paths such as /.ssh, .env, .git, and idrsa, even through symlinks
- returns a normal isError so the agent can self-correct
The author is explicit that it is heuristic-based, cannot stop every novel secret format or injection, and cannot monitor a server’s own outbound network calls. Compression is disabled by default to avoid corrupting code edits. Repo: mcp-guard on GitHub.
More from coding & agent
- 250 Builders Hack With Codex at Berlin Community Hackathon Ahead of OpenAI DevDay — paw_lean · 2026-10-26
- Building AI bots on raw APIs? Devs say models are 'dumb without the harness' — madeofAjala · 2026-10-26
- HarnessMM cuts agent tokens per task by up to 88% while raising success rates — omarsar0 · 2026-10-26
- Microsoft demos intent-classifying agents built with Copilot App and Foundry, deployable across Teams and Outlook — marlene_zw · 2026-10-26
- Looking for a wearable mic with best battery life that feeds recordings to personal agents via MCP — altryne · 2026-10-26
- The identity crisis in software engineering: multiagent systems demand a new problem set — rakyll · 2026-10-26