x402 Wallet

io.github.nirholas由 GitHub 账号 nirholas 发布v0.2.3更新于 Oct 24, 2026

Self-custodial x402 wallet for AI agents: pay any service in USDC or $THREE from your own key.

已验证STDIO仅桌面金融商业与电商

概览

AI 生成的概览

面向 AI 助手的自托管 x402 钱包:发现付费服务、查看价格,并用你自己的 Solana 密钥以 USDC 付款。

可以做什么
查询钱包地址与实时 SOL/USDC 余额,并从本地账本文件读取按商户和日期汇总的支出报告。在实时 x402 集市中搜索付费 HTTP 或 MCP 服务,可按类型、网络和最高价格筛选。在不付款的情况下查看某个端点的 402 付款要求,包括方案、网络、资产、价格和收款地址。用你的 Solana 密钥以 USDC 支付 x402 端点并返回结果,受单次和全局美元上限约束。调用 17 个价格固定的 three.ws 服务,涵盖天气、碳排、域名 RDAP、研究、图书、新闻、交通和地点。
适用场景
当助手需要从 Solana 上的 x402 服务购买数据或 API 结果,且你愿意为一个钱包充值时使用。适合需要在付款前先确认价格,或希望使用固定价格的具名工具而非自行拼装付款调用的代理。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 20 或更高版本。需要 Solana 主网 HTTPS RPC 端点;SOLANA_RPC_URL 默认使用公共集群,适合读取但不建议用于付款流量。付款需要一个持有 USDC 的 Solana 钱包,以 base58 形式的 SOLANA_SECRET_KEY 或单次调用的 secret 提供,也可改用 three.ws 会话令牌。可选设置包括 MAX_PAY_USD、REQUIRE_CONFIRM、THREE_WS_BASE 和 X402_MCP_LEDGER_PATH。
安装前请注意
SOLANA_SECRET_KEY 是控制真实资金的私钥,获得它的人可以花掉钱包中的 USDC。付款会在 Solana 主网上转移真实资金,请把 MAX_PAY_USD 设低并保持 REQUIRE_CONFIRM 开启。服务器会先探测 402 价格,超过上限时在付款前拒绝,但误发的调用仍可能在上限内花钱。付款记录会写入本地账本文件。会话令牌模式下由 three.ws 平台钱包在该会话的预算内代为签名。

安装

在 SourceWeft 中

  1. 打开 控制台中的 x402 Wallet,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[three.ws]

@three-ws/x402-mcp

Give any AI agent a self-custodial x402 wallet — discover, inspect, and pay any paid service in USDC from your own Solana key.

[npm] [license] [node] [MCP Registry] [three.ws]


A Model Context Protocol server that turns any AI assistant into an autonomous economic agent on the x402 network. Search the live bazaar for paid services, read an endpoint's price before committing money, and pay_and_call any x402 service in USDC — settled on Solana with your own key, never a custodial wallet.

