Skip to main content

ToolPermit

CI Python 3.11–3.13 License: Apache-2.0

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.

ToolPermit loopback approval UI with fictional contained-demo data

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

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

toolpermit-0.1.0.tar.gz (143.4 kB view details)

Uploaded Source

Built Distribution

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

toolpermit-0.1.0-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

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

Hashes for toolpermit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b77f1722bd498ede361689afb9176f01e77fa2de058ac726fb172ca106b695c7
MD5 38c284d2dc2d3847abebf9d489a0821c
BLAKE2b-256 7de74aab3bf3c8d1407539f58a162224ec50e56efe5178ae6e24a82965654bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolpermit-0.1.0.tar.gz:

Publisher: release.yml on sunhao123456sun-svg/toolpermit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for toolpermit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75b6635e7dd8a4d59b35ebf2afac18c20ea59a99a8e827eb837f72ffdaff1bfd
MD5 6d77d850e3116335d0bcc30f2d1a9c98
BLAKE2b-256 19f0ce202577079504829b1ea711da4ad849c015b4f198a7ab742f936291ed9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolpermit-0.1.0-py3-none-any.whl:

Publisher: release.yml on sunhao123456sun-svg/toolpermit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page