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.

Current release: v0.1.1 on PyPI, with a matching GitHub Release.

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

Codex Skill

Install the ToolPermit Codex Skill from this GitHub repository with the built-in plugin manager:

codex plugin marketplace add sunhao123456sun-svg/toolpermit --ref main
codex plugin add toolpermit@toolpermit

For a reproducible installation of this release, replace main with v0.1.1 in the first command.

Start a new task, then ask:

Use $toolpermit to install ToolPermit and safely wrap my local MCP stdio server in observe mode.

The Skill checks the environment, installs the compatible Python package when authorized, preserves existing files, shows MCP client changes before writing them, and keeps enforcement and exact approvals user-controlled. See the Codex Skill installation and usage guide for updating, removal, trigger examples, and limitations.

Ten-minute quickstart

Requirements: Python 3.11–3.13. A local checkout is also needed for the contained demo scripts.

python -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install "toolpermit==0.1.1"
.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 plugins
.venv/bin/pyright
.venv/bin/python scripts/check_codex_plugin.py
.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.1.tar.gz (145.7 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.1-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file toolpermit-0.1.1.tar.gz.

File metadata

  • Download URL: toolpermit-0.1.1.tar.gz
  • Upload date:
  • Size: 145.7 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.1.tar.gz
Algorithm Hash digest
SHA256 b5045073c91476166537dcb8f9eb8b05a1fa6eacc34188cf077c3defbfee7e3b
MD5 f95ae252a91d91da5d17b4c59c19e136
BLAKE2b-256 43b36102786b71d0e71ec86ce105f51415b53d56649bd36fe00f085698f2d6e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolpermit-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: toolpermit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05a09bce262a6c204575295fbbcd72f8b1501cbdea763f2d5aa5522e4140c2ec
MD5 5b68be0176c56ec16b78142e45830850
BLAKE2b-256 d55fa7e3716145b15a516ce25fa4558de16e3e45258d9371c0d5e93c1a2e81e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolpermit-0.1.1-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