X402ai Mcp

io.github.ukenal由 GitHub 帳號 ukenal 發布v0.1.1更新於 Oct 26, 2026

Pay-per-call AI tools (embed, summarize, ask) from x402ai, paid in USDC on Base via x402.

已驗證STDIO僅桌面金融AI 與機器學習

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理呼叫 x402ai 的付費工具(embed、summarize、ask),每次呼叫以 Base 上的 USDC 計費,並附免費的 x402 端點檢查器。

可以做什麼
  • 計算文字嵌入向量、產生文字摘要或回答簡短問題,每次呼叫以 Base 上的 USDC 付費
  • 查看 x402ai 服務狀態,以及本次工作階段的花費與剩餘額度
  • 檢查任意 https 的 x402 端點:解析其付款要求,並執行 Coinbase 驗證器與商家查詢
  • 在試跑模式下只回傳價格報價,不簽章也不付款
適用情境
適合希望助理直接呼叫 x402ai 的嵌入、摘要或問答端點、又不想註冊帳號,並願意用專用錢包支付小額單次費用的情況。也適合在付款前先確認某個 x402 端點的收費方式。
執行需求
透過 npx 以 stdio 在本機執行,需要 Node.js 20 或更新版本。付費工具需要 X402AI_BUYER_PRIVATE_KEY,即持有 Base 上 USDC 的十六進位錢包私鑰(不需 ETH)。X402AI_MAX_SESSION_USD 設定每個行程的花費上限(預設 0.25);X402AI_DRY_RUN=1 時只報價不簽章。需要連線 api.x402ai.dev,使用 inspect 時另需連線 api.cdp.coinbase.com。
安裝前請注意
伺服器持有一把可花用真實資金的私鑰;請使用只放少量 USDC 的全新專用錢包,因為用戶端設定檔通常以明文保存該私鑰,且以你的使用者身分執行的其他程式可能讀取它。工作階段上限以行程計算、重新啟動即歸零且沒有上限,例如誤填 250 就是 250 美元,錢包餘額才是唯一硬性限制。呼叫失敗仍可能佔用工作階段額度。inspect 會把你提供的網址送給 Coinbase 的 CDP,請勿檢查需要保密的網址。工具輸出應視為不可信資料。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 X402ai Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

x402ai-mcp

A local MCP server that lets AI clients (Claude Desktop, Claude Code, Cursor and others) call the paid x402ai endpoints, paying per call in USDC on Base through the x402 protocol, plus a free inspector for any x402 endpoint.

It runs on your machine over stdio. You give it a buyer key; it answers each HTTP 402 payment challenge by signing a USDC authorization, and returns the result. Nothing is hosted for you and no account is needed.

Tools

ToolCostWhat it does
embed$0.01768-dimension text embedding (nomic-embed-text)
summarize$0.02Summary of the input text (small local LLM)
ask$0.04Short answer, 2-3 sentences; no web access, no memory, can be wrong
healthfreex402ai service status, plus this session's spend and remaining cap
inspectfreeTakes a URL: decodes its 402 challenge, runs Coinbase's x402 validator and a Bazaar merchant lookup

Paid tools take one input string of up to 3,000 characters. health and inspect need no key.

Before you start: use a dedicated wallet

This server holds a private key that can spend money. Use a new wallet that exists only for this, funded with a few dollars of USDC on Base at most. Payments are gasless for the payer (EIP-3009), so the wallet needs USDC only, no ETH. Never use a wallet that holds anything you can't afford to lose. The wallet balance is your real spending limit.

Can you trust this package?

This server asks for a key that can spend money, and fake "x402 MCP" packages that steal keys have been reported. Don't take this README's word for it: the claims below are meant to be checked.

  • The package never sends or logs your key. It is read once from X402AI_BUYER_PRIVATE_KEY and used only to sign payment authorizations locally, and it is scrubbed from error messages. It stays in this process's environment and memory while the server runs, so anything that can read those (other code in this process, other programs running as your user, your client's config file) can read the key. Clearing the variable inside the process would not change that, because Linux keeps a process's starting environment readable under /proc.
  • Every host it contacts. No request follows a redirect; a redirect is refused and the call fails.
    • https://api.x402ai.dev: the paid tools and health. Signed authorizations go only here, only for the calling tool's own route and price, and expire within 300 seconds.
    • https://api.cdp.coinbase.com: only when you run inspect (Coinbase's validator and merchant lookup).
    • The URL you pass to inspect: one unpaid request (with a fixed body for POST). Nothing is signed.
  • No telemetry, analytics or update checks.
  • Small and readable. Five source files in src/ (about 660 lines), built with tsc into dist/. The published package contains only dist/, this README, LICENSE and package.json.
  • Pinned dependencies. Direct dependencies are pinned to exact versions. npm resolves their dependencies fresh, within the ranges they declare, when you install, so those aren't frozen; the repository's package-lock.json records the exact set that was tested. No dependency runs an install script. All dependencies have verified npm registry signatures (npm audit signatures). The x402 client is @x402/fetch 2.29.0, with a per-payment cap set in code.
  • The spend safeguards stop honest code from overspending; they do nothing against a malicious package. That is why the points above are checkable.

