Skip to main content

eu-pii-redact

Keep European personal data out of LLM prompts and logs, and put it back in the answer. Python client, LangChain integration and MCP server for the EU PII Redaction API.

Hi, my name is Karina Dahl. I was charged twice for order 88412.
Please refund to DK50 0040 0440 1162 43 or call me on +45 32 12 34 56.
Karina

becomes

Hi, my name is [PERSON_1]. I was charged twice for order 88412.
Please refund to [IBAN_1] or call me on [PHONE_1].
[PERSON_1]
  • Names from evidence, not capital letters: titles, greetings, roles, Name: labels, sign-offs, or a first name from 140,000 European names. "Best Practices" and "Court of Justice" stay as they are.
  • National ID numbers from 21 EU/EEA countries, checked by check digit and birth date (personnummer, HETU, DNI/NIE, codice fiscale, NIR, PESEL, BSN, CPR, ...).
  • IBANs (mod-97), cards (Luhn), EU VAT numbers, emails, phones (with + prefix), IPs.
  • Every mention of a person shares one placeholder; order and invoice numbers stay untouched.

You need a RapidAPI key with a plan for the API. The free plan gives 500 requests a month. Set it as RAPIDAPI_KEY.

Python

pip install eu-pii-redact
from eu_pii_redact import Redactor

with Redactor() as r:                       # reads RAPIDAPI_KEY
    redaction = r.redact(ticket)
    reply = ask_llm(redaction.text)         # the model only sees placeholders
    print(redaction.restore(reply))         # real values back in the answer

redaction.entities lists each finding with its type, offsets in the original text and placeholder (national IDs also carry country and scheme). Texts longer than 50,000 characters are sent in pieces with consistent placeholders. r.redact(text, types=["EMAIL", "IBAN"], mode="mask") masks with asterisks.

LangChain

pip install "eu-pii-redact[langchain]"
from eu_pii_redact.langchain import protect, PIIRedactionTransformer

safe_llm = protect(llm)   # any model or chain that takes a string
safe_llm.invoke("Draft a reply to Karina Dahl about her refund to DK50 0040 0440 1162 43")
# the model sees [PERSON_1] and [IBAN_1]; the returned message has the real values again

docs = PIIRedactionTransformer().transform_documents(docs)   # e.g. before indexing for RAG

MCP server

Lets an AI assistant redact text and, more importantly, files without reading them: redact_file reads and writes the file itself and only reports counts, so the personal data never enters the conversation. restore_file puts the values back locally.

Tool What it does
redact_text Redact a text; returns the redacted text and entities (no original values)
redact_file Redact a UTF-8 file into a new file; writes a restore mapping (owner-only permissions)
restore_file Put the original values back into a file using that mapping, offline

Claude Code

claude mcp add eu-pii-redact -e RAPIDAPI_KEY=your-key -- uvx eu-pii-redact

Claude Desktop / Cursor / other hosts (mcpServers config)

{
  "mcpServers": {
    "eu-pii-redact": {
      "command": "uvx",
      "args": ["eu-pii-redact"],
      "env": { "RAPIDAPI_KEY": "your-key" }
    }
  }
}

Limits

Rule-based, which keeps it fast (about 0.1 s for 50,000 characters) and predictable: no street addresses yet, phone numbers need an international prefix, and a name without any cue whose surname is an English word ("Will Smith") is missed on purpose. Use it as a strong first layer, not as a compliance guarantee.

License

MIT for this client package. The API itself is a hosted service.

Metadata

Release files for eu-pii-redact 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eu-pii-redact 0.1.0
File Size Uploaded
eu_pii_redact-0.1.0.tar.gz 175.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eu-pii-redact 0.1.0
File Interpreter ABI Platform
eu_pii_redact-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 186.5 kB

Release files / eu_pii_redact-0.1.0.tar.gz

Download URL eu_pii_redact-0.1.0.tar.gz
Size 175.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b8d037086237c4013899039d24e9f6fb29160fa1efb3f318aa099ededbf2ad55
BLAKE2b-256 checksum
How to use checksums
66587d19c042af2b15ed2035051cf9a1f5f7379b249325a79106780d99ee8611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / eu_pii_redact-0.1.0-py3-none-any.whl

Download URL eu_pii_redact-0.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f9a336de2166b099dc2ef15b220986b64641b0bf8c8391042e1ec7a0c44b652
BLAKE2b-256 checksum
How to use checksums
77008b2ef584e45aa519d3d8a273010a229ce14b0d2a9e62e37ab2061b6398cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page