x402 Micropayments MCP
Enables AI agents to discover, pay for, and sell HTTP APIs using the x402 micropayment protocol, with USDC settlement on Base mainnet. Includes tools for payment requirements, paying and fetching resources, building seller configurations, and monitoring revenue.
README
x402 Micropayments MCP
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.
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 /swarm/products/{id}/purchase |
$0.25 USDC | Base Network Pulse: live settlement-conditions intelligence (EIP-1559 math + real RPC + ETH spot), listed with the x402 Bazaar discovery extension |
The public seller host holds no spend key — it only verifies and settles inbound payments (docs/SELLER-STOREFRONT.md). Roadmap: ROADMAP.md.
Features
- 16 MCP tools for buyer, seller, Stripe fiat, x402 commerce, swarm-agency, and ops-monitoring flows — canonical inventory in
app/tools_registry.py(single source for README,/.well-known/mcp, and tests); guarded bytests/test_readme.pyandtests/test_manifest.py - 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):
create_stripe_checkout+POST /stripe/checkout+POST /stripe/webhookfor card/bank payments - Commerce overlay: 500 calls/month, 10/min rate limit,
metaenvelope on every response - FastMCP + FastAPI with
/.well-known/mcpmanifest - 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=1to run against x402.org
Quick Start (Mission Control)
git clone <repo> && cd x402-mcp
python -m venv .venv && .venv\Scripts\pip install -r requirements.txt && cd dashboard && pnpm install && cd ..
cp .env.example .env
make up
Open http://localhost:5173 — setup wizard runs with doctor checks. Toggle Demo to preview every panel with zero wallet.
Docs: docs/SETUP.md · docs/USER-GUIDE.md · docs/UI-HANDOFF-v2.md
Local stdio (Cursor)
python run_stdio.py
Add to Cursor MCP config (manifests/cursor-mcp.json).
HTTP server
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):
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 | Description |
|---|---|
discover_services |
Query x402 Bazaar for paid HTTP APIs |
get_payment_requirements |
Probe URL for PAYMENT-REQUIRED on 402 |
pay_and_fetch |
Auto-pay and fetch protected resource |
build_seller_requirements |
Build seller payment requirements |
verify_payment_payload |
Verify payment via facilitator |
get_supported_networks |
Networks, facilitators, v2 headers |
get_pro_upgrade_requirements |
Build x402 payment requirements for Pro tier upgrade |
activate_pro_tier |
Verify x402 payment and unlock Pro tier quota |
get_tool_credits_requirements |
Build x402 payment requirements for per-use tool credits |
purchase_tool_credits |
Verify x402 payment and add per-use tool credits |
create_stripe_checkout |
Create Stripe Checkout Session for pro tier or credits |
run_swarm_research |
Swarm Agency: buy cheap upstream x402 services, compose a research report, list it for resale |
settle_composite_sale |
Verify + settle a buyer's payment for a listed composite and record revenue |
swarm_revenue_report |
Portfolio revenue intelligence: spend, revenue, LTV:CAC, margins, per-source profit scores |
get_base_pulse |
Live Base Network Pulse: synthesized settlement-conditions intelligence (base fee, utilization, USD cost, verdict) from real RPC data |
get_os_metrics |
Host OS telemetry: CPU, memory, swap, disk, network, and process signals with an ok/warn/critical health verdict |
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 |
STRIPE_SECRET_KEY |
For Stripe checkout | Fiat payment rail |
STRIPE_WEBHOOK_SECRET |
For /stripe/webhook |
Webhook signature verification |
X402_FACILITATOR_URL |
No | Default: https://x402.org/facilitator (testnet; CDP handles mainnet) |
UPGRADE_URL |
No | Commerce tier upgrade link |
Commerce Meta Envelope
Every tool response includes:
{
"data": { "...": "..." },
"meta": {
"tier": "free",
"calls_this_month": 1,
"quota_remaining": 499,
"quota_warning": false,
"rate_limit_remaining": 9,
"upgrade_url": "https://forge.example.com/upgrade",
"agent_id": "..."
}
}
Agent Ops / Swarm Agency
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 → treasurer pay_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 (spend, revenue, LTV:CAC, per-source profit) surface via swarm_revenue_report / GET /swarm/revenue. 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_pulseMCP 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
pytest -v
See docs/SETUP.md for expected vs unexpected errors (wallet tools fail clearly until .env is configured).
Docker
docker build -f deployment/Dockerfile -t x402-mcp .
docker run -p 8402:8402 x402-mcp
Drive Project Folder
Target: /Forge/MCP_Projects/x402-micropayments/
code/ → this repository
tests/ → pytest suite
docs/ → architecture.md
screenshots/ → verification images
manifests/ → cursor-mcp.json, /.well-known/mcp
deployment/ → Dockerfile
License
Apache-2.0 compatible with x402 Foundation ecosystem.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。