@bzucker42
Brian ZuckerDeveloper▲5
Professional development, Independent
2h ago · edited · Article · Security · Rochester

I built a firewall for my AI agent's tool calls

4 min read

I wanted to leave coding agents running in the background without wondering what they were doing to my database.
The failures that scared me were tool calls: a “cleanup” that became DROP TABLE, a write that resolved outside the project through a symlink, a retry loop hitting the same endpoint hundreds of times. A wrong answer in chat wasn't what I was worried about.

So I built Blastgate and I'm releasing it as open source:
<github.com/bzucker4/blastgate>

Blastgate is a small proxy between an AI agent and its tools. Every MCP tools/call, shell command, or Claude Code tool use is checked against a YAML policy before it runs. The answer is allow, deny, or ask a human. Every decision goes into a hash-chained, Ed25519-signed audit log.

What gets stopped

The default policy covers the things I wanted checked before leaving an agent alone:

  • Blocks DROP TABLE, TRUNCATE, and DELETE without WHERE.
  • Asks before rm -rf and force pushes, including when they're hidden inside an a && b command.
  • Denies reads of ~/.ssh, ~/.aws, and .env.
  • Blocks uploads to webhook, tunnel, and exfiltration services.
  • Keeps writes inside the project.
  • Applies a loop guard to identical calls.

When a call is denied, the agent gets a normal tool result containing the rule and the reason. It usually picks a safer approach rather than crashing or retrying the same thing.

That feedback matters. I want the agent to know which boundary it hit so it can keep working within it.

No model in the decision path

I don't want an LLM judge sitting between an agent and DROP TABLE. Given the same call and the same policy, Blastgate always returns the same answer.

Rule precedence is fixed:
deny > approve > allow > default

Rule order doesn't matter. A matching deny can't be overridden by an allow somewhere else in the file.

Blastgate also fails closed. No terminal available for approval? Deny. Approval webhook down? Deny. Timeout or invalid policy? Deny.

It's zero dependencies and about 1,700 lines. Evaluating a call takes about 10 microseconds at p50. The added time per MCP round trip is about 0.7 ms at p50, mostly from writing the signed audit record.

Watch it before enforcing it

Shadow mode, added in 0.2.0, lets you see what a policy would do before you let it block calls.
Enable it with --shadow or BLASTGATE_MODE=shadow. It evaluates and logs every call exactly as enforce mode would, but blocks nothing and asks for no approvals. Errors still fail closed.

My suggested starting point is to leave it in front of a real agent for a day, then read:

blastgate audit tail

You'll see lines like:

ALLOW $ rm -rf ./build (shadow: would approve)

Read those decisions, then turn enforcement on. You get to see where the policy would interrupt your actual work before dealing with those interruptions.

What I tested with Claude Code

I ran a real test on my machine with Claude Code 2.1.330 and Blastgate 0.2.1 from npm. Here's what happened:

  • cat ~/.aws/credentials was blocked.
  • rm -rf was held for approval.
  • A curl to webhook.site was blocked.
  • SELECT 1 went through to the database server.
  • DROP TABLE was blocked at the Claude Code hook.
  • With hooks turned off, DROP TABLE was blocked again at the MCP proxy.
  • In shadow mode, rm -rf ran and the log recorded “would approve.”

Each time, Claude named the rule and didn't try another way around it. The audit log verified with its chain intact.
There's also a detail in 0.2.1 for calls checked by both the Claude Code hook and the MCP proxy. Both decisions are kept and linked using Claude Code's tool_use_id. In audit tail, the call appears once as via hook+proxy, so you can read it without losing either decision.

Where the boundary ends

Blastgate isn't a kernel sandbox. If you allow npm install, what its install script does is out of view.
The detectors work at the string level. Something like eval $(base64 -d ...) gets past a blocklist. For high-stakes use, use default: deny with explicit allows.

I've documented the limits in docs/threat-model.md. Use Blastgate alongside a container, not instead of one. The policy check only helps with actions it can see and evaluate.

Try it

The quickest way to see it work is:

npx blastgate demo

There's no API key needed. The demo runs a scripted runaway agent against a mock Postgres MCP server through the real proxy. Then it verifies the audit log and shows tampering being detected.

For Claude Code:

/plugin install blastgate --marketplace bzucker4/blastgate

For any MCP server, put this in front of its command:

npx -y blastgate mcp --name <name> -- <server-command> [args...]

Releases are published to npm from GitHub Actions with provenance.
Blastgate is licensed under AGPL-3.0 and is free for local, CI, and internal use. There's a $299/year commercial license for companies building it into closed products.

Try the demo, put it in shadow mode in front of your agent, and send me feedback at <github.com/bzucker4/blastgate>. I especially want bypasses. Each one becomes a test.

MCPClaude CodeSecurityAgents

Comments

No comments yet
Start the conversation.
Log in to join the thread.