
Presidio Hardened X402 Mcp
io.github.presidio-v由 GitHub 账号 presidio-v 发布v0.3.0更新于 Nov 1, 2026
Pre-payment safety gate for x402 agents: PII screening, spend policy, replay checks before signing.
概览
本地 MCP 支付前置闸门:在代理签署 x402 付款前筛查元数据中的个人身份信息、执行消费限额并检测重复付款。
- 可以做什么
- 筛查并脱敏付款元数据(资源 URL、描述、原因)中的个人身份信息,可限定实体类型
- 按单笔、滚动窗口和单端点美元上限检查消费策略,成功时记录该笔支出
- 用规范字段的 HMAC 指纹检测重复付款,状态可存于内存或 Redis
- 在配置密钥与路径后输出签名的付款决策记录和 HMAC 链式审计日志
- 适用场景
- 适用于代理会签署 x402 付款、且希望在资金或元数据离开主机前对载荷中的个人信息、预算超支和重复付款做默认拒绝检查的场景。它用于与支付执行、端点安全类服务器配合,而非替代它们。
- 运行要求
- 需要 Python 3.10 或更高版本,通过 uvx 从 PyPI 本地运行。所有环境变量均为可选,默认提供无网络、无配额、不存储个人信息的进程内模式。限额、重放 TTL、Redis 地址、审计路径、远程筛查地址与 API 密钥、签名密钥通过 PRESIDIO_X402_MCP_* 与 PRESIDIO_X402_* 变量设置。
安装
在 SourceWeft 中
- 打开 控制台中的 Presidio Hardened X402 Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
presidio-hardened-x402-mcp
[PyPI version] [Python] [GitHub release] [License: MIT] [CI] [OpenSSF Scorecard] [OpenSSF Best Practices]
Pre-payment safety gate for x402 — agents call screen_payment_metadata(...), check_payment_policy(...), and check_payment_replay(...) before signing, catching PII, budget overruns, and duplicate payments before metadata or money leaves the agent host.
Part of the presidio-hardened-* toolkit family. Thin MCP (Model Context Protocol) adapter over the presidio-hardened-x402 library, pinned to parent 0.13.x (presidio-hardened-x402>=0.13.0,<0.14.0). 0.13.0 is the first parent that can record a control as NOT_EVALUATED, which signed decision evidence needs; it also includes the 0.11.1 fix for the percent-encoded PII redaction bypass, which remains a security floor.
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 small default-deny gate before payment leaves the agent host. Three tools expose the parent library's stable pre-payment controls: PII redaction, spending policy, and replay detection. Since 0.3.0 each decision can also be emitted as a signed payment-decision@1 record that a third party verifies offline (see Signed decision evidence). The tools are designed to compose with payment-execution and endpoint-safety MCP servers (x402station, Coinbase x402, Sardis, ...), while other parent-library surfaces — evidence-ref@1 verification of inbound evidence, the v0.9.1 SLO broker, the v0.10.0 settlement-ref@1 treasury binding, and the v0.11.0 CapabilityEnforcer — stay in the Python library unless an MCP tool explicitly wraps them later.
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:
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.
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.
entities (optional list of Presidio entity types) narrows detection to a whitelist. Field-length caps mirror the screening-api wire contract that remains stable through parent 0.7.x: resource_url ≤ 2048, description ≤ 4096, reason ≤ 4096 characters. Oversized inputs raise ValueError.
check_payment_policy(resource_url, amount_usd, prior_decision_refs?)
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.
The URL is screened first and only the redacted URL reaches the policy engine, so no raw URL lands in the parent's logs. Per-endpoint limits match on that redacted URL; keep PII out of configured endpoint prefixes. If screening fails, the gate denies without recording spend.
With signed evidence enabled, both outputs also carry decision_ref. prior_decision_refs (optional, up to 8) links refs this server returned earlier for the same payment — typically the one from screen_payment_metadata — into the signed record; a ref this process did not issue is refused before any spend is recorded.
check_payment_replay(resource_url, pay_to, amount, currency, deadline_seconds, prior_decision_refs?)
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.
decision_ref and prior_decision_refs behave as for check_payment_policy.
Signed decision evidence
The audit log (PRESIDIO_X402_MCP_AUDIT_PATH) is HMAC-chained: tamper-evident to whoever holds PRESIDIO_X402_CHAIN_KEY, and to nobody else. From 0.3.0 every tool decision — allow and block alike — can also be written as a signed payment-decision@1 record, built and signed by the parent library (build_payment_decision_content, build_decision_evidence) and checked by anyone with the public key (verify_decision_ref). The audit log is still written; the records go alongside it, never instead of it.
Verify offline with the parent's CLI against a trust store that pins the public key under the signer name:
Without a key the server behaves exactly as 0.2.x — audit log only — and logs one WARNING at startup saying signed evidence is disabled. A key without PRESIDIO_X402_MCP_DECISION_PATH, an unreadable key file, or a key the signer rejects is logged at ERROR and also leaves evidence off. Set PRESIDIO_X402_MCP_REQUIRE_EVIDENCE_KEY=1 to refuse to start in any of those cases instead. Once running, a failed write is logged and the gate's answer stands: a record of a decision never reverses the decision.
What a record says. payment-decision@1 always carries all five controls (pii → trusted_wallet → policy → replay → mpa). Each record holds real verdicts only for what its tool ran and NOT_EVALUATED for the rest: every tool screens the URL (pii), check_payment_policy adds policy, check_payment_replay adds replay; trusted_wallet and mpa are never evaluated here. NOT_EVALUATED never fails a decision and never claims a pass, so the controls block alone says which gate decided. Chain the three with prior_decision_refs to get one linked set per payment.
What it never contains. Raw resource_url, description, or reason; only the URL's scheme and host, the entity-type labels found, and hashes (policy snapshot, replay fingerprint, payment details). The gates see PII in the URL they are handed but pay it unchanged, so their PII verdict is PII_WARNED; screen_payment_metadata returns redacted strings and records PII_REDACTED. Fields an MCP tool never sees — payer wallet, network, the raw 402 offer — are recorded as unspecified / not-presented. The records carry no capability-chain parents, so the ADR-0002 top-level parents field is never set.
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:
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.
What none of these gates can see: a request body the agent made up. The three tools screen the 402 challenge's metadata and the spend; they never see the body the agent sends to a POST route. Independent measurement of the x402 and MPP catalogues (probe402, MCRI #001, 1 September 2026) found 1,521 of 8,056 listed POST routes — 18.9% — publish no usable request example, and 72% of those still return a payable quote at the wall. A route like that is listed, priced, and not machine-executable from the published contract. An agent that fills the gap by synthesising a body is guessing, and a guessed body is where user data enters the request unscreened. Posture: if the catalogue entry carries no request example or schema, stop at the 402 quote and surface it; do not invent a body to get past the wall. Put that rule in the agent's instructions — it is a decision the agent makes before any of these tools run.
Combined snippet: preflight → screen → pay
Endpoint-safety and payload-safety are independent signals — calling both is what you actually want before signing. Configure the two MCP servers side-by-side:
Agent flow before signing a payment (pseudocode — each step is one MCP tool call):
The two servers are developed independently, on purpose — keeping the signals uncorrelated is the point. See x402station-mcp for the preflight tool's full output schema and warning catalog.
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, evidence-ref verification, SLO broker, and audit-chain details. - This MCP release exposes the same three tools as
0.1.1. 0.3.0 adds signedpayment-decision@1emission from those tools and an optionalprior_decision_refsargument on the two gates; the rest of the parent SLO/evidence/capability surface is not promoted into MCP. - 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 on the open-source baseline of the PRESIDIO hardened-family SDLC (report · PDF). The controls measured for it, and any open gaps, are its row in the applicability matrix.
Roadmap (next 12 months)
- Now / in flight — OpenSSF Best Practices silver and a Scorecard above 7:
governance docs, a real CodeQL job alongside Bandit, least-privilege workflow
tokens, and Atheris fuzzing of the configuration validators. Closing the
remaining findings in
SECURITY-AUDIT.md. - Next — hash-pinned CI dependencies, ideally as a family-wide change rather than in this repo alone.
- Later (under evaluation) — signed releases with build provenance; tracking
the MCP specification as it stabilises; exposing the parent library's
capability-grant@1enforcement as a fourth tool, if agent demand justifies the added surface.
Governance, Architecture, Security
- Governance — roles, decision process, and how to become a maintainer.
- Architecture — components, trust boundaries, and the core processing path.
- Assurance case — the security claims and the evidence backing each one.
- Security policy — supported versions and how to report a vulnerability.
- Contributing — review bar, test policy, and verification commands.
- Stability guarantees — what counts as the public API and what may not change.
来源:README.md,提交 911cfcd
工具
0版本历史
3- v0.3.0最新Oct 18, 2026
- v0.2.0Sep 30, 2026
- v0.1.1Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
