x402 Universal Payer
io.github.nirholas由 GitHub 账号 nirholas 发布v1.0.2更新于 Oct 24, 2026
Pay any x402 endpoint on the open web: auto-paying bridge with Bazaar discovery and spend caps.
概览
让助手调用 x402 付费网页端点,在支出上限内自动签名并结算 EVM 链或 Solana 上的 USDC 付款。
- 可以做什么
- 该桥接提供 call_paid_endpoint,可访问任意 URL,若服务端返回 402 Payment Required 则自动付款,并返回响应与结算凭证。它还会发现 x402 Bazaar 上列出的服务,为每个资源注册一个动态工具,并提供 list_bazaar_tools 与 refresh_bazaar 用于查看和重新加载列表。付款支持 EVM exact、EVM 批量结算和 Solana exact 方案,批量通道状态会跨重启持久化。
- 适用场景
- 当助手需要按请求付费使用 x402 计费的 API 或数据服务,并希望自动付款且带有单次与会话限额时使用。对免费端点或不涉及花钱的任务没有帮助。
- 运行要求
- 通过 npx @three-ws/mcp-bridge 以 stdio 在本地运行,需要 Node.js。必须提供 MCP_BRIDGE_EVM_PRIVATE_KEY 或 MCP_BRIDGE_SVM_PRIVATE_KEY 之一,并充值 USDC。可选变量用于设置上限、允许列表、发现数量、RPC 覆盖和通道存储。需要访问目标端点与 Bazaar 的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 x402 Universal Payer,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
@three-ws/mcp-bridge
One MCP server that can pay any x402-paid endpoint on the open web — the universal x402 payer for AI agents.
[npm] [downloads] [license] [node] [MCP Registry] [three.ws]
Quick start · Security · Tools · Environment · three.ws
A Model Context Protocol server that can pay any x402-paid endpoint on the open web. Point your agent at a URL that answers
402 Payment Required; the bridge signs, pays, retries, and hands back the response plus the settlement receipt — EVM exact, EVM batch-settlement, and Solana exact, all behind hard spending caps. It also pre-loads a tool per service discovered on the Coinbase x402 Bazaar, so the entire paid-API economy shows up in your tool list.
Quick start
Claude Code:
Use -e MCP_BRIDGE_EVM_PRIVATE_KEY=0x... instead (or as well) to pay on Base and other EVM chains. At least one key is required.
Claude Desktop (claude_desktop_config.json) or Cursor (~/.cursor/mcp.json):
Restart the client and ask for something like "pay $0.01 on Base for a weather report" — the model picks a matching Bazaar tool (or call_paid_endpoint), and the bridge auto-pays via x402.
Security and spending controls
This server holds private keys and spends real USDC. Read this section before configuring it.
- Use a dedicated, low-balance wallet.
MCP_BRIDGE_EVM_PRIVATE_KEY/MCP_BRIDGE_SVM_PRIVATE_KEYshould never be a main wallet. Fund it with only what you are willing to let an agent spend. - Per-call cap. Any payment above
MCP_BRIDGE_MAX_PRICE_PER_CALL_ATOMIC(default100000= $0.10 USDC) is refused before a payload is signed, with an error naming the network, asset, and cap. - Session ceiling. Cumulative spend per process is capped by
MCP_BRIDGE_MAX_TOTAL_ATOMIC(default1000000= $1.00 USDC). This bounds the damage of a looping or prompt-injected agent: once the ceiling is reached, every further payment aborts until restart. The accumulator reserves atomically, so concurrent calls cannot jointly overshoot it. - Payee allowlist. Set
MCP_BRIDGE_ALLOWED_PAYTO(comma-separated addresses) to refuse payment to any recipient you have not explicitly trusted. - SSRF guard. Every outbound payable URL — whether supplied by the model or by a Bazaar listing — passes one chokepoint that enforces an https-only scheme policy, resolves the hostname, and rejects the request if any resolved address is private, loopback, link-local (including
169.254.169.254cloud metadata), CGNAT, ULA, or unspecified. Literal-IP hosts are checked directly; redirects are never followed (a public host cannot 3xx the bridge into internal infrastructure).http://is available only behind the explicitMCP_BRIDGE_ALLOW_HTTP=1dev opt-in. - Host allowlist. Set
MCP_BRIDGE_ALLOWED_HOSTS(comma-separated hostnames) for strict mode: only listed hosts can be paid at all. - Deposit caps. Batch-settlement channel deposits are bounded by
MCP_BRIDGE_MAX_DEPOSIT_ATOMIC(default $5.00) regardless of what a server requests. - Honest annotations. Every paying tool is annotated
readOnlyHint: false,idempotentHint: false,openWorldHint: true, so MCP hosts apply their strictest confirmation policy. Retrying a paid call is a new charge.
What it exposes
On startup the bridge registers:
Tools whose prices all exceed the per-call cap are filtered out at discovery time, so the model never sees a tool it cannot afford.
Tool annotations
Every tool carries MCP ToolAnnotations so hosts can apply the right confirmation policy:
call_paid_endpointand every dynamicpaid_*tool:readOnlyHint: false,destructiveHint: false,idempotentHint: false,openWorldHint: true. These spend real USDC — each call settles a payment (capped byMCP_BRIDGE_MAX_PRICE_PER_CALL_ATOMIC), and retrying is a new charge. They never delete or overwrite caller state, hence not destructive.list_bazaar_tools:readOnlyHint: true,idempotentHint: true,openWorldHint: false. Pure in-process cache read; free, no network.refresh_bazaar:readOnlyHint: false,destructiveHint: false,idempotentHint: false,openWorldHint: true. Free (no payment), but it mutates the registered tool set from the live Bazaar feed, so repeat calls can differ.
Tool results that are plain objects are returned as both a JSON text block (backward compatible) and structuredContent for typed clients.
Payment schemes
Payment paths registered on the buyer client:
eip155:*→BatchSettlementEvmScheme(preferred when the server advertises it; voucher-based, no per-call gas)eip155:*→ExactEvmScheme(used when the server advertisesscheme: "exact")solana:*and the x402 v1 Solana networks (solana,solana-devnet,solana-testnet) →ExactSvmScheme/ExactSvmSchemeV1(USDC SPL transfer co-signed by the advertised fee payer), registered together byregisterExactSvmScheme(). v1 is the wire format most of the open x402 bazaar still speaks; the client always prefers v2 when a seller advertises both. The spending-cap hook reads eitheramount(v2) ormaxAmountRequired(v1) so both are capped the same way.
Batch-settlement channel state is persisted to ~/.x402-mcp-bridge/channels/client/ so client restarts do not re-deposit on the next call.
Environment
MCP_BRIDGE_* key vars also fall back to EVM_PRIVATE_KEY / SVM_PRIVATE_KEY if you already have those set.
Spending cap behavior
The pre-payment hook inspects the selected accepts entry and aborts payload creation if the amount exceeds the per-call cap, the payee is outside the allowlist, or the session ceiling would be crossed. The tool result then carries a clear error message naming the network, asset, and the limit that was hit — useful for the model to decide whether to ask you to raise it.
Inspecting without a client
The inspector connects over stdio and lists the static tools (call_paid_endpoint, list_bazaar_tools, refresh_bazaar) plus one dynamic tool per discovered Bazaar entry.
Programmatic use
Any Node module can consume an x402 endpoint through the same buyer client:
The same spending caps, SSRF guard, and channel-storage rules apply. Idle batch channels can be refunded out-of-band with the @x402 SDK's client.refund(resourceUrl, { amount }).
Tests
The hermetic suite generates throwaway keypairs in-process; no real keys or funds are ever involved.
License
All rights reserved. See LICENSE.
来源:mcp-bridge/README.md,提交 800052e
工具
0版本历史
1- v1.0.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分