Skip to main content

pii-mcp

Pattern-based PII redaction for MCP servers (regex + checksums). Masks emails, IBANs, cards, BICs, MACs, IMEIs, IPs, coordinates, BSNs, Belgian national register numbers, US SSNs and ITINs, UK National Insurance and NHS numbers, German tax IDs, Dutch BTW-ids, Dutch and German passport/ID numbers, phones, street + house number addresses, Dutch and UK postcodes, and Dutch license plates in tool results. Also masks credentials (API keys, JWTs, Bearer tokens) as [SECRET]. Language packs: en, nl, and opt-in de.

PyPI npm CI License: MIT GitHub stars

If pii-mcp saves you time, a ⭐ helps others find it.

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]

For runnable scripts including a FastMCP server and payload scrubbing, see the examples/ directory.

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"])
scrub_text("ops@foro.sh ada@example.com 123456782", types=["email"], allow=["ops@foro.sh"])
# ops@foro.sh [EMAIL] 123456782

types masks only the listed PiiType names (default: all). allow lists exact values (case-insensitive) left unmasked; it never exempts a secret. PiiScrubMiddleware takes both too.

Scope

Pattern Tier 1 only: structured identifiers that regex and checksums can reach. Aligned with AP: wat zijn persoonsgegevens where that layer applies. Free-text health data (allergies), photos/audio/ video, and unstructured klant-/personeelsnummers stay out of scope.

person is pattern / key-aware when available (issue #52); until then the count stays 0. Prose name NER is out of band — this package does not ship an in-process NER model. Decimal/DMS location coordinates stay here; free-text place names do not.

Using with foro / Presidio

Layer Owner
Pattern / checksum / language packs / MCP middleware this package (Tier 1)
PERSON / LOCATION NER on API paths Presidio or another NER sidecar (Tier 2)

Live MCP gates in user containers should run Tier 1 only (no model). On platforms such as foro, keep NER in one Presidio sidecar on API paths — do not stack a second in-process NER beside it.

AP coverage (pattern layer)

AP example / category Detector Notes
e-mail / contact email, phone Incl. Unicode (EAI/IDN) email
IP-adres ip Indirect identifier
Locatiegegevens location Decimal and DMS lat/lon
Financiële gegevens iban, credit_card, bic, vat_id NL BTW / DE USt-IdNr
BSN / nationaal ID bsn, passport NL passport/NIK; BE rijksregisternummer (nl pack); DE ID card/passport (de pack)
Nationaal ID (US / UK) ssn, tax_id US SSN/ITIN, UK NINO (en pack)
Gezondheidsgegevens (health ID) ssn UK NHS number, grouped (en)
Online / device IDs mac, imei IMEI: grouped forms + Luhn
Adres address Street + number; NL/UK postcode
Kenteken license_plate nl pack
Naam person Pattern/key-aware when available (#52); prose NER out of band
Credentials (not PII) secret Vendor-prefixed keys, JWTs, Bearer credential; all packs
Pasfoto, allergieën, koopgedrag, camera Media / free text

Packages

Runtime Path Install
Python src/pii_mcp pip install pii-mcp
TypeScript typescript/ npm install pii-mcp
Gate (JS) typescript/gate/ COPY pii-gate.mjs (zero npm deps)
Rust core crates/pii-core shared by both (PyO3 / N-API)

Tier 1 gate contract for foro user containers (caps, placeholders, binary skip): docs/tier1-gate.md.

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

Contributing

See CONTRIBUTING.md for setup, how to add a detector, and the checks a PR must pass.

Metadata

Release files for pii-mcp 1.13.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.13.0
File Size Uploaded Provenance Actions
pii_mcp-1.13.0.tar.gz 286.7 kB With provenance Details for pii_mcp-1.13.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pii-mcp 1.13.0
File Actions
pii_mcp-1.13.0-py3-none-any.whl Python 3 none any Details for pii_mcp-1.13.0-py3-none-any.whl
pii_mcp-1.13.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pii_mcp-1.13.0-cp310-abi3-win_amd64.whl
pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
pii_mcp-1.13.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for pii_mcp-1.13.0-cp310-abi3-macosx_11_0_arm64.whl
pii_mcp-1.13.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for pii_mcp-1.13.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 4.9 MB

Release files / pii_mcp-1.13.0.tar.gz

Download URL pii_mcp-1.13.0.tar.gz
Size 286.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d524cdba28f47e9eed306cf477f6f778fc209059fdfc11afd7e35d713e17b95c
BLAKE2b-256 checksum
How to use checksums
5782b8d7db719cca17b87c645d69826c4fb5f73e690c5701b8e80d92820d2c60
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-py3-none-any.whl
Size 35.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97c4937a111109102a9d97a162d1d0409718a7323eba2484dcad43786e57f5bc
BLAKE2b-256 checksum
How to use checksums
e451879fb39bf4bf54196b44c81eb60cc2a00963b5257c195852e61423202c69
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-cp310-abi3-win_amd64.whl
Size 850.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
97917301a24bae322df0478360f6801007d2255531512a68d993a6a05e6ba7f1
BLAKE2b-256 checksum
How to use checksums
d8ec023c9240c4655f1bdc9222d26c475fe47aabd2cda5517c43f26c06e40700
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 999.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a66e360ece362fd95e5aaf3d461ad4cf7f0dc92d5c801e0360a5fb76e8eac927
BLAKE2b-256 checksum
How to use checksums
e47b33094d0644d08fe6192d79d5078a1ff07e9aa1b4a47a4649672579a9a84f
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 969.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
eb7fc12fb8ae49e6e40517768e59e287795f8b8e3d322cfefbcd3e94ec3532e3
BLAKE2b-256 checksum
How to use checksums
ab6c3481fa5cacb2cf856f4eff6250f66978925e6106c3006d9fa8884710863f
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-cp310-abi3-macosx_11_0_arm64.whl
Size 878.5 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0dabb28340b04b76de631d845687683a6f120aea9e5fa23e82b529172bf76e20
BLAKE2b-256 checksum
How to use checksums
612b15d745886261b9d6f9e6fe15e904aec1b4c1f507f641abd573393a22a97a
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 Nov 3, 2026.

Transparency log

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

Download URL pii_mcp-1.13.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 925.1 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b576478eff2acd4126065091a363f3abcaa780817072247f259d614c7f1cbd10
BLAKE2b-256 checksum
How to use checksums
3c4cefe044a6f39c094c977d029e29c91c547599c8857038ddc65eba154132c9
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 Nov 3, 2026.

Transparency log

Security for pii-mcp 1.13.0

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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pii_mcp-1.13.0.tar.gz

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 Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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