X402 Api

io.github.fernsugi由 GitHub 帳號 fernsugi 發布v1.0.5更新於 Oct 24, 2026

Eight paid DeFi tools: prices, gas, swaps, token security, holders, yields, funding and wallets

已驗證STDIO僅桌面金融安全與監控

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理使用八個按次付費的加密與 DeFi 資料工具,透過 x402 協定在 Base 上以 USDC 付款。

可以做什麼
取得加密貨幣價格與多鏈 Gas 價格,無需參數;依代幣對與數量取得單一 DEX 兌換報價,以及 Hyperliquid 與 dYdX v4 的每小時資金費率(可指定資產或全部資產)。執行代幣安全掃描,辨識貔貅盤等風險標記,抽樣前列持幣地址與供應占比,並依鏈與最低 TVL 篩選 DeFi 收益池。查詢錢包已觀測的餘額與交易筆數。預設僅檢查付款要求並回傳 402 詳情,不會實際付款。
適用情境
適合助理需要快速取得加密行情、Gas、DEX 報價、代幣風險、持幣分布、收益、資金費率或錢包資料,且你願意為每次呼叫支付少量 USDC 的情境。檢查模式可在啟用付款前安全查看每次呼叫的費用。
執行需求
透過 npx 或全域 npm 安裝後在本機執行(需要 Node.js)。可選的自動付款需要 viem 套件、一個在 Base 上存有 USDC 的錢包,以及環境變數 X402_WALLET_PRIVATE_KEY。可選設定:X402_API_BASE_URL、X402_MAX_PER_CALL_USDC(預設 0.01)、X402_EXPECTED_PAY_TO 與 X402_REFERRAL_SOURCE。需要能連線至 x402 API 的網路。
安裝前請注意
自動付款會在 Base 上花費真實 USDC,每次 0.001 至 0.008,重複呼叫會再次扣款;啟用前請設定 X402_MAX_PER_CALL_USDC。X402_WALLET_PRIVATE_KEY 是錢包私鑰,應保存在本機環境設定中、不要提交到 Git,錢包內只放可承受損失的金額。除非信任其他部署,否則請將 X402_EXPECTED_PAY_TO 保持為官方收款地址。部分工具輸出明確為不完整或僅供參考。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

@x402-api/mcp-server

[x402-api MCP server]

MCP server that gives Claude, ChatGPT, and any MCP-compatible AI agent access to pay-per-call crypto/DeFi data via the x402 protocol.

8 tools. No API keys. AI agents pay USDC micropayments on Base, per request.

Find this service: Official MCP Registry · Glama · Agent discovery manifest · OpenAPI.

  ██╗  ██╗██╗  ██╗ ██████╗ ██████╗   ╚██╗██╔╝██║  ██║██╔═══██╗╚════██╗    ╚███╔╝ ███████║██║   ██║ █████╔╝    ██╔██╗ ╚════██║██║   ██║██╔═══╝   ██╔╝ ██╗     ██║╚██████╔╝███████╗   ╚═╝  ╚═╝     ╚═╝ ╚═════╝ ╚══════╝

Tools

ToolAPI EndpointCostDescription
get_crypto_pricesGET /api/price-feed0.001 USDCBTC/ETH/SOL + top 24h movers
get_gas_pricesGET /api/gas-tracker0.001 USDCMulti-chain gas (ETH, Base, Polygon, Arbitrum)
get_dex_quotesGET /api/dex-quotes0.002 USDCOne ParaSwap aggregate route
scan_tokenGET /api/token-scanner0.003 USDCGoPlus security flags and heuristic
track_whalesGET /api/whale-tracker0.005 USDCTop-holder sample and supply share
scan_yieldsGET /api/yield-scanner0.005 USDCDefiLlama pool APYs and TVL
get_funding_ratesGET /api/funding-rates0.008 USDCHyperliquid and dYdX hourly rates
profile_walletGET /api/wallet-profiler0.008 USDCObserved Blockscout balances; partial coverage

Quick Start

Option A: Inspect mode (no payment needed)

Just run it — any 402 responses will return human-readable payment instructions:

bash
npx @x402-api/mcp-server

Claude will tell you what's needed when a tool requires payment.

Option B: Auto-pay mode (fully autonomous)

Install optional payment deps and set your wallet key:

bash
npm install -g @x402-api/mcp-servernpm install -g viemexport X402_WALLET_PRIVATE_KEY=0x<your_private_key>x402-api-mcp

The MCP server signs Base USDC EIP-3009 authorizations only when the API advertises that settlement mode. The default payment cap is 0.01 USDC per call. Fund the wallet with USDC on Base; the API operator sponsors gas in direct settlement mode.


Claude Desktop Integration

Add to your claude_desktop_config.json:

Without auto-pay (inspect mode)

json
{  "mcpServers": {    "x402-api": {      "command": "npx",      "args": ["@x402-api/mcp-server"]    }  }}

With auto-pay

