Redacta
Redacta pseudonymises patient identifiers in clinical text, keeps reversal mappings server-side, and provides controlled restoration and leak-checking tools.
protect: replace identifiers with labelled tokens, returning protected text, a session_id, replacement count, and self-check; mapping stays server-side.release_to_file: restore original identifiers from a session into a local file; only a receipt enters the model context.check_output: scan model output for verbatim leaked original values, re-tokenise them, and report leaked token categories.discard_session: immediately delete a session's private mapping.redact(legacy): pseudonymise text but return the token map to the client.reinstate(legacy): restore text using a client-held token map.self_check: scan already-redacted text for possible residual identifiers.Supports pattern sets:
clinical,general, andsafeharbor(HIPAA Safe Harbor).
Redacta
Pseudonymise medical and clinical documents before they're processed by AI or
shared. Redacta replaces patient identifiers with labelled tokens —
[PATIENT_NAME_1], [NHS_NUMBER_1], [DATE_OF_BIRTH_1], … — while leaving the
clinical meaning intact, and returns a redaction report alongside the cleaned
text.
It started as an Agent Skill and is now one engine shipped across eight surfaces — an iOS app, agent skill, MCP server, a self-hosted HTTP service with a Kubernetes deployment, two libraries, a CLI, and a FigJam whiteboard plugin.
Running this in production? Redacta offers a small number of fixed-price design-partner integrations for teams shipping AI agents on clinical or patient data — deployment in your environment, one real workflow integrated, and a data-flow document written for your DPO. Details →
One engine, many surfaces
Surface | Folder | Get it |
iOS app — iPhone (app, Share Extension, widget) | Build with Xcode — see | |
Agent skill (Claude Code / apps / API) |
|
|
MCP server (Claude Desktop, Cursor, …) |
|
|
TypeScript library |
|
|
Python library |
|
|
Command-line tool |
|
|
Self-hosted HTTP service + Kubernetes |
| |
FigJam plugin |
|
The detection logic lives in one place — the TypeScript engine
(@pharmatools/redacta, in npm-package/), which the MCP server and the
FigJam plugin consume, and which the iOS app runs on-device via JavaScriptCore.
The Python package mirrors it for pip users; the agent skill adds LLM reasoning
for free-text names on top of the deterministic patterns.
Related MCP server: PubCrawl
How it works
Two layers:
Patterns (deterministic). A bundled script (
scripts/redact_structured.py, Python standard library only, no network) matches fixed-format identifiers: NHS numbers (Modulus-11 validated), UK National Insurance numbers, dates of birth, UK postcodes, phone numbers, emails, and hospital/MRN numbers. US SSN and ZIP codes are also handled.Reasoning (judgement). The skill then has the agent handle what patterns can't: patient names (told apart from the clinicians treating them), relatives and carers, postal addresses, and identifying ages.
Self-check. A final pass re-reads the output for any identifier that slipped through before the report is written.
It also works in reverse. Re-identification (scripts/reinstate.py) takes the
token map from an earlier redaction and restores the original values — so you can
redact a document, run it through another AI tool, and put the real details back
locally. Redact → process → re-identify is a complete round trip, and identifiers
only ever exist on your machine.
Safe Harbor mode. Ask for HIPAA Safe Harbor (or "US de-identification") and Redacta applies a stricter pass: all dates (not just the date of birth), all specific ages, and the remaining HIPAA identifiers — fax, certificate/licence, device serial, VIN, and health-plan beneficiary numbers.
Self-hosting on Kubernetes
Organisations that can't let identifiable text leave their environment can
run Redacta inside their own infrastructure: a small HTTP service
(gateway-service/) deployable into an existing
Kubernetes cluster with plain YAML — two stateless replicas behind a
Service for redact/reinstate, an optional single-replica session boundary
for the protect → release loop, health probes, resource limits, restrictive
security defaults, and no-PHI logging. Text is pseudonymised before it
reaches any external AI service, and the processing boundary stays under
your control. Walkthrough (local kind cluster included):
gateway-service/k8s/README.md ·
concepts: docs/KUBERNETES.md.
Deploying somewhere a DPO will ask questions? There's a one-page security &
data-protection summary at
pharmatools.ai/redacta-security.
Install
Claude Code
git clone https://github.com/nickjlamb/redacta ~/.claude/skills/redactaThen invoke it with /redacta, or let it trigger automatically when you ask to
redact or de-identify clinical text.
Claude apps / API
Zip the repository folder and upload it as a skill.
Contents
Path | What it is |
| The skill — instructions plus metadata |
| Pattern specs, the Modulus-11 algorithm, NI prefix rules, the date-of-birth vs clinical-date rule, token vocabulary, limitations |
| The deterministic pattern layer |
| The re-identification layer (restore originals from a token map) |
| Tests for the pattern layer |
| Tests for the re-identification layer |
| Example evaluation scenarios |
Run the tests:
python3 scripts/test_redact_structured.py
python3 scripts/test_reinstate.pyA note on limits
Redacta is a strong first line of defence, not a guarantee. It won't catch every possible identifier and isn't a substitute for formal data-protection processes. Always review the redaction report before sharing text.
License
MIT-0 (MIT No Attribution). Built by PharmaTools.AI.
Available Tools
7 toolscheck_outputCheck output for leaked identifiersARead-only
Scan generated text for verbatim reappearance of the original values held in a protected session (tolerant of spacing, dashes and case for identifier-like values) and re-tokenise anything found. Returns which token categories leaked — never the raw values — plus the sanitised text and a general self-check. Scope is verbatim reappearance only: paraphrases and inferred identities are not detected.
Inputs: text (required), session_id (required).
discard_sessionDiscard a protection sessionA
Delete a session's private mapping immediately instead of waiting for expiry. Idempotent. After this, no restoration is possible for that session.
Inputs: session_id (required).
protectProtect text (mapping stays server-side)A
Redact patient identifiers and PII, replacing each distinct value with a labelled token ([NHS_NUMBER_1], [PATIENT_NAME_1], ...). The reversal mapping is kept privately inside the Redacta server and is NEVER included in this response — you receive only the protected text, an opaque session_id for later controlled restoration, a count of what was replaced, and a self-check of possible leftovers. Sessions expire automatically.
Inputs: text (required), categories.
redactRedact / pseudonymise text (legacy — exposes token map)ARead-only
LEGACY: like protect, but returns the token_map (token -> original value) in the response, which places the reversal key in the client and potentially the model context. Kept for backward compatibility and client-managed workflows. Prefer protect, which keeps the mapping server-side.
Inputs: text (required), categories.
reinstateRe-identify from a client-held token map (legacy)ARead-only
LEGACY: reverse a redaction using a token map held by the client (from the legacy redact tool). Restored personal data will appear in this tool result. For session-based restoration that keeps mappings server-side, use protect + release_to_file.
Inputs: text (required), token_map (required).
release_to_fileRestore identifiers into a local fileA
Restore original identifiers into text produced from a protected session, writing the result to a file inside the server's configured release directory (REDACTA_RELEASE_DIR). Returns only a receipt — file path, size, and counts — so restored data never enters the model context. This is the privacy-preserving way to complete the round trip.
Inputs: text (required), session_id (required).
self_checkSelf-check for residual identifiersARead-only
Scan already-redacted text for anything that still looks like an identifier (long numbers, emails, postcodes, URLs). A second pair of eyes, not a guarantee. Returns a list of possible leftovers to review.
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 7 tools
Each tool has a clearly distinct purpose: protect vs redact are differentiated by legacy status and return behavior, release_to_file vs reinstate by client vs server-side mapping, plus check_output, discard_session, and self_check each occupy unique roles. No ambiguity in selection.
All tools use snake_case and a verb-first pattern, though the structure varies (protect, release_to_file, check_output, discard_session, redact, reinstate, self_check). The legacy tools follow the same style but the naming is consistent enough to be predictable.
Seven tools is well-scoped for a redaction/restoration server: core redaction, restoration, leakage checking, session management, and legacy compatibility all have dedicated tools without bloating the surface.
The full lifecycle is covered: redaction (protect), restoration (release_to_file), output verification (check_output), session cleanup (discard_session), and leftover scanning (self_check), plus legacy paths. No obvious gaps for the intended domain.
Maintenance
Related MCP Connectors
HealthGuard - 12-tool health/medical AI safety MCP: PII redaction, HIPAA, GDPR Art.9.
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.
Privacy-preserving synthetic health data generation. FHIR R4/R5 compliant.
Related MCP Servers
- FlicenseAqualityBmaintenancePII sanitization layer for autonomous AI agent pipelines. Detects and redacts emails, phone numbers, national IDs, private keys, and financial data before text reaches LLMs. Supports EN, ES (LATAM), PT (BR/PT), DE, JA.12-
- AlicenseAqualityBmaintenancePubCrawl provides LLMs with access to PubMed, FDA/UK drug labeling, and ClinicalTrials.gov. It enables searching literature, retrieving abstracts and full texts, comparing US and UK drug labels, and exploring clinical trials.15716 npm15MIT
- AlicenseAqualityCmaintenanceLocal pseudonymisation MCP server that detects PII in text, replaces it with opaque tokens before sending to cloud LLMs, and restores tokens afterward.257 npm2MIT
- AlicenseAqualityBmaintenanceDeployment-readiness harness for AI document-QA and extraction systems. Scaffolds grounding checks, privacy redaction and cost tracking into a project, composing OpenGATE, Redacta and PubCrawl.535 npm1MIT