MCP server exposing presidio-hardened-x402 PII screening, policy, and replay-guard tools to autonomous agents.
Project description
presidio-hardened-x402-mcp
Pre-payment PII screener for x402 — agents call screen_payment_metadata(...) before signing, catching emails, SSNs, phone numbers, names, and other personal data in payment metadata before it reaches the merchant.
Part of the presidio-hardened-* toolkit family. Thin MCP (Model Context Protocol) adapter over the presidio-hardened-x402 library.
Why this exists
x402 agentic payments routinely carry user-supplied free text — descriptions, memos, query-string parameters — straight through to merchants and facilitators. When an LLM agent generates that text, it can include PII the user never intended to share. Once the merchant logs it, retention is their decision, not yours.
This MCP server gives agents a one-call gate to screen and redact PII before the payment leaves the agent host. Three tools, designed to compose with payment-execution and endpoint-safety MCP servers (x402station, Coinbase x402, Sardis, ...).
Install & configure
Requires Python ≥ 3.10. Distributed on PyPI; recommended invocation via uvx (no global install).
Claude Desktop / Claude Code
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or the equivalent on your platform:
{
"mcpServers": {
"presidio-x402": {
"command": "uvx",
"args": ["presidio-hardened-x402-mcp"]
}
}
}
Cursor / Windsurf / Continue
Same shape — every MCP host accepts command / args / env. See your editor's MCP-server docs for the config-file path.
Environment variables
All optional. Defaults give a zero-config in-process mode with no quota, no network, and no PII storage.
| Variable | Purpose | Default |
|---|---|---|
PRESIDIO_X402_MCP_MODE |
regex (zero-setup) or nlp (needs [nlp] extra + a spaCy model) |
regex |
PRESIDIO_X402_MCP_MAX_PER_CALL_USD |
Max USD per single payment (policy gate) | unset → no limit |
PRESIDIO_X402_MCP_DAILY_LIMIT_USD |
Max USD per rolling window (policy gate) | unset → no limit |
PRESIDIO_X402_MCP_PER_ENDPOINT_JSON |
Per-endpoint cap, e.g. '{"api.foo.com": 5.00}' |
unset |
PRESIDIO_X402_MCP_WINDOW_SECONDS |
Rolling window for the daily limit | 86400 |
PRESIDIO_X402_MCP_AGENT_ID |
Label written into audit records | unset |
PRESIDIO_X402_MCP_REPLAY_TTL |
Fingerprint cache TTL (seconds) | 300 |
PRESIDIO_X402_MCP_REDIS_URL |
Use Redis for replay state instead of in-memory | unset |
PRESIDIO_X402_MCP_AUDIT_PATH |
Append-only JSON-L audit log path; omit to disable | unset |
PRESIDIO_X402_MCP_LOG_LEVEL |
DEBUG / INFO / WARNING / ERROR |
INFO |
PRESIDIO_X402_MCP_REMOTE_BASE_URL |
Enable HTTP-proxy mode for tool 1 — see Modes | unset |
PRESIDIO_X402_MCP_REMOTE_API_KEY |
API key for the remote screening service | unset |
PRESIDIO_X402_FINGERPRINT_KEY |
32-byte hex key for cross-process replay detection | unset (per-process) |
PRESIDIO_X402_CHAIN_KEY |
32-byte hex key for cross-process audit-chain HMAC | unset (per-process) |
Generate cross-process keys with openssl rand -hex 32.
Tools
screen_payment_metadata(resource_url, description, reason, entities?)
Detects and redacts PII in payment metadata. No side effects — safe to call repeatedly.
// Input
{
"resource_url": "https://api.foo.com/u/jane@example.com",
"description": "monthly fee for jane@example.com",
"reason": ""
}
// Output
{
"redacted_resource_url": "https://api.foo.com/u/<EMAIL_ADDRESS>",
"redacted_description": "monthly fee for <EMAIL_ADDRESS>",
"redacted_reason": "",
"entities_found": [
{ "entity_type": "EMAIL_ADDRESS", "field": "resource_url", "count": 1 },
{ "entity_type": "EMAIL_ADDRESS", "field": "description", "count": 1 }
],
"mode": "in_process"
}
entities (optional list of Presidio entity types) narrows detection to a whitelist. Field-length caps mirror the v0.4.0 wire contract: resource_url ≤ 2048, description ≤ 4096, reason ≤ 4096 characters. Oversized inputs raise ValueError.
check_payment_policy(resource_url, amount_usd)
Spending-policy gate. Records the spend on success — call exactly once, immediately before payment. Skipping the actual payment after a successful check inflates the daily-limit ledger until the window rolls over.
// Input
{ "resource_url": "https://api.foo.com/x", "amount_usd": 1.50 }
// Output (allowed)
{ "allowed": true }
// Output (denied — over per-call limit of $5.00)
{ "allowed": false, "reason": "...", "limit_usd": 5.00, "amount_usd": 6.00 }
check_payment_replay(resource_url, pay_to, amount, currency, deadline_seconds)
Duplicate-payment gate via HMAC-SHA256 fingerprint of the canonical fields. Records the fingerprint on success — call exactly once, immediately before payment.
amount is a string to preserve precision. Cross-process detection requires PRESIDIO_X402_FINGERPRINT_KEY (and optionally PRESIDIO_X402_MCP_REDIS_URL); otherwise each MCP server process keeps its own in-memory store.
// Input
{
"resource_url": "https://api.foo.com/x",
"pay_to": "0xabc...",
"amount": "1.50",
"currency": "USDC",
"deadline_seconds": 1700000000
}
// Output (first seen)
{ "is_replay": false, "fingerprint": "29aaf60f..." }
// Output (duplicate within TTL)
{ "is_replay": true, "fingerprint": "29aaf60f..." }
Modes
In-process (default). Wraps the local presidio-hardened-x402 library in the same process as the MCP server. No network, no API key, no quota. PII never leaves the agent host. Use this unless you have a specific reason not to.
HTTP-proxy. When both PRESIDIO_X402_MCP_REMOTE_BASE_URL and PRESIDIO_X402_MCP_REMOTE_API_KEY are set, screen_payment_metadata calls /v1/screen on the configured host (e.g. https://screen.presidio-group.eu) for centralized audit. On auth / quota / network failure, returns a structured { "error": "auth_error" | "rate_limit" | "unavailable", "detail": ..., "mode": "remote" } — never silently falls back to in-process. Tools 2 and 3 always stay in-process.
Composability
Designed to slot into agent flows alongside payment-execution and endpoint-safety MCP servers:
agent intent: pay https://api.foo.com/x with 1.50 USDC
│
├─ x402station preflight(url) ← is the ENDPOINT safe? (decoys, dead, traps)
│
├─ presidio-x402 screen_payment_metadata ← is the PAYLOAD safe? (PII)
├─ presidio-x402 check_payment_policy ← within budget?
├─ presidio-x402 check_payment_replay ← not a duplicate?
│
└─ pay()
screen_payment_metadata is read-only and safe to interleave anywhere. The policy and replay gates record state on call — sequence them immediately before payment.
Notes for developers
- Logs go to stderr (MCP clients capture stderr). stdout is reserved for JSON-RPC frames.
- The package is a thin adapter. All security logic lives in
presidio-hardened-x402— read its docs for the entity-type catalog, policy semantics, and audit-chain details. - When testing via
mcp-inspector --cli, bare numeric--tool-arg amount=1.50is auto-coerced to a float and rejected by the schema. Real MCP clients send proper JSON types; the tool'samountargument is a string to preserve precision. - Local dev:
uv venv && uv pip install -e ".[dev]" && pytest tests/.
License
MIT. See LICENSE.
Links
- This repo: https://github.com/presidio-v/presidio-hardened-x402-mcp
- Issues: https://github.com/presidio-v/presidio-hardened-x402-mcp/issues
- Parent library: https://github.com/presidio-v/presidio-hardened-x402
- Library on PyPI: https://pypi.org/project/presidio-hardened-x402/
- Requirements: PRESIDIO-REQ.md
- Security policy: SECURITY.md
- MCP spec: https://modelcontextprotocol.io
- x402: https://x402.org
SDLC
This repository is developed under the Presidio hardened-family SDLC: https://github.com/presidio-v/presidio-hardened-docs/blob/main/sdlc/sdlc-report.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file presidio_hardened_x402_mcp-0.1.1.tar.gz.
File metadata
- Download URL: presidio_hardened_x402_mcp-0.1.1.tar.gz
- Upload date:
- Size: 190.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ce68ac17cfff74281a66b1683b2281a1c9c2a3cf843dafb743f50702d5c96f
|
|
| MD5 |
4d532fa288eec5bb125381253e9d9473
|
|
| BLAKE2b-256 |
ae2a41091d8459367e5475c7e32ecc4d6c85cd8dbc49c68c0d6c3afe4f44e3b2
|
Provenance
The following attestation bundles were made for presidio_hardened_x402_mcp-0.1.1.tar.gz:
Publisher:
release.yml on presidio-v/presidio-hardened-x402-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
presidio_hardened_x402_mcp-0.1.1.tar.gz -
Subject digest:
c6ce68ac17cfff74281a66b1683b2281a1c9c2a3cf843dafb743f50702d5c96f - Sigstore transparency entry: 1684220583
- Sigstore integration time:
-
Permalink:
presidio-v/presidio-hardened-x402-mcp@5cd68efbd2264147a619bf6fed60e51ace62c0e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/presidio-v
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cd68efbd2264147a619bf6fed60e51ace62c0e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file presidio_hardened_x402_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: presidio_hardened_x402_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd859c097c88a7245b9639b066c10a2caf6d86229adca44b45de60de0f3cbd1b
|
|
| MD5 |
dc09c55db6a09f60573f666efafaad12
|
|
| BLAKE2b-256 |
cf8c7a32c176f126398ae0e56f04eefdecc084dc105029a65819e66902be9f28
|
Provenance
The following attestation bundles were made for presidio_hardened_x402_mcp-0.1.1-py3-none-any.whl:
Publisher:
release.yml on presidio-v/presidio-hardened-x402-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
presidio_hardened_x402_mcp-0.1.1-py3-none-any.whl -
Subject digest:
dd859c097c88a7245b9639b066c10a2caf6d86229adca44b45de60de0f3cbd1b - Sigstore transparency entry: 1684220666
- Sigstore integration time:
-
Permalink:
presidio-v/presidio-hardened-x402-mcp@5cd68efbd2264147a619bf6fed60e51ace62c0e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/presidio-v
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cd68efbd2264147a619bf6fed60e51ace62c0e2 -
Trigger Event:
push
-
Statement type: