Skip to main content

pii-mcp

Pattern-based PII scrubbing for MCP servers (regex + checksums). Masks 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.

PyPI npm CI License: MIT

Example

from pii_mcp import scrub_text

scrub_text(
    "Contact ada@example.com. IBAN NL91 ABNA 0417 1643 00. card 4111111111111111"
)
# Contact [EMAIL]. IBAN [IBAN]. card [CREDIT_CARD]

Install

pip install "pii-mcp[fastmcp]"   # FastMCP >= 3.0.0
# or
pip install pii-mcp              # core; platform wheels include Rust acceleration
# or
npm install pii-mcp

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"])

Scope

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)

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.2x
Short mixed PII 0.058 ms 0.007 ms 8.9x
100 KiB sparse PII 20.4 ms 2.0 ms 10.2x
1 MiB sparse PII 203 ms 20.4 ms 10.0x
Nested JSON payload 12.4 ms 1.2 ms 10.3x
1k x tiny scrub_text 54.3 ms 6.8 ms 8.0x
python scripts/bench_backends.py

Metadata

Release files for pii-mcp 1.5.1

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.5.1
File Size Uploaded
pii_mcp-1.5.1.tar.gz 160.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pii-mcp 1.5.1
File
pii_mcp-1.5.1-py3-none-any.whl Python 3 none any Details
pii_mcp-1.5.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pii_mcp-1.5.1-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.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
pii_mcp-1.5.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
pii_mcp-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 4.4 MB

Release files / pii_mcp-1.5.1.tar.gz

Download URL pii_mcp-1.5.1.tar.gz
Size 160.6 kB
Tags Source
SHA-256 checksum
How to use checksums
021ff18e9b679dc4e18899573b1cfdff5efb014a7c3eb2af3b7f294d378e67cb
BLAKE2b-256 checksum
How to use checksums
990c2b9f4c562f1e31386b61be64b4bd99e1e62b9b7f99a2be265c44e43c3034
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 20, 2026.

Transparency log

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

Download URL pii_mcp-1.5.1-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00143927ffc139e276ee5450c4b18af7a7dc75ab93b7ae0c7ff425eb66def70f
BLAKE2b-256 checksum
How to use checksums
195b7317896f0ec8feb02f8fc5b9bab8f26bb8a13c423b02054f8d02f91ef74d
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 20, 2026.

Transparency log

Release files / pii_mcp-1.5.1-cp310-abi3-win_amd64.whl

Download URL pii_mcp-1.5.1-cp310-abi3-win_amd64.whl
Size 759.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cf700129213d7eba2edcc39a5d7b25d0d277e8c2b079afbea0fe946d41e77fcc
BLAKE2b-256 checksum
How to use checksums
f8daf60cfee96ed458f811433581d26309ed787b2b1c6f7dd4bf3689f9181815
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 20, 2026.

Transparency log

Release files / pii_mcp-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pii_mcp-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 914.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5b48622365257ad09f8cc241c46423cf845a8f7185dbfa1e1469fb04c7f6a859
BLAKE2b-256 checksum
How to use checksums
1f8fb12d92fdd812a91fa807b1d6d8a2b2275ed6cc2babf97f378033e3abbbc2
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 20, 2026.

Transparency log

Release files / pii_mcp-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pii_mcp-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 883.3 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a713030bd2edc57c1dc4dccc2f50a5f953d1dadccfabc9dc84664a6704ed158a
BLAKE2b-256 checksum
How to use checksums
7c3a2b499df787ce0a9166744d10bc5e44eef9ddec16346ac22bc8c2f49e5cce
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 20, 2026.

Transparency log

Release files / pii_mcp-1.5.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL pii_mcp-1.5.1-cp310-abi3-macosx_11_0_arm64.whl
Size 794.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3b5d9ef2c1422de5b4b105c7859fb7599ffac3cfb1a7250d838d3bcef6c7aff9
BLAKE2b-256 checksum
How to use checksums
811a1e080bc641e1c489ec8cf52355a4989d509eb848e12a603e50dc26c2ec49
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 20, 2026.

Transparency log

Release files / pii_mcp-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pii_mcp-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 840.6 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b4dfdf919e2e4cbf8f2e670735993896d6c1a8f3438755dcf68dd31138c90293
BLAKE2b-256 checksum
How to use checksums
00c4178928f4c5fe92be37e8376d33ce480433aafa1aec53504417603a5a8438
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 20, 2026.

Transparency log

Release history Release notifications | RSS feed

1.10.0

7 release files

1.9.1

7 release files

1.9.0

7 release files

1.8.1

7 release files

1.8.0

7 release files

1.7.1

7 release files

1.7.0

7 release files

1.6.0

7 release files

1.5.5

7 release files

1.5.4

7 release files

1.5.3

7 release files

1.5.2

7 release files

This release

1.5.1 This release

7 release files

1.5.0

7 release files

1.4.0

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