This is the buyer side of the three.ws agent economy. The payment dance and Solana exact-scheme signing are handled by the real @x402/* libraries — nothing is mocked.

Install

bash
npm install @three-ws/x402-mcp

Or run with npx:

bash
SOLANA_SECRET_KEY=<base58> npx @three-ws/x402-mcp

Quick start

Claude Code, one line:

bash
claude mcp add x402 --env SOLANA_SECRET_KEY=<base58> -- npx -y @three-ws/x402-mcp

Claude Desktop / Cursor (claude_desktop_config.json or mcp.json):

json
{	"mcpServers": {		"x402": {			"command": "npx",			"args": ["-y", "@three-ws/x402-mcp"],			"env": {				"SOLANA_SECRET_KEY": "<base58 secret of the wallet that holds USDC>",				"SOLANA_RPC_URL": "https://your-rpc-provider",				"MAX_PAY_USD": "1"			}		}	}}

SOLANA_SECRET_KEY is only needed to spend (pay_and_call, and x402_wallet defaulting to your wallet). find_services and inspect_endpoint work with no key.

Tools

ToolTypeWhat it does
x402_walletread-onlyA wallet's address + live SOL/USDC balance. Defaults to your signer wallet — confirm funds before paying.
find_servicesread-onlySearch the live x402 bazaar (PayAI + Coinbase CDP) for paid HTTP/MCP services with prices.
inspect_endpointread-onlyRead any endpoint's 402 payment requirements (scheme, network, asset, price, pay-to) without paying.
pay_and_callexecutionPay an x402 endpoint in USDC from your Solana key and return its result. Bounded by MAX_PAY_USD.
spending_reportread-onlyTotals of everything pay_and_call and the named tools below have paid, by merchant and by day.

Plus 17 named tools, one per fixed three.ws x402 service, each cheaper for a model to call correctly than composing a raw pay_and_call(url):

ToolPriceEndpoint
weather_forecast$0.001/api/x402/weather-guard-forecast
weather_go_no_go$0.002/api/x402/weather-guard-decision
carbon_now$0.001/api/x402/carbon-now
carbon_best_window$0.002/api/x402/carbon-best-window
domain_rdap_check$0.001/api/x402/domains-check
domain_rdap_check_bulk$0.005/api/x402/domains-bulk
research_search$0.002/api/x402/research-search
research_paper$0.003/api/x402/research-paper
research_bibliography$0.005/api/x402/research-bibliography
book_search$0.001/api/x402/books-search
book_read$0.01/api/x402/books-read
news_wire_search$0.003/api/x402/news-wire-query
news_wire_poll$0.002/api/x402/news-wire-pulse
transit_plan$0.002/api/x402/transit-plan
transit_delays$0.001/api/x402/transit-delays
places_search$0.002/api/x402/places-search
places_detail$0.002/api/x402/places-detail

Each takes the same arguments as its endpoint (see src/tools.json for the full schemas) and pays with the same SOLANA_SECRET_KEY / session_token settlement modes as pay_and_call, gated by the same MAX_PAY_USD cap and REQUIRE_CONFIRM flag. Prefer a named tool over pay_and_call whenever one exists for the endpoint you need: the fixed schema and stated price make the model far less likely to misdial the call.

Safety

pay_and_call carries destructiveHint: true, so annotation-aware clients (Claude Code, Claude Desktop, Cursor) prompt before running it. Beyond the client hint, every payment is bounded server-side: it probes the 402 first and refuses if the price exceeds max_usd or MAX_PAY_USD (default $1) before any money moves, and with REQUIRE_CONFIRM on (default) the call refuses until re-issued with confirm: true. Only the Solana (solana:*) exact-scheme requirement is settled — with the key you control.

Input parameters

x402_wallet — address (optional base58; defaults to the signer wallet).

find_services — query (required), type (http | mcp, default http), network (CAIP-2 filter), max_price_usdc, limit (1–100).

inspect_endpoint — url (required), method (GET | POST), body (object).

pay_and_call: url (required), method (GET | POST), body (object), max_usd (lowers the cap for this call), secret (per-call signer override), confirm (must be true when REQUIRE_CONFIRM is on), session_token, token, idempotency_key.

It has two settlement modes:

  • Self-custodial (default). Signs with SOLANA_SECRET_KEY, or the per-call secret. You hold the key.
  • Session-governed. Pass session_token, a three.ws Payment Session token, and the platform wallet signs on your behalf while enforcing that session's budget, host allowlist, and per-transaction cap. No private key needed. Solana USDC and Base USDC sessions are both supported, and secret and token are ignored in this mode.

token selects the settlement asset: usdc (default), or three for the $THREE platform token when the endpoint advertises it. idempotency_key deduplicates a call, which is recommended with session_token so a retry cannot double-charge.

Example

jsonc
// inspect_endpoint — what does it cost? (no payment)> { "url": "https://three.ws/api/x402/vanity?prefix=ab" }{  "ok": true, "paid": true,  "accepts": [    { "scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "asset": "EPjFW…", "price": 50000 }  ],  "payable_with_this_wallet": true}
// pay_and_call — confirm:true required by default> { "url": "https://three.ws/api/x402/vanity?prefix=ab", "confirm": true }{ "ok": true, "paid": true, "payer": "Gx5E…", "price_usd": 0.05, "settlement": { … }, "result": { … } }

Examples

Runnable, no-payment examples live in examples/:

bash
node examples/list-tools.mjs      # every tool with its full input schemanode examples/inspect-price.mjs   # find_services + inspect_endpoint on live data

Both spawn this server over stdio and hit the real bazaar. Neither reads a key or calls pay_and_call, so nothing is signed and nothing is spent. See examples/README.md for expected output.

Protocol versions

pay_and_call speaks both x402 wire formats on the same Solana key: v2 (CAIP-2 network strings, e.g. solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp) and v1 (flat network strings, e.g. solana), the format most of the open x402 bazaar, and services built on the original x402/x402-fetch packages, still speak. When a seller advertises both, v2 is always preferred. Settlement receipts come back in the same shape (success, transaction, network, payer) regardless of which version paid, so nothing downstream needs to know which one was used.

Requirements

  • Node.js >= 20.
  • A Solana mainnet RPC endpoint (https; only http://localhost is allowed for dev). Public cluster works for reads; bring your own for payment traffic.
  • To pay: a Solana wallet holding USDC, as a base58 SOLANA_SECRET_KEY (or per-call secret).

Environment variables

VariableRequiredDefault
SOLANA_SECRET_KEYto pay only—
SOLANA_RPC_URLnohttps://api.mainnet-beta.solana.com
MAX_PAY_USDno1
REQUIRE_CONFIRMnotrue
THREE_WS_BASEnohttps://three.ws
X402_MCP_LEDGER_PATHno~/.three-ws/x402-mcp-ledger.jsonl

X402_MCP_LEDGER_PATH points at the append-only JSON-lines file every settled payment (pay_and_call and the named tools) is recorded to; spending_report reads it back.

Links


Part of the three.ws SDK suite — 3D AI agents, on-chain identity, and agent payments.
Website · Changelog · GitHub

来源:packages/x402-mcp/README.md,提交 914d712

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.2.3最新Oct 10, 2026
  2. v0.2.2Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分