Developer test: naive MCP file tool leaked .env secrets on 4 of 6 adversarial inputs

A hands-on experiment posted to dev.to puts numbers on a risk many agent builders suspect but rarely measure. The author built three versions of a Model Context Protocol (MCP) file-reading server: a naive one, one with checks, and one prone to crashing. Each was exercised over real stdio JSON-RPC, the way an agent host would call it. On six adversarial inputs, the naive tool returned contents of a .env secrets file four times.
The attacks were mundane path tricks: relative traversal, alternate path spellings and similar inputs that a model can be coaxed into emitting through prompt injection. Because MCP tools run with the host user's file permissions, any agent that can be steered into requesting a sensitive path effectively gets it. The fix, roughly ten lines of canonicalizing paths and enforcing an allowed root, closed most of the leaks.
The finding lands in a week full of agent-security news: JFrog's ARTEX agent poisoning Hugging Face, Microsoft pulling its Agent Framework repo offline, and AWS shipping ID-JAG authorization and MicroVM sandboxes for agent code. Together they suggest the bottleneck is less model capability than the plumbing agents touch.
This is a single developer's small-sample test, not a survey of production MCP servers. Still, the lesson generalizes: community MCP servers vary widely in quality, and hosts should assume tools are only as safe as their input validation. Expect more calls for sandboxed MCP execution and signed, audited server registries.