Evaluate tool calls before they run.
Guard checks tool blocklists, egress rules, file path controls, PII in args, capability fallback, and default action handling.
TrapDefense focuses on one narrow but important layer: controlling risky tool use, protecting sensitive outputs, and keeping audit trails for tool-using AI agents. This page is the fastest way to understand the runtime model without digging through internal design notes.
TrapDefense does not try to be a full AI safety platform. It stays focused on runtime checks that matter when an agent is about to act or has just produced sensitive output.
Guard checks tool blocklists, egress rules, file path controls, PII in args, capability fallback, and default action handling.
AuditLogger writes structured JSONL events for scanner findings, before_tool and after_tool decisions, redaction, and errors.
Scanner is intentionally lightweight. It detects hidden text, HTML comments, metadata payloads, base64 instructions, and prompt injection keywords as a first-pass filter.
The policy model is intentionally small so teams can understand and tune it quickly during early rollout.
| Setting | Purpose | Example |
|---|---|---|
mode |
Choose rollout behavior: observe, warn, or enforce. | shadow, warn, enforce |
domain_allowlist |
Define allowed outbound URL or email destination domains. | ["api.internal.com"] |
block_egress |
Turn outbound domain checks on for URLs and email recipients. | true |
file_path_allowlist |
Limit tools to approved file system paths. | ["/tmp/safe"] |
tool_blocklist |
Hard-block named tools before all other policy checks. | ["rm_rf"] |
pii_action |
Control how PII in args or results is handled. | off, warn, block |
capability_policy |
Fallback policy for capability-tagged tools. | {"shell_exec": "block"} |
default_action |
Final fallback when no specific policy matched. | warn |
MCP is a strong starting point because the tool boundary is clear. TrapDefense keeps Guard synchronous and wraps only the MCP handler with a lightweight async decorator.
pip install agent-runtime-security[mcp]
Use from asr.mcp import mcp_guard. The MCP adapter
is optional and stays out of the base dependency path.
audit is configured.A clear boundary makes the SDK easier to adopt and easier to trust.
TrapDefense Enterprise is the next layer for teams that want shared policy workflows, audit operations, and onboarding support around agent runtime controls.