Free npm package

Guard your agent's tool calls before they run.

affixio-agent-guard is a free, zero dependency npm package that checks every LLM tool call against policy before execution. Unknown tool, unsafe host, over-limit amount or leaked secret: denied, with a local receipt and a plain reason. No API key, no network, about five lines of code.

0Runtime dependencies
0API keys needed
5Lines to integrate
Yes or noBefore the tool runs

Why it exists

Agent demos ship with an open door.

Most agent demos give the model a wildcard allowlist and hope for the best. One prompt injection later the model is calling a payments tool, exfiltrating a key it found in an argument, or contacting a host nobody approved. The OWASP Top 10 for MCP servers names this class of failure directly, and tool poisoning plus confused deputy attacks on MCP tool descriptions keep turning up in the wild.

The fix that actually holds is boring: decide before the call, from a policy you wrote, in your own process. affixio-agent-guard does exactly that. It is the free, local-first gate you put between the model and the tool, and the shortest possible introduction to how AffixIO treats verification: a yes or no, with evidence, before anything moves.

MCP security teams

Enforce an allowlist on every named tool call before your MCP server runs the handler. Stop tool poisoning at the point of execution.

Agent payment limits

Cap what an autonomous agent can spend per call with maxAmount. Refunds and high value tools sit behind requireApprovalFor.

Secret leak prevention

Key prefixes like sk_live_ and AKIA inside tool arguments are a leak in progress. blockedSecrets stops the call and names the pattern.

What it blocks, and what it lets through

  • Tool not in allowedTools, including unknown or invented tools
  • Host not in allowedHosts, so a redirected endpoint never sees the call
  • Amount above maxAmount, so an agent cannot overspend in one call
  • A blocked secret pattern inside the arguments, such as sk_live_ or AKIA
  • Tool listed in requireApprovalFor, denied until a human approves it
  • Tool inside the allowlist, host approved, amount inside the cap, arguments clean

Every decision, allowed or denied, produces a receipt: timestamp, decision, reason and the SHA-256 hash of the canonical request. Hashing uses Node crypto only. Receipts are written to disk as JSON so your agent logs hold something you can audit.

Copy and run

Five lines, then your agent is gated.

Install from npm and wire the guard into whatever runs your tools. Works in any Node 20 or later project, with or without TypeScript.

npm install affixio-agent-guard
// before your agent executes any tool call
import { createGuard } from 'affixio-agent-guard';

const guard = createGuard({
  allowedTools: ['payments.create', 'crm.lookupCustomer'],
  allowedHosts: ['api.example.com'],
  maxAmount: 500,
  blockedSecrets: ['sk_live_', 'AKIA'],
  requireApprovalFor: ['payments.refund']
});

const d = guard.check({ tool: 'payments.create',
  host: 'api.example.com', amount: 120, args: { customer: 'cust_42' } });
// d.allowed is false on any policy violation, with d.reason explaining why

Prefer to see it working first? The CLI ships in the package and runs an allowed call plus a denied call carrying a fake secret, writing both receipts locally:

npx affixio-agent-guard demo

Where a local guard ends

Clear limits, stated plainly. This package is a developer demo and a trust building block, not a compliance control. Receipts are simulations: a local JSON file with a request hash, not a signed attestation. The guard decides, your runtime enforces. It verifies nothing about who is on the other end of the tool.

When an agent moves real money or touches regulated data, upgrade the simulated receipt to an AffixIO proof. The same policy shape runs in production through the affixio SDK on your host, returning a signed yes or no with an ML-DSA-65 attestation and audit evidence on the AffixIO verification path. Nothing about your integration changes, the receipt simply becomes bound to something stronger than your disk.

Related reading: AI agent safety covers the full verification checkpoint model, the AI model usage policy gate applies the same before-execution pattern to model calls, and AffixIO MCP documents the governed tool surface for production agents.

Questions

Do I need an API key?
No. The guard runs entirely inside your Node process with zero dependencies. Nothing leaves your machine and the package never calls a network service.
Is the receipt a cryptographic attestation?
No. The local receipt records the decision, the reason and the SHA-256 hash of the request. It is a simulation for development. Production enforcement uses AffixIO ML-DSA-65 signed proofs on api.affix-io.com.
What does the guard block?
Any tool outside allowedTools, any host outside allowedHosts, any amount above maxAmount, any argument containing a blocked secret pattern, and any tool listed in requireApprovalFor. It fails closed with a reason string and a receipt.
Does it work with MCP servers?
Yes. The guard checks any named tool call, so MCP style names such as payments.create work directly. Call checkToolCall before your MCP server executes the handler.
How do I install it?
Run npm install affixio-agent-guard, then create a policy object and pass it to createGuard. The whole integration is about five lines. Try npx affixio-agent-guard demo for a working example.

Get it on npm Browse all tools AI agent safety