Skip to main content

PyPI Python License mloda

mloda-pii

mloda-pii is a Claude Code hook that replaces identifiers (emails, phone numbers, IBANs, IP addresses, your own dictionary entries) in tool results with tokens such as PII_EMAIL_... before the model sees them. Your local tools and Claude's replies on your screen keep the real values. Every token is a keyed HMAC-SHA256, computed through mloda. It guards against accidental exposure and does not see everything the model gets; see Limits below.

The package also ships a mloda FeatureGroup that tokenizes a string column the same way, without a license key.

Setup

uv tool install "mloda-pii[hook]"   # or: pip install "mloda-pii[hook]" into a virtualenv that stays in place
cd your-project
mloda-pii init invite.txt           # the invite file, '-' for stdin, or the token itself

Then restart Claude Code. init creates the master key, stores and verifies the license, runs the hook once on a test value, and only then registers it in .claude/settings.local.json. It also creates .mloda-pii/dictionary.txt for names and company-specific IDs to detect, kept out of git. Running it again is safe.

Option Effect
--user Register in ~/.claude/settings.json, for every project.
--project Register in the committed .claude/settings.json; every teammate installs mloda-pii and runs init --project.
--mode local No license key, see below.
--key-file <path> Import an existing master key instead of creating one.

Ask for an invite at info@mloda.ai or via mloda.ai.

Modes

Mode License key Needs
licensed (default) Required. Without a valid license every gated event blocks: tool results are withheld, tool calls denied, prompts blocked. An invite.
local None. An anonymizer-rs anonymizer binary on PATH or in ANONYMIZER_BINARY; ask at info@mloda.ai.

Both modes give the same tokens from the same master key; there is no fallback between them.

Back up your master key

The master key lives in ~/.config/mloda-pii/master.key. Back it up: every token depends on it, and a lost key changes all of them. init never overwrites an existing key.

Everyday commands

  • mloda-pii status: the key, the license and its expiry, where the hook is registered, the last events. Exits 1 when something is missing.
  • mloda-pii uninstall: removes the hook entries (same --user / --project flags). --purge also deletes the master key and the stored license, after asking (--yes skips it).
  • mloda-pii license install | status | remove: manage the license alone.
  • mloda-pii stats: per-day counts from the audit log, which never holds values.

A prompt that contains raw identifiers is blocked and a pseudonymized copy is shown to resubmit.

Variable Effect
MLODA_PII_KEY_FILE Master key file (default ~/.config/mloda-pii/master.key).
MLODA_PII_DICTIONARY Literals and re: patterns to detect (default .mloda-pii/dictionary.txt).
MLODA_PII_NAME_HEURISTIC 1 enables a capitalised-bigram name detector; otherwise only dictionary names are detected.
MLODA_PII_WRAP_BASH 1 routes failed Bash output through the hook too.
MLODA_PII_TOKEN_STYLE hex (default, PII_EMAIL_<32 hex>) or readable (PII_EMAIL_1, numbered per project).
MLODA_PII_FAIL_CLOSED On by default. 0 lets an action pass when the hook itself fails; a license block always blocks.
MLODA_PII_REVERSE_MCP 1 also puts real values back into MCP tool input; a remote MCP server then receives them.
MLODA_PII_AUDIT_LOG Audit log path (default ~/.local/state/mloda-pii/audit.jsonl); off disables it.
MLODA_LICENSE_FILE, MLODA_LICENSE_KEY Take precedence over the stored license.

Command options: mloda-pii <command> --help.

The FeatureGroup

from mloda.user import Feature, Options

feature = Feature("email__pii_anonymized", Options(context={"pii_key_file_env": "KEY_FILE"}))

<column>__pii_anonymized returns the 64-hex keyed HMAC-SHA256 token of a string column. pii_key_file_env names the environment variable that holds the path to the master key file. It needs the anonymizer-rs binary, like the local mode.

Limits

  • The hook guards against accidental exposure, not a model that tries to recover values: a Bash command gets the real value and can return it disguised, which detection misses.
  • Hooks never see @file mentions, CLAUDE.md and memory files, the client's own reminders, images or compaction summaries; those reach the model unchanged.
  • A crashed or timed-out hook on a tool result lets the original output through.
  • The values of one event sit in a private temporary Parquet file (under $XDG_RUNTIME_DIR, else /dev/shm, else the temp dir) for the duration of the call.
  • The license gate is a speed bump: the local mode makes the same tokens without one, by design.
  • Tokens are still personal data under GDPR; whoever holds the key can recompute them.
  • The local vault under ~/.local/state/mloda-pii/ (or $XDG_STATE_HOME) maps tokens back to raw values; nothing expires it, and uninstall --purge leaves it in place.

License

mloda-pii is proprietary and source-available, under the mloda-pii License in the LICENSE file of the package. Use in your daily work is permitted with a license key from mloda, also when the key is free, or in the local mode with an anonymizer binary mloda provided. The license text is binding over this summary.

  • mloda: declarative data and feature access, the framework mloda-pii runs on.
  • mloda-registry: plugins and guides for mloda.

Metadata

Release files for mloda-pii 0.3.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 mloda-pii 0.3.0
File Size Uploaded Provenance
mloda_pii-0.3.0.tar.gz 46.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mloda-pii 0.3.0
File Interpreter ABI Platform
mloda_pii-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.0 kB

Release files / mloda_pii-0.3.0.tar.gz

Download URL mloda_pii-0.3.0.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6d9020f167ca1dda307b203757dbe6e782516ac3b29c220211e743d340e5f562
BLAKE2b-256 checksum
How to use checksums
fdb426a5e059bd87b4170b28bca5505b20da53399933de79c8eb2cd96e24c8af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / mloda_pii-0.3.0-py3-none-any.whl

Download URL mloda_pii-0.3.0-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a58e670c926424f76bb1f79d09d587a0d51a58686f5eca61de59d8e747bad2d
BLAKE2b-256 checksum
How to use checksums
21f83466510bb7a32c32031faa8bbb73cbe722ed5c1dec83754e9da3dfcd560b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for mloda-pii 0.3.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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