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
- Webcmd says browser agents waste tokens on navigation, not the actual task — heyshrutimishra · 2026-07-24
- AREX introduces a recursively self-improving deep research agent with inner and outer loops — _reachsumit · 2026-07-24
- A local open-source agent skill flags the rest of your GitHub diff — Saboo_Shubham_ · 2026-07-24
- Stop exposing thousands of tools to agents; use a code sandbox instead — edgestone22 · 2026-07-24
- “Letting Claude read my codebase is basically open-sourcing it,” says developer — _Stocko_ · 2026-07-24
- Roboto Agents adds root-cause analysis that links robot logs to source code — Scobleizer · 2026-07-24