Toolcap
A library for specifying tool use permissions in agentic applications.
Overview
Toolcap provides a ruleset-based system for controlling what operations AI agents can perform. It integrates with the Agent Client Protocol (ACP) to intercept permission requests and automatically allow, deny, or defer to user judgment.
Quick Start
use ;
let ruleset = new;
// Evaluate a command
let op = execute;
assert_eq!;
Example: Preset permissions for Claude Code (via ACP)
The repo includes an example ACP proxy (toolcap_proxy) to provide automatic permission handling for Claude Code in Zed.
Prerequisites
-
Install sacp-conductor (version 9.0.0+):
-
Build the example proxy:
Zed Configuration
Add to ~/.config/zed/settings.json:
The proxy includes a default ruleset:
Allows (auto-permitted):
- Git read-only:
status,log,diff,show,blame,branch,tag,remote,describe,rev-parse,ls-files,ls-tree,cat-file,shortlog,annotate - Cargo:
build,check,test,clippy,fmt,doc,tree,metadata - npm read-only:
list,view,search,audit,outdated,ls - Common tools:
ls,cat,head,tail,grep,rg,find,wc,pwd,which,echo,printf - Go:
build,test,vet,fmt,mod - Build tools:
make,tsc,node,npx
Denies (auto-blocked):
- Destructive git:
push,reset,rebase,force-push - System commands:
sudo,su,chmod,chown,rm -rf,rm -r,mkfs,dd - Network exfiltration:
curl,wget,nc,netcat
The conductor chain is:
Zed (Client) <-> sacp-conductor <-> toolcap_proxy <-> claude-code-acp (Agent)
- toolcap_proxy intercepts
request_permissionrequests from the agent - Evaluates them against the built-in ruleset
- For Allow outcomes: auto-responds with permission granted
- For Deny outcomes: auto-responds with permission rejected
- For Unknown outcomes: forwards to Zed for user decision
Add --debug to the conductor args to create timestamped log files:
"args":
Log format:
C ->= conductor to client0 ->= conductor to component 0 (proxy)0 <-= component 0 to conductor1 ->= conductor to component 1 (agent)1 <-= component 1 to conductor0 !/1 != component stderr output
Features
- Shell parsing: Full POSIX shell command parsing
- Compound commands: Evaluate pipelines (
|), logical operators (&&,||) - Composable matchers:
command(),with_subcommand(),with_flag(),and(),or() - Directory scoping: Restrict rules to specific directory trees with
within_directory() - ACP integration: Direct integration with Agent Client Protocol
License
MIT