prompt-redact Airlock MCP Server
Proxies OpenAI-compatible API requests, tokenizing outbound prompt payloads before forwarding to the configured upstream and restoring echoed tokens locally.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
prompt-redact
Deterministic, reversible secret redaction for LLM workflows: a zero-runtime-dependency TypeScript SDK, a loopback Anthropic/OpenAI proxy, an MCP "airlock" server, and a strict secret scanner/gate.
prompt-redact replaces credential-shaped values with opaque tokens before prompt content leaves the machine, and restores the values locally when the model echoes a token. It is a detection and tokenization layer, not a sandbox.
Security model (read this first)
What the tool does: for values matched by the configured catalog (or the optional entropy detector), the proxy, file reader, and SDK emit tokens instead of the plaintext. Rehydration happens locally, in the same vault.
What it does not do:
It does not prove that every secret is detected. Detection is heuristic (patterns plus optional Shannon entropy). Unlabeled, low-entropy strings can pass through. Give secrets a recognizable shape, add
customPatterns, or enableentropy.The proxy redacts request bodies, path segments, and query values. It does not redact arbitrary HTTP headers.
Authorizationandx-api-keyare forwarded to the configured upstream by design;CookieandRefererare stripped.Secret values live in process memory for the lifetime of the vault. There is no zeroization or secure enclave.
There is no TLS. Keep listeners on loopback unless you put a TLS terminator in front. Binding a listener to a non-loopback host requires (and still sends in cleartext) a bearer token.
airlock_execis disabled by default. Once enabled, every allowlisted command can read the vault (tokens are resolved into its args/env), so a prompt-injected model can exfiltrate secrets through that command. Only enable it for commands and models you trust with every secret in the vault.The CI gate does not trust configuration from the repository it inspects.
verifyignores a repo-localallowlist/excludePaths; pass a trusted--configif you need them. Expected binaries should be explicitly excluded in a trusted config.The scanner cannot verify files it cannot read.
verifytreats every skipped file (binary, oversized, unreadable, symlinked, invalid UTF-8) as a failed check.scanreports them but stays a report, not a gate.The MCP airlock cannot stop native file or shell tools from bypassing it. The secure installer (skill --install --secure) adds permission deny rules and a guard hook, but this remains a guard, not a sandbox.
What you can rely on
Tokens are stable within a session/vault, so multi-turn prompt prefixes remain cacheable.
Redaction is fail-closed on vault saturation:
overflowPolicy: "hash"emits a random opaque mask (<<redact-masked:0123456789ab>>, not derivable from the secret);"error"aborts the whole operation.SSE rehydration is chunk-boundary safe: tokens split across TCP, UTF-8, or JSON-string boundaries are reassembled before the client sees them.
audit.md, SARIF,/audit,redact_audit, andredact_verifyrecord rule IDs, paths, line numbers, and counts — never matched values.
Related MCP server: privacy-gateway-mcp
Requirements
Node.js >= 18.3.0 for the runtime (uses
node:util.parseArgsandserver.closeAllConnections).Node.js >= 20 to run the development/test suite (
@modelcontextprotocol/clientis test-only).Zero runtime dependencies.
Quick start
1. Local LLM proxy (Anthropic + OpenAI)
npx prompt-redact setup --autopilot
npx prompt-redact proxy --port 4790Point clients at the proxy:
# Claude Code
export ANTHROPIC_BASE_URL="http://127.0.0.1:4790"
# OpenAI-compatible clients (Cursor, Cline, OpenCode, ...)
export OPENAI_BASE_URL="http://127.0.0.1:4790/v1"PowerShell:
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:4790"
$env:OPENAI_BASE_URL = "http://127.0.0.1:4790/v1"Useful options:
--dry-run(or headerx-prompt-redact-dry-run: 1) returns the tokenized outbound payload without contacting the upstream.--mode ephemeralcreates a fresh vault per proxy request;session(default) keeps tokens stable across turns. This option is proxy-only.--max-entries/--overflow-policy hash|errorcontrol fail-closed behavior at vault capacity.--tokenrequires a bearer token from clients. The proxy strips that bearer value before forwarding; a separate upstream credential belongs inAuthorization/x-api-keyand is forwarded.
2. Airlock MCP server
npx prompt-redact mcp # stdio
npx prompt-redact mcp --http --port 4791--http generates a bearer token and prints it once to stderr. Loopback is the default; non-loopback binding requires a token and is cleartext. --no-auth is accepted only on loopback and leaves plaintext-revealing inspector endpoints disabled. Query-string tokens for the legacy SSE endpoints are rejected by default; they are available only to SDK callers that explicitly set allowQueryToken.
Tool | Purpose |
| Tokenize text through the active vault. |
| Deep-tokenize arbitrary JSON (keys and values). |
| Read a confined workspace file with credentials replaced by tokens. |
| Opt-in. Run an allowlisted command with vault tokens resolved in args/env; stdout/stderr are re-scrubbed. |
| Zero-plaintext rule/capacity/audit summary. |
| Scan text or a confined file for unredacted credential patterns (rule/line only). |
To enable the executor, add this to prompt-redact.config.json:
{
"exec": {
"enabled": true,
"allowCommands": ["git", "node"]
}
}An empty allowlist refuses everything. Entries without a path separator match the executable basename; entries with one match the full path. Enabling airlock_exec is equivalent to granting those commands access to the vault.
3. Secure agent setup (recommended for the airlock)
Native Read/Bash tools bypass the MCP server. To make the airlock the default path, install the MCP config, Claude Code permission deny rules, and hooks together:
npm i -D prompt-redact
npx prompt-redact skill --install --secureThis writes:
.mcp.json (Claude Code) and .cursor/mcp.json (Cursor)
.claude/settings.json: denies native reads of .env, keys, SSH material, and cloud credentials; allowlists the six MCP tools; runs guard --hook on PreToolUse and verify --hook on UserPromptSubmit
.cursorignore for the same sensitive paths
the skill and rule files
guard --hook blocks native reads/commands that target credentials and blocks literal secrets; the MCP tools remain allowlisted. This closes the common bypass, but it is a guard, not a sandbox: obfuscated shell can evade heuristics, and airlock_exec remains a trust boundary for every allowlisted command.
When the airlock helps - and when it doesn't
Useful when:
the agent is restricted to the MCP tools, or the secure installer is applied;
the model must inspect .env/configs and run authenticated commands without plaintext entering the model;
you need an audit trail.
Not a boundary when:
native Read/Bash remain available and unguarded;
the model is untrusted and airlock_exec is enabled (allowlisted commands can exfiltrate);
you expect protection from a malicious local process or a compromised host.
4. Scanner and CI gate
npx prompt-redact scan --sarif # writes audit.md + audit.sarif, exit 1 on findings
npx prompt-redact verify # strict gate over the workspace
npx prompt-redact verify --staged # simulate the index, not the working tree
npx prompt-redact verify --stdin # stdin, e.g. a pre-commit hook
npx prompt-redact verify --hook # Claude Code hook envelope on stdin; exit 2 blocksverify is strict: every skipped file fails the check, and a repo-local config cannot widen allowlists/exclusions. Pass --config /path/to/trusted.json (or --no-config) for a trusted gate. scan is a report: it lists skipped files but exits on findings only.
Exit codes: 0 success/clean, 1 findings or runtime failure, 2 usage/config error (and verify --hook / guard --hook use 2 for findings so Claude Code blocks the action).
5. Agent skill and hooks
npx prompt-redact skill --installWrites .claude/skills/prompt-redact/SKILL.md and .cursor/rules/prompt-redact.mdc (Cursor frontmatter included) and adds both to .gitignore unless --track is used. Add --secure to also install the MCP/permission/hook configuration described in section 3.
Claude Code hook example:
{
"hooks": {
"UserPromptSubmit": [
{ "hooks": [{ "type": "command", "command": "npx --no-install prompt-redact verify --hook" }] }
],
"PreToolUse": [
{ "matcher": "Read|Edit|Write|MultiEdit|Grep|Bash", "hooks": [{ "type": "command", "command": "npx --no-install prompt-redact guard --hook" }] }
]
}
}--hook parses the JSON envelope on stdin and emits exit code 2 on findings, which is the only code Claude Code treats as blocking. The PreToolUse guard blocks native credential reads/commands; the prompt hook scans submitted text.
Programmatic SDK
import {
createVault,
redactPayload,
rehydratePayload,
} from "prompt-redact";
const vault = createVault({ mode: "session", maxEntries: 1024, overflowPolicy: "hash" });
const { payload } = redactPayload(
{ messages: [{ role: "user", content: process.env.ANTHROPIC_API_KEY ?? "" }] },
vault
);
// send `payload` to the model, then restore locally:
const restored = rehydratePayload(payload, vault);Token example: <<redact:0123456789abcdef0123456789abcdef:1>> (prefix, 32-hex salt, index). Overflow masks look like <<redact-masked:0123456789ab>> (opaque; not reversible and not derived from the secret). The legacy <<redact-hash:...>> form is still recognized as a placeholder for compatibility.
For streaming responses, pipe the upstream body through createSseRehydrationTransform(vault, protocol, options) (or wrapResponseWithRehydration). It supports OpenAI chat/completions, the Responses API, and Anthropic events, including tokens split across frames, multiple choices, tool-call JSON, and id:/retry: fields.
Configuration
prompt-redact.config.json is data-only JSON. Unknown keys are rejected instead of silently ignored.
Key | Type | Default | Meaning |
| string |
| Token prefix. |
| integer |
| Distinct secrets before the overflow policy applies. |
| string |
|
|
| string |
| Proxy session policy; ignored by the SDK/MCP/scanner/serve. |
| object | disabled |
|
| array |
| Exact strings or |
| array |
|
|
| array |
| Paths skipped by scan/verify (trusted config only in verify). |
| object |
|
|
Example:
{
"maxEntries": 1024,
"overflowPolicy": "hash",
"entropy": { "enabled": true, "threshold": 4.2, "minLength": 24 },
"customPatterns": [{ "rule": "corp-token", "pattern": "CORP_[A-Z0-9]{12}" }],
"exec": { "enabled": false, "allowCommands": [] }
}CLI reference
Command | What it does |
| Loopback Anthropic/OpenAI proxy (default port 4790). |
| MCP server over stdio or |
| Loopback inspector/playground with |
| Scan and write |
| Strict gate: workspace, |
| PreToolUse hook for native Read/Bash credential access; exits 2 to block. |
| Write the default config and print env hints ( |
| Check Node, config, port, and a vault round-trip. |
| Print or install the agent skill ( |
| Machine-readable agent contract ( |
Common flags: --cwd, --config, --no-config, --host, --port, --token, --no-auth, --allow-origin, --max-entries, --overflow-policy, --mode (proxy), --format, --help, --version. The skill installer also accepts --secure. Run describe --format json for the authoritative per-command option matrix.
The inspector (serve) requires a bearer token by default; its /api/rehydrate and /api/sse-simulate endpoints (which reveal plaintext) are disabled entirely under --no-auth. The page sets CSP/frame-protection headers, and the token is kept in sessionStorage, not persistent storage.
Benchmarks
Measured with npm run benchmark on Node v24.12.0, win32-x64. These are indicative, not guarantees.
Case | Measured |
SDK redact, 10 KB secret-dense | ~5.1 ms median |
SDK redact, 100 KB secret-dense | ~49 ms median |
SDK redact, 100 KB ordinary prose | ~0.87 ms median |
SDK rehydrate, 100 KB | ~0.39 ms median |
Proxy overhead, 2.6 KB JSON | ~+1.0 ms |
Proxy overhead, 2.6 KB SSE | ~+1.2 ms |
Proxy overhead, 100 KB prose | ~+2.9 ms |
The secret-dense payload contains two credential shapes per ~120-character line; the prose case exercises the credential-assignment prefilter. Earlier README revisions quoted much lower numbers measured before the catalog grew — the benchmark script is the source of truth.
Development
npm ci
npm run typecheck # tsc --noEmit
npm test # builds, then runs 72 tests
npm run verify # typecheck + tests + pack-check + real tarball install check
npm run benchmark # SDK + proxy timingsCI runs npm run verify on Node 20 and 22. Versioning is currently 0.1.0.
Release
0.1.0 is the current release candidate. .github/workflows/release.yml publishes on a v* tag with npm provenance; it expects an NPM_TOKEN repository secret (or npm trusted publishing) and a tag matching package.json (v0.1.0). prepublishOnly re-runs the check suite and prepack rebuilds dist, so a publish cannot ship stale output.
License
MIT © Ankur Halder
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Find and redact leaked secrets, wallet keys and PII before an AI agent sends text.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Governed access to sensitive data, secrets and APIs for AI agents. A signed proof for each decision.
Related MCP Servers
AlicenseAqualityBmaintenanceEnables AI agents to scan text for leaked secrets and prompt injection markers, and redact them before reaching an LLM.222 PyPI1MIT- AlicenseAqualityCmaintenanceEnables safe interaction with cloud LLMs by redacting sensitive entities into reversible placeholders, enforcing deterministic egress policies with human approval, and rehydrating responses so real data never leaves the process.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to scan and audit environment files for leaked secrets, sanitize them, encrypt/decrypt vaults, and run processes with zero-disk secret injection.MIT
- AlicenseBqualityCmaintenanceEnables AI agents to use vault-stored credentials without ever exposing plaintext secrets to model context, transcripts, or telemetry. It decrypts AES-256-GCM envelopes locally via WebCrypto, resolves opaque secret handles into subprocess environments and outbound HTTP requests, issues auto-zeroizing time-bounded leases, and scrubs echoed credentials from output.19MIT