Open-source middleware for Node.js

Your AI agents are spending money.
Who's watching?

ActionFence is an AI action firewall that sits in front of your MCP servers and APIs. One JSON policy. Spend caps. Signed receipts. Zero trust by default.

README

Install ActionFence locally in one command.

npm install actionfence

Agents can book flights, delete databases, and drain your Stripe balance — often before you even know it happened.

01

Runaway Spending

An agent told to "book the best flight" books 200 hotel rooms instead. Per-call limits aren't enough — smart agents fragment $500 into 100 × $5 transactions.

02

No Audit Trail

"Who authorized this $2,300 charge?" Without cryptographic receipts, you have no proof of what happened, when, or why.

03

Honor-System Security

Most "AI safety" tools rely on the agent behaving correctly. Client-side enforcement is a suggestion, not a guarantee.

Integration path

One line of code.
Three layers of defense.

ActionFence turns a normal tool call into a governed decision with proof attached.

3D tablet displaying JSON policy code

Define your policy

Write the allowlist, spend limits, identity tier, and rate windows in guard-policy.json.

Tilted glossy 3D shield

Wrap your server

withGuard() and guard() intercept tool calls before handlers run, then evaluate policy on your server.

Two glossy 3D chain links

Every decision is receipted

Store hash-chained, HMAC-signed receipts in SQLite or PostgreSQL for every allow and block.

Everything you need to govern AI actions. Nothing you don't.

01
Policy Setup

Define guardrails before any tool call can execute.

Glossy 3D code braces

JSON Policy Engine

Declarative rules in guard-policy.json for allow, deny, identity, and spend caps. Supports wildcard matching (book_*) and hot-reload.

Glossy 3D ID badge

Identity & JWT Verification

Three tiers: anonymous → token → verified, with built-in JWKS verification.

02
Runtime Enforcement

Enforce spend, pace, and approvals while requests are live.

Glossy 3D dollar sign with shield

Multi-Layer Spend Caps

Per-action, session, daily, rolling window, and global circuit-breaker caps catch fragmented micro-spending that per-call limits miss.

Glossy 3D stopwatch

Rate Limiting

Sliding-window rate limiting with per-agent tracking to stop runaway loops.

Glossy 3D raised hand

Human Approval Webhook

Pause high-value actions for human approval via onApprovalRequired with a 30-second timeout.

03
Oversight & Recovery

Keep a verifiable trail and catch silent control-plane drift.

Glossy 3D chain with receipt tag

Signed Receipt Chain

Cryptographic proof of every decision with HMAC-SHA256 signatures and hash-chain continuity.

Glossy 3D magnifying glass inspecting a schema

Schema Drift Detection

Pin tool schemas with SHA-256 hashes and alert when MCP tool definitions silently change.

Glossy 3D lab flask

Simulation Mode

Dry-run policy outcomes and spend impact before anything executes for real.

60 seconds to integrate. We mean it.

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { withGuard } from 'actionfence';

const server = new McpServer({ name: 'my-server', version: '1.0.0' });

// One line. That's the entire integration.
withGuard(server, {
  policy: './guard-policy.json',
  identityReaderOptions: {
    jwksUri: 'https://issuer.example/.well-known/jwks.json',
    issuer: 'https://issuer.example',
    audience: 'bookflight-mcp',
  },
});

// Register tools as normal — ActionFence wraps them automatically
server.registerTool('book_flight', {}, async () => {
  return { content: [{ type: 'text', text: 'Booked!' }] };
});

Server-side enforcement. Not a client-side suggestion.

How Others Do It
  • [X]Client-side checks can be bypassed or skipped
  • [X]Rules can drift across services and environments
  • [X]"Please don't do bad things" approach
  • [X]No consistent deny-by-default behavior
How ActionFence Does It
  • [+]One policy gate executes before every tool handler
  • [+]Agent never sees guard-policy.json
  • [+]All tool calls must pass through middleware
  • [+]Blocked requests never reach execution code
  • [+]Default rule: deny. Allowlist only.
AI Agent
ActionFence
MCP Tools
APIs

Zero-Trust Architecture

Policy lives entirely on your server. Agents cannot bypass the middleware, read theguard-policy.json, or tamper with the cryptographic receipt chain.

Every decision leaves a cryptographic trail.

When someone asks who approved what, when, and under which policy, the receipt chain gives a verifiable answer.

Hash-chained

Each receipt references the previous one, so edits or deletions break continuity immediately.

HMAC-SHA256 signed

Every decision record is signed, and tampering fails verification on replay.

Append-only

History grows forward only; no record updates and no silent rewrites.

Verifiable

ReceiptStore.verifyChain() can validate the full timeline in a single integrity pass.

Redactable

Sensitive fields can be removed for storage while preserving decision integrity.

Proof captured. Next step: install and enforce.

Receipt #a1b2c3d42026-05-07T14:02:11Z
Agent:agt_7x9f2k
Action:book_flight
Status:[+] ALLOWED
Spend:$250.00
Payload Hash:0x8f3a9...
Prev Hash:0x7e2d4...
Signature:0x4f9b8...
Receipt #e5f6g7h82026-05-07T14:05:32Z
Agent:agt_7x9f2k
Action:delete_db
Status:[-] BLOCKED
Spend:$0.00
Payload Hash:0x1c9e2...
Prev Hash:0x8f3a9...
Signature:0x2a1f0...

Built for anyone giving AI agents real-world permissions.

[ UC_01 ]

MCP Server Developers

You build MCP tools that book flights, manage calendars, or query databases. ActionFence ensures no agent overspends, over-queries, or accesses unauthorized tools.

[ UC_02 ]

API Providers

Your REST API is consumed by AI agents. Drop in guard() middleware to enforce spend caps, rate limits, and identity checks on every request — without changing your route handlers.

[ UC_03 ]

Enterprise / Compliance

You need an audit trail for every AI-initiated action in your system. Signed receipts provide tamper-evident proof for compliance, incident response, and regulatory reporting.

[ UC_04 ]

Solo Developers

You're one person shipping an MCP server. npm install actionfence. Write a policy. Done. No enterprise gateways. No container networking. No vendor lock-in.