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
- Codex tip: use Sol with Astra and Luna sub-agents to save usage — pvncher · 2026-09-11
- agents-best-practices: a provider-neutral Agent Skill for designing and auditing agentic harnesses — tom_doerr · 2026-09-11
- Cognition's SWE-2 uses a KKT duality argument in RL to shift the effort Pareto curve — YouJiacheng · 2026-09-11
- First-ever Three.js Conference lands in Paris, with a panel on AI-shortened design workflows — OdinLovis · 2026-09-11
- Data engineering, not agent frameworks, is the real bottleneck for enterprise AI agents — dhruv2038 · 2026-09-11
- RTK Terminal Compression Cuts Tokens but Leaves Your AI Coding Bill Unchanged — Bartaseth · 2026-09-11