Skip to main content
Glama

Your Data. Your Control.

npx -y dont-leak-mcp setup

Guide · Before & After · Install · 10-Agent Hooks · Detectors · Deploy · FAQ

npm version Node.js CI GHCR MIT license


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:

Before: raw input sent to the AI

After: filtered locally by Don't Leak

Debug failed webhook for budi.santoso@klien.co.id
Applicant NIK: 3171014507900003
Phone: +6281298765432
DATABASE_URL=postgresql://app:Sup3rS3cret99@db.internal:5432/prod
WEBHOOK_SECRET=whsec_9fK3mPq8Rw2Lx7Nz4Vb6Cd1Fg5Hj0Kl3

Debug failed webhook for <EMAIL_001>
Applicant NIK: <NIK_001>
Phone: <PHONE_001>
DATABASE_URL=<DB_CREDENTIAL_001>
WEBHOOK_SECRET=<HIGH_ENTROPY_SECRET_001>

Customer identity, database password, and signing secret enter the model context permanently.

Context stays readable and deterministic (budi... maps to <EMAIL_001> everywhere in the turn), while raw values stay on your machine.

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 safely via MCP (read_sanitized_file)

Agent hooks block direct cat .env or read_file(".env") calls and instruct the agent to call read_sanitized_file instead, so the agent sees variable names without raw credentials:

.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=<HIGH_ENTROPY_SECRET_001>

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."

Related MCP server: classifinder-mcp

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

MCP Server

Gives the AI client 9 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

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.

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.

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.

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.

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)

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.

MCP Tool

Access

Purpose

sanitize_text

Default

Redacts, masks, or blocks sensitive spans according to active policy

inspect_text

Default

Returns structured finding metadata (labels, offsets, severity) without modifying input

read_sanitized_file

Default

Reads .env, logs, or configs locally and returns only sanitized text to the agent

test_regex

Default

Tests a custom RE2 pattern against sample text safely

get_protection_status

Default

Reports active policy, enabled detectors, country profiles, and scan counts

add_custom_rule

--allow-admin

Adds or updates a validated RE2 custom rule (creates automatic config backup)

remove_custom_rule

--allow-admin

Removes a custom regex rule by ID

add_blocked_word

--allow-admin

Adds a blocked word or phrase

remove_blocked_word

--allow-admin

Removes a blocked word or phrase

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

git clone https://github.com/ItsAxware/DontLeak.git
cd DontLeak
docker compose up -d --build

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 the privacy-data volume (/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"]
        }
      }
    }
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-leak system user with NoNewPrivileges=true, PrivateTmp=true, ProtectSystem=strict, and ProtectHome=true.

  • Stores config in /etc/dont-leak/config.yaml and 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

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

Star History Chart

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.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers