| Crates.io | toolcap |
| lib.rs | toolcap |
| version | 0.1.0 |
| created_at | 2025-12-28 19:02:44.992067+00 |
| updated_at | 2025-12-28 19:02:44.992067+00 |
| description | A library for specifying tool use permissions in agentic applications. |
| homepage | |
| repository | https://github.com/dherman/toolcap |
| max_upload_size | |
| id | 2009273 |
| size | 212,738 |
A library for specifying tool use permissions in agentic applications.
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.
use toolcap::{Ruleset, Rule, Matcher, Outcome};
let ruleset = Ruleset::new(vec![
// Allow read-only git commands
Rule::new(
Matcher::command("git").with_subcommands(["status", "log", "diff"]),
Outcome::Allow,
),
// Deny destructive commands
Rule::new(
Matcher::command("git").with_subcommand("push"),
Outcome::Deny,
),
]);
// Evaluate a command
let op = Operation::execute("git status");
assert_eq!(ruleset.evaluate(&op), Outcome::Allow);
The repo includes an example ACP proxy (toolcap_proxy) to provide automatic permission handling for Claude Code in Zed.
Install sacp-conductor (version 9.0.0+):
cargo install sacp-conductor --force
Build the example proxy:
cargo build --release --example toolcap_proxy --features="acp matchers"
Add to ~/.config/zed/settings.json:
{
"agent_servers": {
"Claude Code (with default permissions)": {
"type": "custom",
"command": "/path/to/home/.cargo/bin/sacp-conductor",
"args": [
"--debug",
"agent",
"/path/to/toolcap/target/release/examples/toolcap_proxy",
"npx -y '@zed-industries/claude-code-acp'"
]
}
}
}
The proxy includes a default ruleset:
Allows (auto-permitted):
status, log, diff, show, blame, branch, tag, remote, describe, rev-parse, ls-files, ls-tree, cat-file, shortlog, annotatebuild, check, test, clippy, fmt, doc, tree, metadatalist, view, search, audit, outdated, lsls, cat, head, tail, grep, rg, find, wc, pwd, which, echo, printfbuild, test, vet, fmt, modmake, tsc, node, npxDenies (auto-blocked):
push, reset, rebase, force-pushsudo, su, chmod, chown, rm -rf, rm -r, mkfs, ddcurl, wget, nc, netcatThe conductor chain is:
Zed (Client) <-> sacp-conductor <-> toolcap_proxy <-> claude-code-acp (Agent)
request_permission requests from the agentAdd --debug to the conductor args to create timestamped log files:
"args": ["--debug", "agent", ...]
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|), logical operators (&&, ||)command(), with_subcommand(), with_flag(), and(), or()within_directory()MIT