Active policy enforcement proxy for MCP servers.
Redacts PII. Enforces limits. Filters fields. Controls tools. Generates audit logs.
Powered by vurb.ts β The Express.js for MCP Servers.
Raw MCP servers send everything to the LLM β passwords, API keys, internal database fields, unbounded arrays. There is no built-in way to enforce security or efficiency policies.
mcp-firewall wraps any MCP server as a transparent sidecar proxy and enforces 7 configurable rules on every response. No code changes required.
Client (Cursor) ββstdinβββΆ mcp-firewall ββstdinβββΆ Raw MCP Server
βββstdoutββ βββstdoutββ
β
ββββββββ΄βββββββ
β Policy Engine β β firewall.yaml
β 7 Rules β
β Audit Log β
βββββββββββββββ
npx @mcp-firewall/enforce --initThis creates a firewall.yaml in your current directory with sensible defaults.
npx @mcp-firewall/enforce -- node dist/server.jsThat's it. The firewall is now active.
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["@mcp-firewall/enforce", "--", "node", "dist/server.js"]
}
}
}With a custom policy:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": [
"@mcp-firewall/enforce",
"--policy", "./strict.yaml",
"--", "node", "dist/server.js"
]
}
}
}| # | Rule | What it does | Default action |
|---|---|---|---|
| 1 | PII Redaction | Replaces sensitive field values with [REDACTED] |
redact |
| 2 | Payload Size | Enforces max response size (default 50KB) | truncate |
| 3 | Row Limit | Truncates arrays to max N items (default 50) | truncate |
| 4 | Field Filter | Allowlist/blocklist fields from responses | blocklist |
| 5 | Tool Access | Allowlist/blocklist which tools the LLM can call | β |
| 6 | Rate Limiting | Max N calls per tool per minute (default 60) | block |
| 7 | Secret Detection | Detects API keys, tokens, and secrets via regex | redact |
Each rule supports configurable actions: redact, block, truncate, or warn.
version: 1
rules:
pii:
action: redact
fields: [password, secret, token, ssn, credit_card, cpf, cnpj]
censor: "[REDACTED]"
payload:
maxBytes: 51200 # 50KB
action: truncate
rows:
maxItems: 50
action: truncate
fields:
mode: blocklist
blocklist: [_id, __v, tenant_id, created_at, updated_at, deleted_at]
tools:
blocklist: [] # tool names to block
allowlist: [] # if set, only these tools are allowed
rateLimit:
maxCallsPerMinute: 60
action: block
secrets:
patterns:
- "sk-[a-zA-Z0-9]{20,}" # OpenAI keys
- "ghp_[a-zA-Z0-9]{36}" # GitHub tokens
- "AKIA[A-Z0-9]{16}" # AWS access keys
action: redact
audit:
enabled: true
path: ./mcp-firewall.audit.jsonlWhen audit.enabled is true, mcp-firewall writes a structured JSONL file with every enforcement action:
{
"timestamp": "2026-03-24T23:15:00.000Z",
"toolName": "users.list",
"messageId": 14,
"verdicts": [
{ "rule": "pii", "action": "redacted", "severity": "critical", "title": "PII REDACTED β 2 field(s)" }
],
"bytesBefore": 84200,
"bytesAfter": 12400,
"blocked": false
}This enables compliance workflows for SOC 2, HIPAA, and GDPR.
npx @mcp-firewall/enforce [options] -- <command> [args...]
Options:
--policy <file> Path to firewall.yaml (default: ./firewall.yaml)
--init Generate a default firewall.yaml
--quiet Only show blocked actions and session summary
--json Output enforcement log as JSON to stderr
-h, --help Show help
import {
enforce,
loadPolicy,
applyPiiRule,
applySecretsRule,
buildSessionSummary,
} from '@mcp-firewall/enforce';
// Load and customize policy
const policy = loadPolicy('./firewall.yaml');
// Enforce rules on a JSON-RPC message
const result = enforce(message, policy, 'users.list');
if (result.blocked) {
console.error('Response blocked:', result.verdicts);
}mcp-firewall enforces policies externally β wrapping any MCP server.
With vurb.ts, these protections are built into your server code: Presenters handle field filtering, PII redaction, row limits, and TOON encoding natively. Zero-config, zero-bypass.
npm install @vurb/core| Capability | mcp-firewall | vurb.ts |
|---|---|---|
| PII redaction | β (field name heuristics) | β
(schema-aware, fast-redact) |
| Payload optimization | β (truncation) | β (TOON encoding, 90%+ savings) |
| Field filtering | β (allowlist/blocklist) | β (Presenter schema) |
| Row limits | β (array truncation) | β
(.limit() with pagination) |
| Secret detection | β (regex patterns) | β (built-in DLP engine) |
| Audit logging | β (JSONL file) | β (Telemetry events) |
See CONTRIBUTING.md for guidelines on adding new rules and submitting pull requests.
See SECURITY.md for vulnerability reporting and the security model.
Apache-2.0 β Β© 2026 Vinkius Labs