ToolPermit
ToolPermit is a local-first permission policy, one-time approval, and redacted audit layer for
Model Context Protocol (MCP) tool calls. Put it between a
local MCP client and a stdio server to observe calls, enforce explainable allow / ask / deny
rules, review exceptional actions, and replay recorded calls against a candidate policy.
Release status: v0.1.0 release candidate. The package is not on PyPI yet. Install from a checked-out commit until the first release is published.
English is authoritative for project contracts. See README.zh-CN.md for the Chinese feature overview and quickstart.
Why ToolPermit?
- Deterministic policy: strict, versioned YAML; first match wins and every result explains why.
- Exact one-time approval: an approval is bound to the canonical request, policy, session, and expiry, then consumed atomically.
- Redaction before storage: recognized secrets and sensitive keys are irreversibly replaced before SQLite persistence, display, or JSONL export.
- Offline replay: compare policies against stored, redacted calls without starting the MCP server or executing a tool.
- Local interfaces: every core workflow is available from the CLI; the optional approval UI is restricted to loopback and protected by Host, Origin, CSRF, CSP, and SameSite controls.
- Portable core: tested on Ubuntu, macOS, and Windows with Python 3.11, 3.12, and 3.13.
Ten-minute quickstart
Requirements: Python 3.11–3.13 and a local checkout.
python -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/toolpermit init
On Windows PowerShell, use .venv\Scripts\python and .venv\Scripts\toolpermit.
Observe the contained demo. The only write target is the disposable directory you provide:
mkdir demo-workspace
.venv/bin/python examples/demo_client.py \
--mode observe \
--demo-dir demo-workspace
.venv/bin/toolpermit runs list
To see a one-time approval, start the same client in enforce mode. It waits before the demo file is written:
.venv/bin/python examples/demo_client.py \
--mode enforce \
--policy toolpermit.yaml \
--demo-dir demo-workspace
In a second terminal, approve from the CLI:
.venv/bin/toolpermit approvals list
.venv/bin/toolpermit approvals approve APPROVAL_ID
Or launch the loopback UI with .venv/bin/toolpermit ui. Continue with the
complete quickstart, including policy suggestion, replay, and cleanup.
Policy example
version: 1
default: deny
rules:
- id: allow-demo-read
action: allow
explanation: Reading from the contained demo is expected.
match:
tool: read_demo
- id: review-demo-write
action: ask
explanation: Demo writes require one-time local approval.
match:
tool: write_demo
Unknown keys and invalid rules fail validation. See the policy reference for matching, precedence, canonicalization, redaction uncertainty, and examples.
Supported scope
v0.1 supports one local user, MCP over stdio, YAML policy version 1, SQLite audit schema version
1, CLI approval, and a loopback-only web UI. It does not provide an operating-system sandbox,
authenticate remote users, inspect calls that bypass the proxy, undo an executed tool action, or
guarantee that a permitted path is safe from every symlink/TOCTOU race.
Read Security, Privacy and data lifecycle, and Known limitations before using enforcement around destructive tools.
Documentation
- Quickstart
- CLI reference
- Configuration
- Policy reference
- Architecture
- Security model
- Privacy, retention, export, and deletion
- Troubleshooting
- Known limitations
- Policy benchmark
- Contributing and support
Development
python -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/ruff check src tests examples scripts benchmarks
.venv/bin/pyright
.venv/bin/pytest --cov=toolpermit --cov-fail-under=70
The release process, compatibility policy, and stage evidence are documented in docs/releasing.md and planning/.
License
Licensed under the Apache License 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolpermit-0.1.0.tar.gz.
File metadata
- Download URL: toolpermit-0.1.0.tar.gz
- Upload date:
- Size: 143.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b77f1722bd498ede361689afb9176f01e77fa2de058ac726fb172ca106b695c7
|
|
| MD5 |
38c284d2dc2d3847abebf9d489a0821c
|
|
| BLAKE2b-256 |
7de74aab3bf3c8d1407539f58a162224ec50e56efe5178ae6e24a82965654bbb
|
Provenance
The following attestation bundles were made for toolpermit-0.1.0.tar.gz:
Publisher:
release.yml on sunhao123456sun-svg/toolpermit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
toolpermit-0.1.0.tar.gz -
Subject digest:
b77f1722bd498ede361689afb9176f01e77fa2de058ac726fb172ca106b695c7 - Sigstore transparency entry: 2418489607
- Sigstore integration time:
-
Permalink:
sunhao123456sun-svg/toolpermit@fe6277d8901a71f2a4cd5f3e07a0afcf31db66e4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sunhao123456sun-svg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe6277d8901a71f2a4cd5f3e07a0afcf31db66e4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file toolpermit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: toolpermit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75b6635e7dd8a4d59b35ebf2afac18c20ea59a99a8e827eb837f72ffdaff1bfd
|
|
| MD5 |
6d77d850e3116335d0bcc30f2d1a9c98
|
|
| BLAKE2b-256 |
19f0ce202577079504829b1ea711da4ad849c015b4f198a7ab742f936291ed9d
|
Provenance
The following attestation bundles were made for toolpermit-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sunhao123456sun-svg/toolpermit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
toolpermit-0.1.0-py3-none-any.whl -
Subject digest:
75b6635e7dd8a4d59b35ebf2afac18c20ea59a99a8e827eb837f72ffdaff1bfd - Sigstore transparency entry: 2418489731
- Sigstore integration time:
-
Permalink:
sunhao123456sun-svg/toolpermit@fe6277d8901a71f2a4cd5f3e07a0afcf31db66e4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sunhao123456sun-svg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe6277d8901a71f2a4cd5f3e07a0afcf31db66e4 -
Trigger Event:
push
-
Statement type: