x402 Crypto Data API

v0.1.0
io.github.piaoshuweb3/x402-data-mcp Checked 2 days ago Published 5 days ago

Pay-per-call crypto market data for agents: prices, Fear & Greed, headlines.

An MCP (Model Context Protocol) server that exposes an x402 pay-per-call crypto data API to AI agents. 1. Call a paid tool with no arguments — you get status: payment_required plus payment_required.accepts[0] (scheme exact, network eip155:8453, amount, payTo, asset). 2. Sign an EIP-3009 TransferWithAuthorization for amount to payTo, validBefore ≈ now + 600s. 3. Build the PaymentPayload {x402Version: 2, accepted: accepts[0], payload: {signature, authorization}} and base64-encode it. 4. Call the same tool again with payment_signature = that base64 string.

Summary extracted from the README.

x402-data-mcp

An MCP (Model Context Protocol) server that exposes an x402 pay-per-call crypto data API to AI agents.

  • Network: Base mainnet (eip155:8453)
  • Asset: USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
  • Payee: 0x562A7fcDA9330fF963A3E4bd923A2F01c229fF9a
  • No API key, no signup — payment is per call.

Tools

Tool Price What it returns
x402_health free Service liveness + configuration
x402_payment_requirements free The x402 v2 payment challenge (decoded) for a paid tool
crypto_snapshot 0.001 USDC BTC/ETH/SOL/BNB/BASE spot + 24h change
crypto_fear_greed 0.001 USDC Crypto Fear & Greed index
crypto_news 0.002 USDC Up to 12 crypto headlines from the last 24h

How payment works

  1. Call a paid tool with no arguments — you get status: payment_required plus payment_required.accepts[0] (scheme exact, network eip155:8453, amount, payTo, asset).
  2. Sign an EIP-3009 TransferWithAuthorization for amount to payTo, validBefore ≈ now + 600s.
  3. Build the PaymentPayload {x402Version: 2, accepted: accepts[0], payload: {signature, authorization}} and base64-encode it.
  4. Call the same tool again with payment_signature = that base64 string.

The response then carries paid: true, the settlement receipt (transaction hash) and the data.

A ready-made payer script is in the sibling service docs (pay_x402.py), and any x402 client SDK works.

Run

node server.mjs

Environment:

  • X402_BASE — base URL of the API (default http://186.244.245.80/x402)

MCP client config

{
  "mcpServers": {
    "x402-data": {
      "command": "node",
      "args": ["/absolute/path/to/server.mjs"],
      "env": { "X402_BASE": "http://186.244.245.80/x402" }
    }
  }
}

Or via npx once published:

{ "mcpServers": { "x402-data": { "command": "npx", "args": ["-y", "@piaoshuweb3/x402-data-mcp"] } } }

Protocol

JSON-RPC 2.0 over stdio. Supports initialize, tools/list, tools/call, ping. Zero dependencies; requires Node 18+.

Notes

  • Settlement is performed by the PayAI facilitator (https://facilitator.payai.network); the payee never pays gas.
  • The upstream service is operated independently by an autonomous agent. Data is provided as-is, no warranty.

MIT.

Hosted remote endpoint (MCP Registry)

This server is published in the official MCP Registry as io.github.piaoshuweb3/x402-data-mcp and is available as a public remote (Streamable HTTP) server:

https://186-244-245-80.sslip.io/x402/mcp/

Free tools: x402_health, x402_payment_requirements. Paid tools return the x402 challenge until a valid payment_signature is supplied. The underlying HTTP API and /llms.txt live at https://186-244-245-80.sslip.io/x402/.