warder 0.1.0

A policy gate for MCP tool calls - blocks destructive AI agent actions before they run
Documentation

The problem

When an engineer points Claude Code or Cursor at a real database, the AI client launches the database tool as a local subprocess on that laptop and talks to it over pipes. There is no network request. The credential is a permanent one, sitting in plaintext in a dotfile:

// ~/.cursor/mcp.json
{ "mcpServers": {
    "postgres": { "command": "mcp-server-postgres",
                  "args": ["--dsn", "postgres://svc:PASSWORD@prod-db:5432/app"] } } }

Every AI-agent gateway on the market — Cloudflare, AWS AgentCore, Azure APIM, Docker, Anthropic's own enterprise connector auth — governs agents that reach tools over the network. None of them can see the above, because there is no packet to inspect. The protocol spec is explicit about it:

"All request metadata for the stdio transport is carried inline in the JSON-RPC message body… There is no header layer." — MCP specification 2026-07-28, stdio transport

So the only place to enforce anything is inside that laptop, as the process the client launches. That is what warder is.

Install

cargo install warder

Use

Point warder at the server you already run. One command:

warder init postgres --patch .cursor/mcp.json -- mcp-server-postgres --dsn "$DSN"
  created  .warder/policy.cedar
  created  .warder/postgres.json
  backup   .cursor/mcp.json.warder-backup
  patched  .cursor/mcp.json

  Restart your AI client. Tool calls now pass through warder.

That rewrites only the postgres entry, leaves your other servers alone, and keeps a backup. Drop --patch and it prints the snippet for you to paste instead.

Now your agent behaves normally — until it doesn't:

→ tools/call  execute_sql  {"sql":"SELECT count(*) FROM users"}
  ALLOW   allow-reads                          27µs
← {"content":[{"type":"text","text":"1,284"}]}

→ tools/call  execute_sql  {"sql":"DROP TABLE users;"}
  DENY    deny-destructive                     23µs
← error -32001  Blocked by warder policy: forbidden by policy (deny-destructive)

The upstream server never receives the second call.

Policy

Plain Cedar. The shipped default is four rules:

@id("allow-reads")
permit(principal, action == Action::"invoke", resource)
when { context.operation_class == "read" };

@id("writes-require-approval")
@advice("require_approval")
permit(principal, action == Action::"invoke", resource)
when { context.operation_class == "write" };

@id("deny-destructive")
forbid(principal, action, resource)
when { context.operation_class == "destructive" };

@id("deny-stacked-statements")
forbid(principal, action, resource)
when { context.signals.contains("multi_statement") };

Cedar is default-deny, so anything warder cannot confidently classify is denied and the audit record says why.

Classification is structural, not keyword matching. String literals and comments are stripped first, which matters more than it sounds:

Statement Class Why
SELECT 'drop table users' AS note read a literal is not a keyword
DELETE FROM audit -- WHERE id = 1 destructive the WHERE is commented out, so nothing bounds it
DROP/*x*/ TABLE users destructive comments do not hide it
SELECT 1; DROP TABLE users; destructive stacked statements escalate
UPDATE users SET x=1 WHERE id=3 write bounded, so it goes to approval
VACUUM FULL unknown denied — warder does not guess

Speed

Every decision is made in-process against a locally cached policy. No database call, no vault round trip, no network. Measured on the shipped policy, 50,000 iterations per case after 2,000 warmup, Apple M3 Pro / macOS 15.7 (cargo run --release --example bench — reproduce it yourself):

p50 p90 p99
read 26.6µs 29.9µs 35.0µs
write 27.0µs 32.1µs 36.4µs
destructive 22.9µs 27.4µs 31.3µs
complex read 27.3µs 32.1µs 36.7µs

A real tool call to a hosted API takes 100–800 milliseconds, so warder adds well under 1% to the end-to-end time.

What else it does

Catches tool poisoning. Warder hashes every tool description and input schema the server advertises, pins it on first sight, and warns when it changes. This matters because peer-reviewed work found tool poisoning to be the most prevalent client-side MCP vulnerability, that five of seven major clients do no validation of server-provided descriptions, and that proxies do not fix it — client-side validation does. Warder is on the client side of that boundary.

Keeps an audit trail you can defend. Every decision records the matched policy, the reason, split timings, and a hash of the arguments. It does not record the arguments themselves unless you explicitly opt in — tool-call arguments are exactly where credentials and personal data live, and a governance tool that hoards them is a liability, not a control. Fail-open and fail-closed are distinct recorded outcomes, so an outage is never indistinguishable from an approval.

Status

Early. Working and tested, but pre-1.0 and missing things you may need:

  • stdio transport only — Streamable HTTP is not implemented yet
  • no credential brokering yet, so keys still live where they live
  • the control plane (control-plane/) is a skeleton: tenancy and decision ingest only

docs/ARCHITECTURE.md is the honest version, including what does not work and why several obvious-looking features were deliberately not built.

Build from source

git clone https://github.com/santosh-singhh/warder && cd warder
make test    # 53 tests: rust unit + e2e, go unit
make demo    # watch a DROP TABLE get blocked, end to end

Contributing

The most useful thing you can send is a statement warder classifies wrongly. See CONTRIBUTING.md.

MIT.