json
{  "mcpServers": {    "x402-api": {      "command": "npx",      "args": ["@x402-api/mcp-server"],      "env": {        "X402_WALLET_PRIVATE_KEY": "0x<your_private_key>"      }    }  }}

Config file location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Environment Variables

VariableRequiredDescription
X402_WALLET_PRIVATE_KEYOptionalBase wallet private key for EIP-3009 automatic payment. Requires viem.
X402_MAX_PER_CALL_USDCOptionalPer-call cap, default 0.01 USDC.
X402_API_BASE_URLOptionalOverride API URL (default: https://x402-api.fly.dev)

How x402 Payments Work

This API uses the x402 protocol — HTTP 402 Payment Required:

  1. Agent calls tool → MCP server makes API request
  2. Server returns 402 with payment details (amount, USDC address, Base network)
  3. Auto-pay mode: this client signs an EIP-3009 authorization and retries; the API settles it on Base
  4. Inspect mode: MCP returns 402 details without signing or paying

Payment details:

  • Token: USDC on Base mainnet
  • Address: 0x60264c480b67adb557efEd22Cf0e7ceA792DefB7
  • Chain: Base (chain ID 8453)
  • Amount: 0.001–0.008 USDC per call (< 1 cent USD)

Tool Reference

get_crypto_prices

No parameters. Returns current prices for BTC, ETH, SOL + top 24h movers.

Cost: 0.001 USDC

get_gas_prices

No parameters. Returns gas prices for Ethereum, Base, Polygon, Arbitrum — slow/standard/fast tiers.

Cost: 0.001 USDC

get_dex_quotes

Get one ParaSwap aggregate route. No independent comparison between DEX venues.

ParameterTypeRequiredDescription
fromstring✅Input token (e.g. "ETH", "0x...")
tostring✅Output token (e.g. "USDC")
amountstring✅Amount to swap (e.g. "1.5")
Cost: 0.002 USDC

scan_token

Token security scan — detects rug-pull flags, honeypot patterns, mint authority, etc.

ParameterTypeRequiredDescription
tokenstring✅Contract address or symbol (e.g. "PEPE")
Cost: 0.003 USDC

track_whales

Top-holder sample from GoPlus. Gini and recent transfer history unavailable.

ParameterTypeRequiredDescription
tokenstring✅Contract address or symbol
Cost: 0.005 USDC

scan_yields

Top DeFi yield opportunities across Aave, Compound, Morpho, Lido, Pendle, etc.

ParameterTypeRequiredDescription
chainstring❌Filter by chain: "ethereum", "base", "arbitrum", "polygon"
min_tvlnumber❌Minimum TVL in USD (e.g. 1000000)
Cost: 0.005 USDC

get_funding_rates

Hourly perpetual funding from Hyperliquid and dYdX v4. Spreads are indicative.

ParameterTypeRequiredDescription
assetstring❌Asset symbol (e.g. "BTC", "ETH"). All assets if omitted.
Cost: 0.008 USDC

profile_wallet

Observed priced wallet balances and available transaction counts. DeFi positions, PnL and risk score unavailable.

ParameterTypeRequiredDescription
addressstring✅Ethereum/Base wallet address (0x...)
Cost: 0.008 USDC

Development

bash
git clone https://github.com/fernsugi/x402-api-mcp-servercd x402-api-mcp-server
npm installnpm run buildnpm start

To test without a payment wallet, simply run and see the 402 responses:

bash
node dist/index.js

Links


License

MIT

Three runnable workflows

WorkflowToolsTotal USDC
Token checkscan_token + track_whales0.008
ETH fundingget_funding_rates0.008
Swap quote + gasget_dex_quotes + get_gas_prices0.003

Runnable Node examples start in inspect mode. Each demo has inputs, recorded provider output, coverage limits, a spending cap, and an agent prompt.

Optional X402_REFERRAL_SOURCE labels requests for first-party aggregate attribution (default mcp). It is a hint, not verified caller identity. The API journals no raw payer wallets, IP addresses, or signatures. X402_EXPECTED_PAY_TO pins the payment recipient to the official wallet by default. Tools advertise that auto-pay can spend money and repeated calls can incur another charge.

Cursor / other local MCP clients

Use the same mcpServers configuration shown above. For Cursor, put it in .cursor/mcp.json in your project. Inspect mode needs no wallet. Set X402_MAX_PER_CALL_USDC before enabling auto-pay; repeated calls spend again. Keep wallet credentials in local environment settings, outside Git.

Registry publication

The Publish MCP Registry GitHub workflow validates the matching npm version, then publishes server.json using GitHub OIDC. It runs on a published GitHub release or a manual dispatch from main. No npm token, GitHub PAT, or wallet key is stored in CI. Actions and official publisher source are pinned to verified commits. npm publication still happens separately before creating the release.

來源:README.md,提交 44bdf37

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

3
  1. v1.0.5最新Sep 30, 2026
  2. v1.0.4Sep 29, 2026
  3. v1.0.2Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分