Skip to main content

pii-mcp

Pattern-based PII scrubbing for MCP servers (regex + checksums). Mask emails, IBANs, cards, BICs, MACs, IPs, coordinates, BSNs, US SSNs, German tax IDs, Dutch BTW-ids, phones, Dutch postcodes, and Dutch license plates in tool results — not NER for person names or full street addresses. Language packs: en, nl, and opt-in de.

Aligned with AP examples of persoonsgegevens where pattern/checksum detection can reach them (contact/financial IDs, online identifiers including IP/MAC, locatiegegevens as coordinates, BSN, kenteken). Names, free-text health data, and full street addresses need NER and are out of scope here.

Install

pip install "pii-mcp[fastmcp]"   # FastMCP >= 3.0.0
# or
pip install pii-mcp              # core only (pure Python, no Rust toolchain)

Optional Rust core

Default installs stay pure Python. To accelerate scrubbing with the shared pii-core crate (PyO3), build the optional extension locally:

pip install -e ".[native]"
maturin develop --release --manifest-path crates/pii-mcp-native/Cargo.toml

When pii_mcp._native is importable, scrub_text / scrub_payload use it. Force the Python path with PII_MCP_BACKEND=python.

Performance (Python vs Rust release)

Medians from scripts/bench_backends.py on macOS arm64 / CPython 3.14.7 (release native build; debug builds are not representative):

Case Python Rust Speedup
Short clean text 0.234 ms 0.023 ms 10.2×
Short mixed PII 0.058 ms 0.007 ms 8.9×
100 KiB sparse PII 20.4 ms 2.0 ms 10.2×
1 MiB sparse PII 203 ms 20.4 ms 10.0×
Nested JSON payload 12.4 ms 1.2 ms 10.3×
1k× tiny scrub_text 54.3 ms 6.8 ms 8.0×
python scripts/bench_backends.py

FastMCP

from fastmcp import FastMCP
from pii_mcp.fastmcp import PiiScrubMiddleware

mcp = FastMCP("MyServer")
mcp.add_middleware(PiiScrubMiddleware())  # languages=["en", "nl"] by default
# mcp.add_middleware(PiiScrubMiddleware(languages=["en", "nl", "de"]))

Results only. On scrub failure or oversize, the result is withheld — never forwarded unmasked.

Core

from pii_mcp import scrub_text, scrub_payload

scrub_text("mail ada@example.com")
scrub_payload({"email": "ada@example.com"}, languages=["en"])

Release files for pii-mcp 1.4.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 pii-mcp 1.4.0
File Size Uploaded
pii_mcp-1.4.0.tar.gz 115.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pii-mcp 1.4.0
File Interpreter ABI Platform
pii_mcp-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size:129.2 kB

Release files / pii_mcp-1.4.0.tar.gz

Download URL pii_mcp-1.4.0.tar.gz
Size 115.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cbe0ab27f76d43ebba762cb0abb50249f3345834d9b8bf98a427ac237c2fbd35
BLAKE2b-256 checksum
How to use checksums
676f3184a6873fc16f620c3ad76f1eb9001dd9935232992d200f00dbeba92313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / pii_mcp-1.4.0-py3-none-any.whl

Download URL pii_mcp-1.4.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
127dc862863a9c6c969625a69cce879d668d91187057b0fbbe635588df238be2
BLAKE2b-256 checksum
How to use checksums
a32f4c273313169fa3d0aab2fc36cb906dee23fec09fe4e6f0d58b58fccd78cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release history Release notifications | RSS feed

1.5.0

7 release files

This release

1.4.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