How to check: compare the published files with the source (npm pack x402ai-mcp@<version> downloads the exact tarball for inspection), confirm the package name is exactly x402ai-mcp, and read src/.

Don't run unvetted MCP servers in the same client as a funded key. Any other program running as your user, including another MCP server, can typically read this process's environment and your client's config file, which holds the key in plain text.

Install

Requires Node.js 20 or later. Add it to your MCP client's configuration, for example:

json
{  "mcpServers": {    "x402ai": {      "command": "npx",      "args": ["-y", "x402ai-mcp"],      "env": {        "X402AI_BUYER_PRIVATE_KEY": "0x...",        "X402AI_MAX_SESSION_USD": "0.25"      }    }  }}

Note that most clients store this file in plain text, so the key sits on disk unencrypted. That is one more reason to use a dedicated low-balance wallet.

To try it without a key or any spending, set X402AI_DRY_RUN=1: paid tools then return the price quote they would pay, and never sign anything.

Configuration

VariableDefaultMeaning
X402AI_BUYER_PRIVATE_KEYnoneBuyer key (hex). Needed only for paid tools. Never logged; scrubbed from error messages.
X402AI_MAX_SESSION_USD0.25Total the server may spend per process. An invalid value stops it at startup.
X402AI_DRY_RUNoff1 = quote only, never sign. No key needed.

The server logs to stderr only (stdout carries the MCP protocol). At startup it prints whether a key is configured, the buyer address and the session cap.

Spending safeguards

  • Per payment: before signing, each paid tool checks that the challenge is for Base mainnet, USDC, x402ai's payment address, and that tool's own route, at or below that route's price. Anything else is refused. A per-payment maximum of $0.04 is enforced as a second check.
  • Short-lived authorizations. A challenge that asks for an authorization valid longer than 300 seconds is refused before signing, so a leaked authorization cannot stay usable for long.
  • Per session: each payment attempt is reserved against X402AI_MAX_SESSION_USD before signing. Once the cap is reached, paid tools refuse until the server restarts.
  • The session cap is per process. It is counted in memory, resets when the server restarts, and each running copy of the server gets its own cap, even with the same wallet. The wallet balance is the only hard limit: fund it with only what you are willing to lose.
  • The cap has no upper limit. A typo such as 250 means $250. The wallet balance is the backstop that always holds.

Things to know

  • A failed call can still count. If the server returns an error after the payment was signed, the reservation is kept, because a signed authorization can still settle. You are not charged when x402ai's handler fails, but the session cap treats the attempt as spent.
  • inspect sends the URL you give it to Coinbase's CDP (validator and merchant lookup). Don't inspect URLs you want to keep private.
  • inspect refuses local and private addresses (loopback, private ranges, link-local, CGNAT, IPv6 ULA, and IPv4 addresses wrapped in IPv6 forms), checked after DNS resolution. It allows https only. The request to the inspected URL checks the resolved addresses at connect time, in the same lookup the socket uses, so a DNS answer that changes after the early check cannot reach a local or private address. It follows no redirects and verifies the TLS hostname. This covers the request to the inspected URL; inspect's calls to Coinbase go to a fixed host.
  • Treat tool output as untrusted data. Answers and summaries come from a small model and may be wrong; responses from inspected endpoints are third-party content. Don't let them act as instructions to your agent.
  • Latency: embed is usually under a second; summarize and ask take about 5-15 seconds (CPU inference).
  • Claude Code may load tool schemas late. Claude Code defers MCP tool schemas by default, so the first call to a tool can go out with wrong or empty arguments. Starting Claude Code with ENABLE_TOOL_SEARCH=false loads them up front.

License

MIT. Not affiliated with Coinbase or the x402 Foundation.

來源:README.md,提交 495a762

工具

5

embed

x402ai embed

Compute a text embedding vector. Costs $0.01 (USDC on Base) per call. Spends real money; subject to a per-payment and per-session cap. Pass the text in `input` (max 3000 chars).

輸入參數input必填

summarize

x402ai summarize

Summarize text. Costs $0.02 (USDC on Base) per call; takes 5-16 s. Spends real money; subject to a per-payment and per-session cap. Pass the text in `input` (max 3000 chars).

輸入參數input必填

ask

x402ai ask

Ask a question and get an answer. Costs $0.04 (USDC on Base) per call; takes 5-16 s. Spends real money; subject to a per-payment and per-session cap. Pass the question in `input` (max 3000 chars).

輸入參數input必填

health

x402ai health

Free. Check GET /health on api.x402ai.dev and show local session spend. No key needed.

無需輸入參數。

inspect

x402 inspect

Free, never signs or pays. Fetch an https URL unpaid, decode its x402 payment-required header, and check it with Coinbase CDP validate and merchant discovery. Sends the URL to api.cdp.coinbase.com.

輸入參數url必填method

版本歷史

1
  1. v0.1.1最新Oct 26, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分