pii-mcp
Pattern-based PII scrubbing for MCP servers (regex + checksums). Mask emails,
IBANs, cards, BICs, MACs, IMEIs, IPs, coordinates, BSNs, US SSNs, German tax
IDs, Dutch BTW-ids, Dutch passport/ID numbers, 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: wat zijn persoonsgegevens where pattern/checksum detection can reach them. Names, free-text health data (allergies), photos/audio/video, unstructured klant-/personeelsnummers, and full street addresses need NER or media handling and stay out of scope.
AP coverage (pattern layer)
| AP example / category | Detector | Notes |
|---|---|---|
| e-mail / contact | email, phone |
|
| IP-adres | ip |
Indirect identifier |
| Locatiegegevens | location |
Decimal lat/lon |
| Financiële gegevens | iban, credit_card, bic, vat_id |
|
| BSN / nationaal ID | bsn, passport |
Passport/NIK format (nl pack) |
| Online / device IDs | mac, imei |
IMEI: grouped forms + Luhn |
| Adres (structured) | address |
NL postcode only |
| Kenteken | license_plate |
nl pack |
| Naam, pasfoto, allergieën, koopgedrag, camera | — | NER / media |
Packages:
| Runtime | Path | Install |
|---|---|---|
| Python | src/pii_mcp |
pip install pii-mcp |
| TypeScript | typescript/ |
npm install pii-mcp |
| Rust core | crates/pii-core |
shared by both (PyO3 / N-API) |
Install (Python)
pip install "pii-mcp[fastmcp]" # FastMCP >= 3.0.0
# or
pip install pii-mcp # core; platform wheels include Rust acceleration
Rust core (Python)
Published platform wheels ship pii_mcp._native (PyO3 over pii-core). Pip
prefers those on supported OS/arch; elsewhere (or with --no-binary) you get
the pure-Python hatchling wheel/sdist and the same scrub API.
When _native is importable, scrub_text / scrub_payload use it. Force the
Python path with PII_MCP_BACKEND=python; require native with
PII_MCP_BACKEND=native.
Local development from a clone (optional):
pip install -e ".[native]"
maturin develop --release --manifest-path crates/pii-mcp-native/Cargo.toml
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 (Python)
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 (Python)
from pii_mcp import scrub_text, scrub_payload
scrub_text("mail ada@example.com")
scrub_payload({"email": "ada@example.com"}, languages=["en"])
Install (TypeScript)
npm install pii-mcp
Default installs stay pure TypeScript. To use the same pii-core crate via
N-API from a clone of this repo (shared with Python’s PyO3 addon):
cd typescript
npm install
npm run build
npm run build:native # requires a Rust toolchain; needs ../crates/pii-core
Published npm install pii-mcp is JS-only until optional native artifacts ship.
When a locally built napi addon is loadable, scrubText / scrubPayload use it.
Force the JS path with PII_MCP_BACKEND=js. See typescript/README.md.
Performance (TypeScript vs Rust release)
Medians from scripts/bench_backends.mjs on macOS arm64 / Node 22
(release napi build). V8 is already fast, so napi wins are modest on
larger/mixed inputs; tiny calls can favor pure JS (FFI overhead):
| Case | TypeScript | Rust | Speedup |
|---|---|---|---|
| Short clean text | 0.024 ms | 0.026 ms | 0.9× |
| Short mixed PII | 0.014 ms | 0.011 ms | 1.2× |
| 100 KiB sparse PII | 2.03 ms | 1.84 ms | 1.1× |
| 1 MiB sparse PII | 20.6 ms | 20.7 ms | 1.0× |
| Nested JSON payload | 1.28 ms | 1.12 ms | 1.1× |
1k× tiny scrubText |
9.82 ms | 10.5 ms | 0.9× |
cd typescript && npm run build && npm run build:native
node ../scripts/bench_backends.mjs
Core (TypeScript)
import { scrubText, scrubPayload, usingNative } from "pii-mcp";
scrubText("mail ada@example.com");
scrubPayload({ email: "ada@example.com" }, { languages: ["en"] });
usingNative();
Release files for pii-mcp 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pii_mcp-1.5.0.tar.gz | 150.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pii_mcp-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
| pii_mcp-1.5.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pii_mcp-1.5.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| pii_mcp-1.5.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size:4.3 MB
Release files / pii_mcp-1.5.0.tar.gz
| Download URL | pii_mcp-1.5.0.tar.gz |
|---|---|
| Size | 150.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e83914beedc9e64864b23a25e37258ddd4273997e24c572b6d168f378307e3f
|
|
BLAKE2b-256 checksum How to use checksums |
30b45c37c136fff73bf7f399e601916daf0f1f6a887db1c722875844956611cc
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-py3-none-any.whl
| Download URL | pii_mcp-1.5.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce5267e7a38441c4fdf1941edf6cc7e861299a8f756ebcae754efdfd6791fa53
|
|
BLAKE2b-256 checksum How to use checksums |
3758baf8683263ece999624db872b63bf54ba5ead83a98c5f00a82459f5ccb07
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-cp310-abi3-win_amd64.whl
| Download URL | pii_mcp-1.5.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 748.3 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
364bc26fd3369931a7cf7493bc37554d934b6af10e8baa74f900cee4ec880573
|
|
BLAKE2b-256 checksum How to use checksums |
24334b5c5c9d5be57c1d63b325636a76df504be8568d072318641fd6768b441a
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 904.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
db391e285e47bed65a08a140a7ed1ec01f699175dea130475b831f8b8d39d1e9
|
|
BLAKE2b-256 checksum How to use checksums |
985f3c176ab911ec51e67af2477bf84c131f182797a58b8232d6b92627756513
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pii_mcp-1.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 872.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
72b79820d7412de2a3555d9f52b20742d0c9e84a0d6ff8e5424d07372dd9023b
|
|
BLAKE2b-256 checksum How to use checksums |
84478ffec9f2cfcfb8ae97c9b3ec612fed87a723a477bfb079818daba00b88cf
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | pii_mcp-1.5.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 783.1 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bffa579fac849847bc76eac9ec082c097c4d7709b5a59fdd5c81caca10a8d50b
|
|
BLAKE2b-256 checksum How to use checksums |
7b54e135a0c3e81a49b941ed88e0be08e2759c3b0dfd3e9d52f9b011bd3e862f
|
| 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 19, 2026.
Transparency logRelease files / pii_mcp-1.5.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | pii_mcp-1.5.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 828.8 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d3e0cbf87eb1311f583daabcbd1f53a285bb9174b226eddb77bc9503f0c38f13
|
|
BLAKE2b-256 checksum How to use checksums |
162619788a417a673c49e84a369895e8b152017c23687b330e2b597d8c9339b8
|
| 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 19, 2026.
Transparency log