privacy-gateway-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@privacy-gateway-mcp Draft a reply to this email, redacting any personal or financial details first."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
privacy-gateway-mcp
An MCP server that sits between an assistant and a cloud LLM and enforces a simple rule: no raw sensitive data leaves the process.
Before any text is sent out, the gateway:
Redacts sensitive entities (emails, phones, national IDs, cards, money, API keys) into reversible placeholders —
ana@acme.cl→[EMAIL_1].Runs a deterministic egress policy that can
ALLOW, requireHUMAN APPROVAL, orBLOCKthe call. The LLM never gets to overrule it.Re-hydrates the provider's reply, so the caller sees real values while the cloud only ever saw placeholders.
Writes every decision to an append-only audit log.
This is a small, generic illustration of a pattern I run in a private production system: a multi-agent setup where business rules live in code, not in the prompt, and any action that touches data or money needs explicit confirmation. No business logic or real data is included here.
Why this exists
LLM assistants are great at drafting replies to an email or summarizing a contract — but doing so usually means shipping the raw text (names, phone numbers, amounts) to a third-party API. Two things must be true before that's acceptable:
The cloud must not see real entities. Redaction is bidirectional so the answer is still useful.
The decision to send can't be the model's. Whether a payload leaves — and whether a human signs off first — is a hard rule enforced in code. The model proposes; the gateway decides.
That "deterministic layer over the LLM" plus "confirm before it leaves" is the whole point.
Related MCP server: TracePII Shield MCP
Architecture
┌──────────────────────── privacy gateway ────────────────────────┐
text ───▶ redact (reversible) ─▶ egress policy ─┬─ BLOCKED ─▶ ✋ nothing leaves
├─ NEEDS_APPROVAL ─▶ 🎫 token, nothing leaves
└─ ALLOWED ─▶ send redacted ─▶ cloud LLM
│
caller ◀──────────────── rehydrate ◀──────────────────────────────── redacted reply ◀──┘
└── every path is written to an append-only audit log ──┘Module | Responsibility |
| Bidirectional entity redaction (span-based, consistent placeholders) |
| Deterministic egress rules — |
| Single-use, TTL-bound human-approval tokens |
| Append-only decision log (counts + reasons, never raw values) |
| Pluggable cloud provider ( |
| Orchestration — pure, synchronous, framework-free (fully unit-tested) |
| Thin MCP wrapper exposing the tools + resource |
The core (gateway.py and below) has no MCP dependency, so the guardrails are tested in isolation and the MCP layer stays thin.
MCP tools
Tool | What it does |
| Dry run: shows what would be redacted and how the policy would rule. No send, no token. |
| Guarded egress. Returns |
| Releases a payload the policy flagged for approval. Token is single-use and time-limited. |
| The append-only decision trail. Also exposed as the resource |
The policy (defaults)
Signal | Outcome |
Text contains an API key/token or a card number | BLOCKED — never routed to the cloud, even redacted |
A sensitive entity survives redaction | BLOCKED (fail-closed) |
Text contains a monetary amount | NEEDS_APPROVAL |
More than 5 entities redacted, or prompt > 4000 chars | NEEDS_APPROVAL |
Otherwise | ALLOWED |
All thresholds live in PolicyConfig — they are code, not prompt.
Run it
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
python -m privacy_gateway_mcp.server # stdio transportRegister it with an MCP client (e.g. Claude Desktop's mcp config):
{
"mcpServers": {
"privacy-gateway": {
"command": "python",
"args": ["-m", "privacy_gateway_mcp.server"]
}
}
}Test
pip install -e ".[dev]"
pytest -qThe suite covers the pieces that matter: redaction round-trips to identity, secrets/cards are blocked, money needs approval, block beats approval, approval tokens are single-use and expire, and — end to end — the real entity never reaches the provider while the caller still gets it back re-hydrated.
Extending it
Real provider — implement
CloudProvider.complete; a commented Anthropic sketch is inproviders.py. Text is already redacted before it reaches the provider.Better detection — the regex detectors are dependency-free on purpose (runs on bare metal, no model download). Swapping in an NER model (spaCy / Microsoft Presidio) is a single method on
Anonymizer.detect.Policy — add categories or thresholds in
PolicyConfig; the engine picks them up.
License
MIT — see LICENSE.
Available Tools
4 toolsask_cloud_llmA
Send text to the cloud LLM through the privacy gateway.
The text is redacted first; then the deterministic policy decides. Possible
status values: sent (redacted text was dispatched and the reply
re-hydrated), blocked (a hard rule refused it), or needs_approval
(call confirm_send with the returned confirmation_token).
Inputs: text (required).
confirm_sendA
Approve and release a payload the policy flagged for human approval. The token is single-use and time-limited.
Inputs: token (required).
get_audit_logA
Return the append-only log of every egress decision made this session.
Inputs: no named parameters. Returns: result
redact_previewA
Show what would be redacted and how the egress policy would rule — without sending anything or issuing an approval token.
Inputs: text (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool serves a distinct purpose: previewing redactions, confirming sends, auditing decisions, and making requests. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern (redact_preview, confirm_send, get_audit_log, ask_cloud_llm), making them predictable and easy to use.
Four tools cover the essential workflow of a privacy gateway without unnecessary bloat or missing critical operations.
The set covers the full lifecycle: preview (redact_preview), action (ask_cloud_llm), approval (confirm_send), and audit (get_audit_log). No obvious gaps.
Maintenance
Related MCP Connectors
Detect and redact PII and secrets before text reaches an LLM, with reversible placeholders.
Detect and redact PII and secrets (API keys, tokens) in text, HTML or PDF before it reaches an LLM.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Find and redact leaked secrets, wallet keys and PII before an AI agent sends text.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides a pre-flight/post-flight firewall for LLM calls with comprehensive detection, classification, policy enforcement, reversible redaction, output safety, and immutable audit logging.1MIT
- FlicenseNot gradedqualityDmaintenanceRedacts PII from LLM traces and tool payloads before they leave review, enabling PII scanning, payload redaction, sensitive field classification, privacy receipts, and trace audit exports.-
- AlicenseNot gradedqualityCmaintenanceEnables data-loss prevention for Model Context Protocol traffic by inspecting tool calls in both directions, redacting sensitive values with stable placeholders, and providing audit logging, manual scanning, and data source connectors.5 npmMIT
- AlicenseBqualityBmaintenanceEnables local, in-memory de-identification of PII, PHI, and credentials with deterministic reversible surrogate tokens before LLM transmission, then restores originals from volatile session mappings and audits for exposures without network egress or disk writes.5115 npm1Apache 2.0