Don't Leak
Don't Leak is a local-first privacy filter for AI coding agents. It detects, redacts, masks, or blocks personal data (PII), credentials, custom RE2 regex patterns, and restricted words before prompts or local files reach a cloud model.
Documentation
Your Data. Your Control.
npx -y dont-leak-mcp setup
Guide · Before & After · Install · 10-Agent Hooks · Detectors · Deploy · FAQ
Don't Leak is a local-first privacy filter for AI coding agents. It detects, redacts, masks, or blocks personal data (PII), credentials, custom RE2 regex patterns, and restricted words before prompts or local files reach a cloud model. One shared @dont-leak/core engine powers the MCP Server, automatic hooks for 10 AI agents, a local LLM HTTP proxy, a bilingual (ID / EN) Web Dashboard, and the CLI. Raw sensitive values never leave your machine and are never stored in SQLite audit logs.
Before and after
One developer prompt containing customer PII and production credentials, before and after passing through Don't Leak:
Click here for more before and after examples (Masking, Blocked phrases, Safe .env reader, Reversible Vault)
1. Partial masking (action: mask)
Useful in development presets when you still want visual confirmation of which record was matched:
| Input | Masked output |
|---|---|
Charge card 4111 1111 1111 1111 and notify admin@corp.id | Charge card 41************11 and notify ad***@corp.id |
2. Hard block on internal codenames (action: block)
When any finding resolves to block (or when failMode: closed catches a validation error), Don't Leak withholds the entire payload before the model is called:
Input: "Summarize the Q4 acquisition memo for Project Garuda"
Verdict: BLOCKED (status: "blocked", summary: { BLOCKED_WORD: 1 })
Output: Withheld. Nothing is sent upstream.
3. Reading .env, structured configs, and documents safely (read_sanitized_file)
Agent hooks block direct cat .env or read_file(".env") calls and instruct the agent to call read_sanitized_file instead. It preserves valid syntax on .json, .yaml, .env, and .csv files, and extracts text locally from .pdf, .docx, and .xlsx documents before redacting:
.env on disk | Returned to AI agent |
|---|---|
PORT=3000PUBLIC_APP_NAME="Billing Portal"SUPABASE_SERVICE_ROLE_KEY=sbp_v1_8f9K2mPqR7xLw4nZt6vBc3dFgH1jKlMn | PORT=3000PUBLIC_APP_NAME="Billing Portal"SUPABASE_SERVICE_ROLE_KEY=<SECRET_HIGH_ENTROPY_SECRET> |
4. Human-only reversible Token Vault (<LABEL_VXXXXXX>)
When the encrypted vault is enabled, headless hooks and MCP seal values with an RSA-OAEP-256 public key. Only a human with the admin password can restore them afterward:
# AI receives and replies using sealed tokens:
"Send the invoice confirmation to <EMAIL_V4F9A2C>."
# You restore original values locally when needed:
npx -y dont-leak-mcp detokenize ./ai-reply.txt
# -> "Send the invoice confirmation to finance@klien.co.id."
Install
Pick the setup that matches how you run your AI tools. Every route shares the same config.yaml and SQLite metadata store. Full step-by-step instructions, including updates and removal, live in GUIDE.md.
| Route | What it does | Best for |
|---|---|---|
| Interactive wizard | Configures detectors, country profiles, policy preset, Dashboard password, and project hooks | First-time setup on any machine |
| Automatic agent hooks | Intercepts prompts and .env/secret tool calls automatically on every new session | OpenCode, OMP/Pi, Antigravity, Claude Code, Cursor, Gemini CLI, Windsurf, Cline, Copilot, Codex |
| CLI scanner and Git guard | Scans folders, .pdf/.docx/.xlsx documents, and blocks leaked secrets on git commit | Local repo audits, CI checks, and Git pre-commit protection |
| MCP Server | Gives the AI client 11 local sanitization, inspection, and safe-file tools over stdio | Claude Desktop, Cursor, Antigravity, OpenCode, Windsurf, Cline |
| Local HTTP proxy | Sanitizes OpenAI, Anthropic, and Gemini JSON request bodies in transit | Custom scripts, SDKs, or chat apps without hook support |
The setup wizard (recommended)
Requirements: Node.js >= 22.13. Run one command and answer the prompts:
npx -y dont-leak-mcp setup
Verify your environment or open the local Web Dashboard (http://127.0.0.1:3000 by default) anytime:
npx -y dont-leak-mcp doctor
npx -y dont-leak-mcp dashboard
MCP Server
Add dont-leak to your client's mcpServers configuration:
{
"mcpServers": {
"dont-leak": {
"command": "npx",
"args": ["-y", "dont-leak-mcp"]
}
}
}
By default, MCP runs in read/sanitize-only mode (5 tools). Append "--allow-admin" to args only if you want the AI client to add or remove custom regex rules, blocked words, and allowlist entries.
Click to see where each MCP client stores this JSON config
| Client | Config file location |
|---|---|
| Claude Desktop | Windows: %APPDATA%\Claude\claude_desktop_config.jsonmacOS: ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Code | ~/.claude.json or project .mcp.json |
| Cursor | .cursor/mcp.json (project) or ~/.cursor/mcp.json (global) |
| Antigravity | ~/.gemini/antigravity/mcp_config.json |
| OpenCode | ~/.config/opencode/opencode.json or project opencode.json (under "mcp") |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
| Cline | VS Code Cline panel -> MCP Servers -> Configure MCP Servers |
Automatic interception
Standard MCP servers are passive: an AI model only filters text through MCP when it chooses to call a tool. To filter prompts and block direct .env or private-key reads automatically on every new session, install lifecycle hooks for your coding agent:
# Auto-detect agent folders in the current project:
npx -y dont-leak-mcp setup-hooks
# Or install globally across your machine for specific / all 10 agents:
npx -y dont-leak-mcp setup-hooks --target opencode,omp,antigravity,claude,cursor --global
npx -y dont-leak-mcp setup-hooks --target all --global
Add --strict-prompt if you want prompts containing redactable PII/secrets to be hard-blocked on agents whose hook protocol cannot rewrite prompt text in-place.
OpenCode v2 (in-place prompt rewrite + tool guard)
npx -y dont-leak-mcp setup-hooks --target opencode --global
Writes ~/.opencode/plugins/dont-leak.js (or .opencode/plugins/dont-leak.js for a single repo) using OpenCode v2's { id, setup(ctx) } plugin contract. Hooks ctx.session.hook("prompt") to rewrite PII/secrets into placeholders before persistence and ctx.tool.hook("execute.before") to block .env or secret shell reads. If OpenCode is already open, run opencode reload or opencode service restart.
OMP / Oh My Pi & Pi coding agent (in-place prompt transform + tool guard)
npx -y dont-leak-mcp setup-hooks --target omp --global
# Alias also supported: --target pi
Writes native ExtensionAPI module dont-leak.js (pi.on("input") prompt transform + error toast on blocked phrases, and pi.on("tool_call") guard) alongside settings.json command hooks.
Antigravity, Claude Code, Cursor, Gemini CLI, Windsurf, Cline, Copilot, Codex
Install one or several by name (--global for machine-wide, omit --global for current workspace):
npx -y dont-leak-mcp setup-hooks --target antigravity,claude,cursor,gemini,windsurf,cline,copilot,codex
| Agent | Project path | Global path | Interception behavior |
|---|---|---|---|
| Antigravity | .agents/hooks.json | ~/.gemini/config/hooks.json | PreInvocation gate + PreToolUse (read_file, run_command, grep_search) |
| Claude Code | .claude/settings.json | ~/.claude/settings.json | UserPromptSubmit + PreToolUse (Read, Bash, Grep) |
| Cursor | .cursor/hooks.json | ~/.cursor/hooks.json | beforeSubmitPrompt + beforeReadFile + beforeShellExecution |
| Gemini CLI | .gemini/settings.json | ~/.gemini/settings.json | BeforeAgent + BeforeTool (decision: "deny") |
| Windsurf | .windsurf/hooks.json | ~/.codeium/windsurf/hooks.json | pre_user_prompt + pre_read_code + pre_run_command (exit code 2) |
| Cline | .clinerules/hooks/* | ~/Documents/Cline/Rules/Hooks/* | POSIX sh UserPromptSubmit & PreToolUse (cancel: true) |
| GitHub Copilot | .github/hooks/dont-leak.json | ~/.copilot/hooks/dont-leak.json | userPromptSubmitted + preToolUse (VS Code & Copilot CLI) |
| OpenAI Codex | .codex/hooks.json | ~/.codex/hooks.json | UserPromptSubmit + PreToolUse (exit code 2 block) |
CLI scanner and Git pre-commit guard
Scan any local file, directory, or document (.pdf, .docx, .xlsx), or install a repository .git/hooks/pre-commit guard so credentials and PII never enter Git history:
# Install automatic Git pre-commit guard in the current repository:
npx -y dont-leak-mcp setup-hooks --target git
# Scan staged changes, a project directory, or local documents manually:
npx -y dont-leak-mcp scan --staged
npx -y dont-leak-mcp scan ./src ./docs/report.docx
npx -y dont-leak-mcp scan . --json
scan prints file:line:column and rule metadata only, never echoing raw secret values to terminal or CI logs.
Local LLM HTTP proxy
For SDKs, scripts, or desktop chat clients without hook support, route requests through the local sanitizing reverse proxy:
npx -y dont-leak-mcp proxy --port 8787
Point your client base URLs to the local proxy (127.0.0.1 only):
export OPENAI_BASE_URL="http://127.0.0.1:8787/openai/v1"
export ANTHROPIC_BASE_URL="http://127.0.0.1:8787/anthropic"
# Gemini route prefix: http://127.0.0.1:8787/gemini
Multi-turn messages[] within one request share a consistent token table, and payloads matching a block rule stop locally with HTTP 422 before reaching the provider.
Detectors
| Module | What it catches | Validation & safety |
|---|---|---|
PII (pii) | Email, phone (+62/08xx, US NANP, E.164), Indonesian NIK & NPWP, US SSN, EU IBAN, payment cards, IPv4 & IPv6 | Checksum and structure checks (Kemendagri province/date for NIK, Luhn for cards, ISO 13616 MOD-97 for IBAN) |
Secrets (secret) | AWS, GitHub, GitLab, Slack, Stripe, OpenAI/Anthropic, Google API keys, JWTs, PEM/SSH private keys, Bearer tokens, DB URLs, and high-entropy credentials | Contextual Shannon entropy skips UUIDs, SHA/Git hashes, file paths, and PUBLIC_KEY names |
Custom Regex (custom_regex) | User-defined patterns such as EMP-[0-9]{6} or internal ticket IDs, with optional custom replacement text | Compiled through re2-wasm (linear-time O(n), immune to catastrophic ReDoS backtracking) |
Blocked Words (blocked_words) | Confidential codenames, client names, or restricted phrases (exact, whole_word, or phrase matching) | NFKC Unicode normalization; rules with action: block always override allowlist exclusions |
Country profiles (id, us, eu, intl) can be toggled independently in config.yaml or the Web Dashboard.
MCP tools and Web Dashboard
The local Web Dashboard (npx -y dont-leak-mcp dashboard) binds to 127.0.0.1, supports Bahasa Indonesia (ID) and English (EN), and protects state-changing endpoints with scrypt password hashing, HttpOnly session cookies, and CSRF tokens.
Click to view all 11 MCP tools and access levels
| MCP Tool | Access | Purpose |
|---|---|---|
sanitize_content | Default | Redacts, masks, or blocks sensitive spans (supports format: "json" | "yaml" | "env" | "csv" to keep syntax valid) |
redact_content | Default | Alias of sanitize_content |
scan_content | Default | Returns structured finding metadata (labels, offsets, severity) without modifying input |
read_sanitized_file | Default | Reads .env, .json, .yaml, .csv, logs, or .pdf/.docx/.xlsx documents locally and returns sanitized text |
list_detection_rules | Default | Lists active custom rule IDs plus blocked-word and allowlist counts |
list_policies | Default | Reports active policy, enabled detectors, and country profiles |
get_sanitization_report | Default | Returns aggregate scan and label counts from local SQLite audit metadata |
test_regex_rule | Default | Tests a custom RE2 pattern against sample text safely |
manage_detection_rules | --allow-admin | Adds, updates, enables, disables, or removes a validated RE2 custom rule |
manage_blocked_words | --allow-admin | Adds or removes blocked words and phrases |
manage_allowlist | --allow-admin | Adds or removes allowlist exclusions |
Encrypted Token Vault (optional)
Need to restore redacted values in an AI response? Initialize the local hybrid RSA-OAEP-256 + AES-256-GCM vault:
npx -y dont-leak-mcp vault init
npx -y dont-leak-mcp detokenize ./ai-output.md
MCP, hooks, and the HTTP proxy only ever read the public key to seal <LABEL_VXXXXXX> tokens. The private key stays wrapped with your scrypt admin password and is never exposed as an MCP tool.
Update
When a new release ships updated detectors or agent plugin schemas, one command upgrades your global install (if present), cleans stale _npx cache slots so hooks do not run an older cached version, regenerates every installed hook/plugin across your project and home folder, and reloads OpenCode's background service:
npx -y dont-leak-mcp@latest update
To inspect your current version and list detected hooks without changing any files:
npx -y dont-leak-mcp update --check
Self-hosted deployment
Docker Compose & GHCR container
# Option A: Pull prebuilt container directly from GitHub Container Registry (GHCR)
docker pull ghcr.io/itsaxware/dontleak:latest
docker run -d --name dont-leak -p 127.0.0.1:3000:3000 -v privacy-data:/data ghcr.io/itsaxware/dontleak:latest
# Option B: Docker Compose from repository
git clone https://github.com/ItsAxware/DontLeak.git
cd DontLeak
docker compose up -d
Prebuilt image: ghcr.io/itsaxware/dontleak:latest.
- Web Dashboard listens on
http://127.0.0.1:3000. - Persistent
config.yaml, snapshots, and SQLite WAL files live in theprivacy-datavolume (/data). - Connect a host MCP client to the running container:
{ "mcpServers": { "dont-leak": { "command": "docker", "args": ["exec", "-i", "dont-leak", "node", "/app/apps/mcp-server/dist/server.js"] } } }
Linux systemd service
git clone https://github.com/ItsAxware/DontLeak.git
cd DontLeak
pnpm install --frozen-lockfile
pnpm -r build
sudo ./deployment/scripts/install.sh --from-dir .
- Runs under a dedicated
dont-leaksystem user withNoNewPrivileges=true,PrivateTmp=true,ProtectSystem=strict, andProtectHome=true. - Stores config in
/etc/dont-leak/config.yamland SQLite/backups in/var/lib/dont-leak. - Upgrade with automatic snapshot:
sudo ./deployment/scripts/update.sh --from-dir . - Uninstall while keeping config and audit data:
sudo ./deployment/scripts/uninstall.sh
config.yaml reference
policy:
name: default
failMode: closed
maxInputBytes: 1000000
entropyDetection: true
reversibleTokenization: false
countryProfiles: [id, us, eu, intl]
enabled:
pii: true
secret: true
custom_regex: true
blocked_words: true
actions:
pii: redact
secret: redact
custom_regex: redact
blocked_words: block
rules:
- id: employee-id
label: EMPLOYEE_ID
pattern: \bEMP-[0-9]{6}\b
case_insensitive: false
severity: medium
action: redact
replacement: "[EMPLOYEE_ID]"
enabled: true
blocked_words:
- value: project phoenix
group: internal_project
match: phrase
action: block
allowlist:
- value: "@example.com"
kind: literal
description: Synthetic test domain
Allowlist entries (literal, @domain suffix, or RE2 regex) skip warn, mask, and redact findings. Rules or words with action: block always override the allowlist.
Measured performance
Benchmarked on Node.js >= 22.13 (x64) across 46 structured positive and hard-negative lookalike cases (including contextual Shannon entropy) plus a 1.00 MB mixed sanitization and output-validation payload:
| Metric | Measured value |
|---|---|
| Precision | 1.0000 (FP = 0) |
| Recall | 1.0000 (FN = 0) |
| False-positive rate (lookalike negatives) | 0.0000 |
1 MB sanitize + output validation | ~312 ms (~3.21 MB/s) |
Heap delta during 1 MB pass | ~6.88 MB |
FAQ
Why did my agent still see a secret when I only configured MCP?
MCP tools are passive: the model only calls sanitize_text when it decides to. Install automatic hooks (npx -y dont-leak-mcp setup-hooks) or use the local HTTP proxy so prompts and .env reads are intercepted before the model runs.
How is this different from an agent's built-in secret redaction? Built-in agent filters usually only mask a few known API key prefixes in terminal output and vary across vendors. Don't Leak gives you one consistent policy across all 10 agents, adds country-specific PII checksums (NIK, NPWP, SSN, IBAN, Luhn cards), linear-time RE2 custom rules, company blocked words, a human-only reversible vault, and local metadata-only audit stats.
Can an AI agent decrypt <LABEL_VXXXXXX> vault tokens?
No. No MCP tool accepts a detokenization request, and the private key is encrypted at rest with your scrypt admin password. Only you can run dont-leak-mcp detokenize or enter your admin password in the Web Dashboard Vault tab.
What does Don't Leak intentionally not claim to catch?
Unstructured free-text person names and street addresses have no deterministic format; Don't Leak does not claim regex-only coverage for them to avoid a false sense of security. For specific client or project names, add them to blocked_words or rules.
Star History
Contributors
Thanks to everyone reporting detector edge cases, agent hook changes, and fixes. See the contributors graph or open an issue if a pattern slipped through or flagged a false positive. Full setup, update, and troubleshooting documentation lives in GUIDE.md.
"AI agents work best with context.
Your raw credentials, customer IDs, and internal codenames do not belong in it."
Disclaimer
Get Don't Leak only from ItsAxware/DontLeak, the dont-leak-mcp npm package, or ghcr.io/itsaxware/dontleak. For LAN or remote Dashboard deployments, place Don't Leak behind a TLS reverse proxy and set DASHBOARD_ALLOWED_HOSTS.
License
MIT: LICENSE