x402-mcp-chain-query
Integrates with Coinbase's CDP facilitator to verify and settle x402 payments on Base mainnet for paid MCP tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@x402-mcp-chain-querycheck the native balance of 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 on Base"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
x402-mcp-chain-query
Cloudflare Workers remote MCP server that exposes Base mainnet chain query tools with x402 payments, using the Agents SDK (McpAgent + withX402 + paidTool).
Follows Charge for MCP tools and the x402-mcp example, but uses the CDP facilitator for Base mainnet — never x402.org for mainnet / real funds.
Tools
Tool | Price | Notes |
| free ( | Proxies |
| $0.01 ( | Proxies |
| $0.01 ( | Proxies |
payTo / recipient: 0xc8aaea11c93a438e2fc7bd5cddb9a6936ed3595c
network: base (mainnet → eip155:8453)
facilitator: https://api.cdp.coinbase.com/platform/v2/x402
Output fields
chain_balance:
address,chainId,token,symbol,decimals,balance,balanceFormatted,asOf(when present)chain_gas:
baseFeePerGas,maxPriorityFeePerGas,maxFeePerGas,gasPrice,urgency(MCP enum),asOf
Related MCP server: Base Gas MCP Server
Free trial (N=10)
Documented allotment: 10 free uses per payer (FREE_TRIAL_N).
Best-effort KV counter (
TRIAL_KV) keyed by payer address (observability / remaining).MCP
paidToolstill requires x402 payment before the handler runs; a true MCP-side free bypass is TODO.Upstream seller receives
x-wallet-addressheader and/or?payer=so it can grant its own free trials.
Upstream
Default UPSTREAM_API_BASE=http://127.0.0.1:4021 (e.g. the companion Express x402-chain-query seller).
Method | Path | Auth |
GET |
| none |
GET |
| none (x402 at MCP / seller layer) |
GET |
| none — urgency |
No upstream API key.
Setup
cd /workspace/x402-mcp-chain-query
cp .dev.vars.example .dev.vars
# Edit .dev.vars — add CDP_API_KEY_ID / CDP_API_KEY_SECRET (never commit)
npm installEnvironment variables
Variable | Required | Default | Purpose |
| no |
| Upstream chain-query HTTP API |
| for settle | — | CDP Facilitator JWT (secret) |
| for settle | — | CDP Facilitator JWT (secret) |
| no |
| x402 payment recipient |
| no |
| Documented trial allotment / KV counter limit |
Do not commit secrets. Use .dev.vars locally and wrangler secret put CDP_API_KEY_ID / CDP_API_KEY_SECRET in production.
Local development
Start the upstream seller on :4021 if you want live tool results, then:
npm run dev
# → wrangler dev (MCP at http://localhost:8787/mcp by default)Typecheck:
npm run typecheckConnect MCP Inspector or another client to http://localhost:8787/mcp.
Mainnet / CDP warning
This project targets Base mainnet and the CDP facilitator.
Never point mainnet payments at
https://x402.org/facilitator(test facilitator).Without
CDP_API_KEY_ID/CDP_API_KEY_SECRET, payment requirements can still be advertised, but verify/settle will fail.Do not deploy or settle real payments from this scaffold until keys and
PAY_TOare intentional.
Deploy (not done by scaffold)
npx wrangler kv namespace create TRIAL_KV # put real id into wrangler.jsonc
npx wrangler secret put CDP_API_KEY_ID
npx wrangler secret put CDP_API_KEY_SECRET
# npm run deploy # only when you intend to shipStack
agents—McpAgent,agents/x402(withX402,paidTool)@modelcontextprotocol/sdk—McpServerzod— tool input schemas@coinbase/cdp-sdk— CDP JWT for facilitatorcreateAuthHeaders@x402/core/@x402/evm— peer deps ofagents/x402wrangler— Workers / Durable Objects / KV
This server cannot be deployed
Maintenance
Related MCP Connectors
Paid MCP tools behind one endpoint. Agents pay per call in USDC on Base via x402.
Metered MCP tools: free discovery over MCP; per-call execution settled in USDC via x402 v2.
Agent x402 Paywall MCP — Coinbase HTTP 402 protocol + on-chain settlement. Agents pay per-call
Production-grade MCP gateway delivering 8 real-time AI tools with instant x402 micropayments settled in USDC on Base Mainnet or SPL-USDC on Solana. Features Basescan contract auditing, wallet analytics, headless browser scraping, and pre-scraped oracle data feeds.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server for pay-per-call DeFi and crypto data via x402 micropayments on Base. 8 endpoints: token prices, TVL, funding rates, token security, gas tracker, whale monitoring, wallet profiling, and yield scanning.823 npmMIT
- FlicenseAqualityCmaintenanceProvides AI agents with real-time gas prices and blockchain data from Base, with metered access via x402 payment protocol.4-
- AlicenseAqualityCmaintenanceEnables agents to fetch live Base mainnet gas prices by paying $0.001 USDC per call via the x402 payment standard.110 npmMIT
- AlicenseBqualityBmaintenanceMCP server exposing x402 Bazaar's paid Base APIs (token risk/honeypot, prices, gas, wallet intel, tx decode + AI utilities) as agent tools. Your agent pays per call in USDC over x402 — no API keys, no signup.17246 npm1MIT