Pay for HTTP APIs and charge for your own: x402 micropayments in USDC on Base.
io.github.kwizzlesurp10-ctrl/x402-mcp (MCP)
This MCP server provides an interface tied to x402 HTTP micropayments. It supports “pay for HTTP APIs and charge for your own” using x402 micropayments denominated in USDC on Base. The project is associated with the x402 ecosystem and Base Mainnet (8453).
🛠️ Key Features
Model Context Protocol (MCP) server
x402 micropayments for HTTP APIs
USDC micropayments on Base
16 tools reported
Topics include MCP, Base, and agent-card
🚀 Use Cases
Charging for HTTP API access via x402
Agent-to-agent payment flows using an A2A v1.0 agent card
Integration with Base Mainnet (8453)
⚡ Developer Benefits
Standard MCP integration for tool discovery
Base-focused deployment target (Base Mainnet)
Uses an A2A v1.0 Agent Card endpoint
⚠️ Limitations
Documentation excerpt is incomplete (“Production MCP server for the [x402]…”) so tool behavior and coverage are not fully described here
Build seller-side x402 payment requirements via x402ResourceServer.
Pass resource_url (plus optional discovery_* fields) to embed the Bazaar
discovery extension so a settled payment catalogs the endpoint.
Run the swarm Agency: compose a research product and list it for resale.
Spends nothing by default — the report is synthesized from free inputs, so
unsold inventory costs nothing. Pass allow_paid_inputs=True to buy upstream
x402 services first (buy → compose → list), which books a cost basis before
knowing whether the composite will sell.
Live Base Network Pulse: synthesized settlement-conditions intelligence
(base fee, EIP-1559 projection, utilization trend, USD settlement cost, and a
settle-now/hold verdict) computed from real Base RPC data + ETH spot price.
Host OS telemetry: CPU, memory, swap, disk, network, and process
signals with an ok/warn/critical health verdict, sampled live from the
machine running the server. Optionally includes the top processes by
memory.
Production MCP server for the x402 HTTP micropayment protocol — live on Base mainnet, selling real data products to AI agents for USDC today. Agents discover paid services, probe 402 Payment Required responses, pay with stablecoins, and build/verify seller payment configs; the server runs both sides of that market.
Discover (public + A2A)
Machine surfaces agents and directories crawl first:
Fiat Sponsors (GitHub Sponsors / Polar / thanks.dev) do not credit payTo on-chain.
Live on Base mainnet
Storefront:https://x402-mcp.onrender.com — x402 v2 challenges served, USDC verified + settled through the Coinbase CDP facilitator (eip155:8453).
Product
Price
What you get
GET /mn/property-check?address=…
$0.01 USDC
Minneapolis rental-compliance snapshot composed from 3 live City of Minneapolis open datasets — the first machine-payable housing-compliance data for agents
GET /us/{code}/property-check?address=…
$0.01 USDC
US City Open-Data Compliance Network (public catalog; see /us/cities) — same wire protocol; free catalog /us/cities + free /sample; MCP: city.list → city.sample → city.check
GET /swarm/products/d22bbf5f3c4b4666a6f80980c7bc7c50/purchase
$0.05 USDC
Base Network Pulse: live settlement-conditions intelligence (EIP-1559 math + real RPC + ETH spot), pinned listing with the x402 Bazaar discovery extension
19 MCP tools for buyer, seller, x402 commerce, swarm-agency, US city compliance, Agent ID cards, and ops-monitoring flows — canonical inventory in app/tools_registry.py (single source for README, /.well-known/mcp, and tests); guarded by tests/test_readme.py and tests/test_manifest.py. MailRail send/inbound is operator-only (docs/MAILRAIL-PUBLIC-SURFACE.md).
4 MCP prompts (onboarding_flow, x402_tool_selector, generate_quote, troubleshoot_payment) for LLM orchestrators
A2A Protocol v1.0 Agent ID Cards — HTTP Agent Card + MCP x402.agent_card / x402://agent-card with per-agent_id quota isolation
x402/Coinbase rail (primary): x402 v2 wire format end to end — challenge generation, verify + settle via the CDP facilitator on Base mainnet, Bazaar discoverability on listings
Stripe payment rail (fiat alternative, HTTP only): POST /stripe/checkout + POST /stripe/webhook for card/bank payments (not exposed as an MCP tool)
Commerce overlay: 500 calls/month, 10/min rate limit, meta envelope on every response
FastMCP + FastAPI with /.well-known/mcp manifest
stdio (Cursor/Grok local) and HTTP/SSE (remote connector) transports
Redis-ready quota store (in-memory default)
Operator dashboard at /dashboard — live health, per-agent quota burn-down meters, tool matrix, and revenue paths (single-file, zero build step)
Hermetic test suite — a local mock facilitator/discovery backend spins up automatically; no internet required. Set X402_LIVE_TESTS=1 to run against x402.org
Quickstart & 1-Click Installation
Install kwizzlesurp10/x402-mcp into your favorite MCP client using the Smithery CLI:
Add to Cursor MCP config (manifests/cursor-mcp.json).
HTTP server
bash
uvicorn app.main:app --host 0.0.0.0 --port 8402
curl http://localhost:8402/.well-known/mcp
curl http://localhost:8402/health
# then open http://localhost:8402/dashboard
Paid HTTP Resource: MN Property Check
First-party sellable endpoint (the seller side of this repo's own tooling):
code
GET /mn/property-check?address=1700%20Penn%20Ave%20N
x402-gated at $0.01 USDC (MN_PROPERTY_CHECK_PRICE). Unpaid requests get a
402 with x402 v2 PAYMENT-REQUIRED terms; paid requests are verified and
settled via the facilitator, then served with a PAYMENT-RESPONSE receipt.
One call returns a composite Minneapolis rental-compliance snapshot from live
City of Minneapolis Open Data: active rental license (status, tier, licensed
units, expiration, ward/neighborhood), regulatory violation case history
(APN-joined), and condemned/boarded status. Owner phone/email in the source
data are intentionally never served. Public records, as-is; not legal advice.
MCP Tools
Tool names use domain.action trees so clients can route x402.*, commerce.*, swarm.*, pulse.*, ops.*, and city.*.
Tool
Description
x402.agent_card
Return the A2A Agent ID Card and MCP server card
x402.discover
Query x402 Bazaar for paid HTTP APIs
x402.probe
Probe URL for PAYMENT-REQUIRED on 402
x402.pay_and_fetch
Auto-pay and fetch protected resource
x402.build_seller
Build seller payment requirements
x402.verify
Verify payment via facilitator
x402.networks
Networks, facilitators, v2 headers
commerce.pro_requirements
Build x402 payment requirements for Pro tier upgrade
commerce.activate_pro
Verify x402 payment and unlock Pro tier quota
commerce.credits_requirements
Build x402 payment requirements for per-use tool credits
commerce.purchase_credits
Verify x402 payment and add per-use tool credits
swarm.research
Swarm Agency: compose a research report and list it for resale
swarm.settle
Verify + settle a buyer's payment for a listed composite and record revenue
swarm.revenue
Swarm composite economics: spend, composite sales, LTV:CAC, margins; storefront is the full settled ledger
pulse.base
Live Base Network Pulse: synthesized settlement-conditions intelligence (base fee, utilization, USD cost, verdict) from real RPC data
ops.metrics
Host OS telemetry: CPU, memory, swap, disk, network, and process signals with an ok/warn/critical health verdict
city.list
Free US City Open-Data Compliance catalog (codes, paid_url, sample_url, MCP golden path)
city.sample
Free fixed-address property compliance sample for one city code
city.check
Paid city property compliance via x402 (same HTTP resource external buyers use)
Connect an MCP client to Streamable HTTP /mcp/mcp. Call x402.discover then x402.probe then x402.pay_and_fetch for paid APIs; city.list → city.sample → city.check for US property compliance.
Environment
Variable
Required
Description
X402_PAY_TO_ADDRESS
For selling
Recipient wallet — all x402 sales settle here
CDP_API_KEY_ID / CDP_API_KEY_SECRET
For Base mainnet
Coinbase CDP facilitator creds (verify + settle on eip155:8453)
SWARM_SELL_NETWORK
For mainnet listings
Set eip155:8453 to list products on Base mainnet (default: Base Sepolia)
EVM_PRIVATE_KEY
For pay_and_fetch
Buyer wallet private key — never set this on a public seller host
Cost-effective multi-agent operating group (scout, warden, treasurer, archivist, sovereign, merchant) with budget policy and ledger. See docs/agent-ops.md. Dashboard handoff: docs/UI-HANDOFF.md.
The Swarm Agency (app/swarm/) implements the hybrid resale loop end-to-end:
scout discovers cheap upstream x402 services → warden enforces ledger/policy.json spend caps → treasurerpay_and_fetches and records cost basis to ledger/spend.jsonl → archivist composes a research report priced at cost × SWARM_MARKUP → sovereign (profit optimizer) reprices the composite to hit a target LTV:CAC (SWARM_TARGET_LTV_CAC, default 3.0), enforces a margin floor, and scores which upstream sources are actually profitable → merchant lists it via build_seller_requirements; settle_composite_sale records realized revenue. Portfolio economics (swarm spend, composite sales, LTV:CAC, per-source profit) surface via swarm_revenue_report / GET /swarm/revenue — total_revenue_usdc is composites only; first-party SKUs are under storefront. Every phase streams to the dashboard's Swarm Activity panel over SSE. Run via the run_swarm_research MCP tool (needs EVM_PRIVATE_KEY + X402_PAY_TO_ADDRESS).
Multi-chain (EVM + Solana). The resource server registers ExactEvmServerScheme for eip155:* and ExactSvmServerScheme for solana:* (via the x402[svm] extra; solana>=0.36,<0.40). Seller requirements build on Base and Solana mainnet (solana:EtWTRAB…), and the buyer client registers an EVM and/or Solana signer from EVM_PRIVATE_KEY / SVM_PRIVATE_KEY — no marketing-vs-code gap.
Selling network / facilitators. The merchant lists on SWARM_SELL_NETWORK (default eip155:84532). The free x402.org facilitator only settles exact on Base Sepolia; to sell/settle on Base mainnet set SWARM_SELL_NETWORK=eip155:8453 and provide Coinbase CDP credentials (CDP_API_KEY_ID + CDP_API_KEY_SECRET) — the seller then routes verify/settle through the CDP facilitator with a per-request Ed25519 JWT (app/cdp_auth.py).
Base Network Pulse
Base Network Pulse (app/pulse.py + app/swarm/publisher.py) is a synthesis publisher: it turns free, high-quality Base RPC data (latest block, EIP-1559 base fee, block gas utilization) plus a live ETH spot price into a priced, x402-payable intelligence report. It projects the next-block base fee from the EIP-1559 formula, converts settlement gas into a live USD cost, and renders a settle-now / hold verdict on current Base settlement conditions. All inputs are real data — no mocks: real Base RPC calls, real Coinbase ETH price, real base-fee math.
Endpoints:
GET /pulse — live preview of the current synthesized pulse (base fee, utilization, USD settlement cost, verdict).
POST /pulse/publish — mints an x402-payable listing for the report (402-gated purchase endpoint).
get_base_pulse MCP tool — the same intelligence surfaced to agents.
This is the synthesis economic model: cost basis is ~$0 because the underlying Base data is free to read; the margin is the analysis itself. The priced report is sold to external buyers through the 402-gated purchase endpoint — pure synthesized value on top of free public data.
Testing
bash
pytest -v
See docs/SETUP.md for expected vs unexpected errors (wallet tools fail clearly until .env is configured).
Mission Control Dashboard
Fintech-terminal ops dashboard at http://localhost:5173. Net position, quota gauge, rate sparkline, activity stream, agent lanes, spend/revenue ledgers (with BaseScan links), 402 Inspector, wallet panel, first-run wizard, and mission progress tracker. Three density modes (Guided/Standard/Operator). cmd+K command palette.
API surface: GET /stats, GET /events (SSE with 15s heartbeat), GET /ledger/{spend|revenue}, GET /doctor, GET /probe, GET /wallet, POST /seller/requirements.
Agent Ops
Cost-effective multi-agent operating group (scout, warden, treasurer, archivist, merchant) with budget policy and ledger. See docs/agent-ops.md.
Agent ID Cards & Machine Identity
x402-mcp implements the Agent-to-Agent (A2A) Protocol v1.0 and MCP machine identity for autonomous discovery.