securedact-mcp
The Securedact MCP server is a local-first privacy layer for AI workflows. You can:
Analyze text (
analyze_text): Detect and classify sensitive data (PII, identifiers, contextual info) locally, without external transmission.Redact text (
redact_text): Replace detected sensitive values with stable typed placeholders (e.g.,[EMAIL_1]) according to a named privacy policy, returning anok/review_required/blockedstatus and a mapping for later restoration.Restore text (
restore_text): Reverse redaction by substituting placeholders with original values using a caller-supplied mapping.Create safe copy (
create_safe_copy): Write sanitized content to a.txtor.mdfile in a pre-configured safe directory (SECUREDACT_SAFE_COPY_DIR), preventing overwrites.Manage contextual models: Install, verify, update, or remove English/Dutch Flair models from Hugging Face for offline, local operation.
Fail-closed operation: The system fails closed if required contextual capability is unavailable, and can be configured to permit deterministic/rule-based mode.
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., "@securedact-mcp Redact any sensitive data from this text."
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.
SecuRedact MCP
SecuRedact is a local-first privacy and security layer for AI agents and AI workflows. It detects and protects sensitive data — personal data / PII, GDPR-sensitive information, credentials, API keys, tokens, secrets, and sensitive files — before that data reaches models, tools, files, or external destinations.
SecuRedact MCP is the Apache-2.0 open-source MCP server and reusable Python privacy engine. It detects sensitive text, applies versioned policies, redacts locally, and validates residual output before marking sanitized content approved.
MCP mode does not automatically intercept every prompt. The host must invoke the tool and send only
sanitized_textwhenstatus == "ok"; a misconfigured or malicious MCP host can bypass that ordinary MCP workflow. Provider-native enforced hooks are separate integration assets: when a supported provider invokes such a hook at its prompt lifecycle boundary, it can apply the same deterministic decision before normal model processing. See SecuRedact Enforced.
Why SecuRedact
AI agents increasingly read files, call tools, and send prompts to external models. That exposes PII, credentials, and sensitive documents unless something checks the data first. SecuRedact is a privacy and security control for AI workflows:
Local-first — all detection, redaction, and policy evaluation run on your machine. No network listener by default, no telemetry, no provider calls.
PII / GDPR detection — names, emails, IBANs, identifiers, and special-category data are detected and pseudonymized or redacted.
Secret & credential protection — API keys, tokens, and passwords are detected and blocked from leaving your environment.
Filesystem protection — reads are defended against traversal/symlink escapes and blocked from protected paths such as
.env.AI Agent Privacy Firewall — enforced hooks for Claude Code and Gemini CLI run the same local decision before a prompt, model call, or tool action proceeds.
Network / egress awareness — outbound tool calls are classified (internal/external/unknown) so policy can require approval or block egress.
SecuRedact helps reduce exposure of sensitive data; it is not a guarantee of compliance or a claim that every leak is prevented. See Limitations.
Related MCP server: phi-redact-mcp
HIPAA Safe Harbor (0.5.0)
SecuRedact 0.5.0 adds a HIPAA Safe Harbor mechanical-de-identification aid for
45 CFR 164.514(b)(2) text processing. It builds on the existing deterministic
detection stack and adds an 18-category Safe Harbor mapping, US-specific identifiers
(SSN with area/group/serial validation, US ZIP/ZIP+4, health-plan beneficiary,
account numbers, ages over 89, VIN-format vehicle identifiers, fax), and an optional
validated Flair PERSON-only gate for Category A (Names).
Use engine.hipaa_safe_harbor(text) or the HIPAA_SAFE_HARBOR_POLICY policy. This is
a mechanical aid, not a compliance certification: it cannot satisfy the
actual-knowledge prong (164.514(b)(2)(ii)) or replace Expert Determination
(164.514(b)(1)). See
docs/hipaa-safe-harbor-profile.md and
docs/hipaa-safe-harbor-gap-analysis.md.
Quick start
Install from PyPI and run the guided setup (Windows):
py -3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setupLinux / macOS:
python3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setupProtect a piece of text in seconds (deterministic-only demo, no model needed):
import os
os.environ["SECUREDACT_REQUIRE_FLAIR"] = "0" # deterministic detectors only
from securedact_core import RedactionRequest, SecuredactEngine
engine = SecuredactEngine.from_environment()
result = engine.prepare(
RedactionRequest(
text="Contact alex@example.test, IBAN NL91ABNA0417164300",
policy="strict_external_ai",
)
)
print(result.status) # "ok"
print(result.sanitized_text) # "Contact [EMAIL_1], IBAN [IBAN_1]"Reproducible synthetic security demos: docs/distribution/security-demo.md.
Safe default workflow
Use prepare_for_external_ai for normal external-AI preparation:
{
"text": "Contact alex@example.test",
"policy": "strict_external_ai",
"language": "auto",
"response_mode": "minimal"
}Approved response:
{
"schema_version": "1",
"status": "ok",
"sanitized_text": "Contact [EMAIL_1]",
"counts": {"email": 1},
"policy": "strict_external_ai",
"policy_version": 1,
"policy_digest": "...",
"reason_codes": []
}review_required and blocked responses never contain approved
sanitized_text. Minimal responses contain no original text, raw entity values,
mapping, exception body, stack trace, model path, or restoration handle unless
restore_capable was explicitly selected.
Architecture and trust boundary
flowchart LR
H["MCP host"] --> M["Securedact MCP"]
M --> D["deterministic detectors"]
M --> C["contextual detectors"]
D --> P["policy engine"]
C --> P
P --> R["redactor"]
R --> V["residual validator"]
V --> O["approved sanitized output"]
O --> W["host-controlled downstream workflow"]
H -. "host may bypass MCP" .-> WThe server has no provider clients, OpenAI-compatible proxy, reverse proxy, website, desktop chatbot, provider credentials, or provider-specific forwarding. See ADR 0001 and the threat model.
Tools
Tool | Intended use | Sensitive-response behavior |
| Recommended complete safe workflow | Minimal by default |
| Lower-level local analysis/review | Minimal; offsets in |
| Lower-level compatibility operation | Minimal by default; explicit |
| Consume a local opaque session | Single-use by default; direct mappings require explicit trusted legacy mode |
| Write approved | Returns no mapping or absolute path |
| Safely read a local file and return only sanitized text | Blocks protected paths before reading; rejects traversal/symlink/binary; |
Response modes are minimal, review, debug, and restore_capable. Debug is
disabled unless the process was started with
SECUREDACT_ENABLE_DEBUG_RESPONSES=1; an MCP request cannot enable it. In-memory
restoration sessions use cryptographic random handles, bounded capacity,
expiration, concurrency protection, and single-use consumption. Process exit
destroys all sessions.
See MCP tools, response privacy, and restoration sessions.
Installation
Python >=3.12,<3.13 is supported.
For a normal installation from PyPI:
py -3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setupOn Linux or macOS, use python3.12 -m pip install "securedact-mcp[ml]";
python -m pip install "securedact-mcp[ml]" is also appropriate when python
already selects a supported 3.12 environment.
setup checks the package, Python and ML dependencies, inspects local model
state, offers the existing consent-based model installer, runs the existing
offline verifier, and offers the packaged Claude Code and Gemini CLI
integrations when those hosts are detected. It uses the providers' official
plugin/extension commands and is safe to rerun. It does not call a provider
model API, accept provider trust automatically, or download a contextual model
unless the user explicitly selects model setup and accepts the existing
upstream prompt.
Manual model commands remain available for advanced or unattended operation:
securedact-mcp install
securedact-mcp models verify
securedact-mcpThe last command starts a local stdio server. Standard output is reserved for
MCP protocol messages. securedact-mcp setup --non-interactive reports state
without implying upstream acceptance or configuring a new provider. Use
--host claude, --host gemini, or --host all for targeted interactive
provider setup.
Developer/source installation
To work from a reviewed source checkout instead:
git clone https://github.com/GigantesHJI/securedact-mcp.git
cd securedact-mcp
python -m pip install ".[ml]"
securedact-mcp setupNo model checkpoint is included in the repository or wheel, and startup never downloads one. Securedact does not redistribute these model weights. Upstream model weights retain their own licenses and are not relicensed by Apache-2.0. See model installation and third-party licenses.
Deterministic-only local development must be explicitly selected:
$env:SECUREDACT_REQUIRE_FLAIR = "0"
securedact-mcpProduction defaults to requiring contextual capability and fails closed while a configured model is missing, loading, corrupt, or unavailable.
Host packages
Tested configuration assets and safe-workflow instructions are under
integrations/ for Codex, Cursor, and Windsurf. The automated MCP client harness
validates server startup, tool listing, calls, minimal response shape, stdout
integrity, and shutdown. It does not prove that a real host invokes the tool for
every prompt. See the compatibility evidence.
The repository is also a Gemini CLI extension root: gemini extensions install https://github.com/GigantesHJI/securedact-mcp can install the hooks. The
gemini-cli-extension topic and a release whose tag tree contains the root
manifest are required for that path to resolve; without pip install "securedact-mcp[ml]" and the local models the installed hooks do not enforce
anything. See SecuRedact Enforced.
Policies and Python API
Built-ins include default, strict_external_ai, gdpr, identifiers_only,
and review_all_contextual; compatibility policies remain available. Local
organization policy files load only from the controlled policy directory, use a
strict declarative schema, and cannot disable fail-closed invariants. Unknown,
duplicate, oversized, malformed, or symlinked policies fail closed.
from securedact_core import RedactionRequest, SecuredactEngine
engine = SecuredactEngine.from_environment()
result = engine.prepare(
RedactionRequest(
text="Contact alex@example.test",
policy="strict_external_ai",
)
)from_environment() preserves the contextual-model requirement. Standalone
deterministic development requires SECUREDACT_REQUIRE_FLAIR=0; applications may
also inject tested detector implementations. See public API
and policies.
Reproducible development
The committed uv.lock resolves runtime, ML, development, benchmark, and
security extras for Python 3.12.
uv sync --frozen --extra dev --extra benchmark
uv run python scripts\verify.pyNever use real personal information, private documents, credentials, customer logs, or model weights in tests, issues, screenshots, fixtures, or pull requests. See CONTRIBUTING.md.
Evaluation and performance
uv run python -m securedact_eval quality --mode deterministic --gate `
--thresholds benchmarks\thresholds.json `
--baseline benchmarks\baselines\quality-deterministic.json
uv run python -m securedact_eval performance --mode deterministicThe versioned synthetic corpus reports exact and relaxed span precision, recall, F1, false-positive and false-negative rates, per-entity/language/domain/split results, action/category accuracy, and bootstrap recall intervals. True negatives are document-level negative examples, not token-level safety. The GDPR-related suite is detection evaluation, not legal compliance certification. Real Flair and GPU benchmarks require an explicitly configured local model and are not ordinary CI. See benchmarking. The benchmark framework documents local data tiers and large profiles; the migration plan defines its future extraction boundary. For a failure before GitHub executes repository steps, use the CI troubleshooting decision tree. Local success does not replace a required GitHub check.
Security and limitations
No prompt, finding, mapping, restoration handle, secret, model input, or restored output is logged by application code.
Deterministic and contextual detection can miss novel, ambiguous, or adversarial disclosure; coreference and universal obfuscation resistance are not claimed.
Review offsets let a trusted local client with the original input reconstruct a value; keep review responses local.
Host behavior and downstream provider behavior are outside the trust boundary.
Repository security settings documented in files still require administrator verification.
Report vulnerabilities privately using SECURITY.md. Do not put vulnerability details or real data in a public issue.
License
Original repository source and documentation are licensed under the Apache License 2.0. Copyright attribution is recorded in NOTICE. Third-party dependencies and model weights retain their own licenses.
Available Tools
6 toolsanalyze_textARead-onlyIdempotent
Inspect text locally and report detected sensitive content without producing sanitized output.
Use this when you need to understand what PII, secrets, or credentials are present (counts, entity types, and, with review/debug modes, positions) but do not need redacted text for transmission. The original text is not modified and no sanitized representation is returned. For a policy-approved, ready-to-send result use prepare_for_external_ai; for a sanitized file use create_safe_copy; for reversing a prior local session use restore_text.
Returns a JSON object with 'status' ('ok', 'review_required', or 'blocked'), 'policy', 'policy_version', 'policy_digest', 'counts' (entity-type tallies), and, when response_mode is 'review' or 'debug', a 'findings' list. 'debug' additionally returns 'debug_details'.
Inputs: text (required), policy, response_mode. Returns: object
create_safe_copyA
Sanitize text locally and write the approved result to a new file in the Safe Copies directory.
Use this when you need a sanitized on-disk copy (for storage, handoff, or archival) rather than an in-memory sanitized string. For the sanitized text only, use prepare_for_external_ai; for inspection-only use analyze_text; for reversing a prior session use restore_text.
Side effects: a new file is written to the directory set by SECUREDACT_SAFE_COPY_DIR. The supplied 'content' is not modified and no existing file is overwritten. The filename must be a bare '.txt' or '.md' basename (no path separators or directory traversal). The operation blocks and reports 'blocked' if the directory is unconfigured, the filename is invalid, or policy blocks the content.
Returns a JSON object with 'status' ('ok' or 'blocked'), 'filename', and 'counts'.
Inputs: content (required), filename (required), policy. Returns: object
prepare_for_external_aiARead-onlyIdempotent
Use this before sending user-supplied or potentially sensitive text to an external AI service.
SecuRedact inspects and sanitizes the text locally and returns the policy-approved representation; this tool does not transmit the text externally. It is the recommended default for outbound AI workflows. Use analyze_text for inspection-only classifications, redact_text for the lower-level compatibility path, create_safe_copy when a sanitized file is required, and restore_text only to reverse a prior local session in a trusted context.
Returns a JSON object with 'status' ('ok', 'review_required', or 'blocked'), 'sanitized_text' (present only when approved), 'counts', 'policy', and optionally 'restoration_session' (when response_mode is 'restore_capable').
Inputs: text (required), policy, language, response_mode. Returns: object
redact_textARead-onlyIdempotent
Direct/lower-level redaction entry point; prefer prepare_for_external_ai for normal outbound workflows.
In its normal modes this performs the same local sanitization as prepare_for_external_ai and returns the approved result, so most agents should call prepare_for_external_ai instead. Use redact_text when you specifically need this lower-level compatibility path, or the 'legacy' mode for local review of raw redaction internals. The 'legacy' mode returns potentially sensitive local-review details and is never selected by default.
Returns, for normal modes, the same approved result as prepare_for_external_ai (status, sanitized_text, counts). For 'legacy' mode it returns a result with deprecation_code 'legacy_sensitive_response' containing local-review redaction data.
Inputs: text (required), policy, response_mode. Returns: object
restore_textA
Reverse a prior SecuRedact protection step in a trusted, local-only context.
Use this ONLY after you previously received a restoration_session from SecuRedact (for example from prepare_for_external_ai with response_mode 'restore_capable') and now need to reconstruct the original text locally for trusted review. Restoration can reveal the original sensitive values (PII, secrets, credentials); it is a trusted-local operation, not a step to prepare data for external transmission. Never call it to sanitize or prepare text for an external AI; for that use prepare_for_external_ai. Never call it on text you did not previously protect with SecuRedact.
Security boundary: all processing is local and nothing leaves the machine. The 'mapping' form requires trusted_local_review=true and exposes raw originals, so its output must never be transmitted. Returns a JSON object with 'status' ('ok' or 'blocked'), 'restored_text' (present only on success), and 'reason_codes' describing any failure.
Inputs: text (required), mapping, restoration_session, trusted_local_review. Returns: object
securedact_read_fileARead-onlyIdempotent
Safely read a local file and return only its sanitized (PII/secrets removed) text.
Use this when you must ingest a local file's contents for use with an external AI but want path-traversal, size, and binary defenses plus sanitization applied first. If the content is already in memory, use prepare_for_external_ai; for a sanitized file on disk, use create_safe_copy.
Side effects: reads a file from local disk and never transmits it. Sensitive paths and escapes are blocked before any file content is read. The returned 'sanitized_text' is safe to forward.
Returns a JSON object with 'status' ('ok' or 'blocked'), 'path', and 'sanitized_text' (present only when approved).
Inputs: path (required), policy, max_bytes. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have clearly distinct outputs (in-memory text, file write, file read, inspection, restoration), but prepare_for_external_ai and redact_text perform identical sanitization in normal modes, with redact_text explicitly deferring to prepare_for_external_ai. This creates a potential misselection point despite the helpful cross-references.
The majority of tools follow a clean verb_noun pattern (analyze_text, redact_text, restore_text, create_safe_copy). prepare_for_external_ai and securedact_read_file deviate with a prepositional phrase and a brand prefix, but the overall naming remains readable and predictable.
Six tools is well within the ideal scope for a focused sanitization server. Each tool maps to a distinct workflow step, and none feel extraneous enough to bloat the surface.
The set covers the core lifecycle: inspection, in-memory sanitization, safe file output, safe file input, and session restoration. Minor gaps exist around policy management and the redundant redact_text path, but there are no critical dead ends for the stated purpose.
Maintenance
Related MCP Connectors
MCP gateway: one connection for your AI apps, with tool policies, PII redaction and audit logs.
MCP server for detecting and redacting PII (Personally Identifiable Information) in PDF documents.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA local, containerized MCP server that uses a local LLM to sanitize documents by removing or transforming PII before content is sent to public LLM services.MIT
- AlicenseAqualityCmaintenanceAn MCP server that redacts PII/PHI from text before it ever reaches an LLM — self-hosted, fail-closed, and HIPAA-aware.324 PyPIMIT
- AlicenseAqualityDmaintenanceMCP server providing on-prem PII detection and anonymization tools (scan and is_sensitive) for AI agents, ensuring data stays local.4MIT

omitly-mcpofficial
FlicenseAqualityBmaintenanceMCP server for local, verifiable PDF redaction. Enables AI agents to find sensitive regions, locate text, redact PDFs on-device, verify redaction and tamper-evidence seals, and generate PDFs—without uploading confidential documents.8602 npm-