I wanted to see what it actually takes to put a per-call USDC paywall in front of an MCP server on Cloudflare Workers without pulling in a heavy framework.
There is a lot of talk about "agent economies," mostly at the slide-deck level. I wanted to test the plumbing myself: deploy real endpoints, wire up HTTP 402 challenges, and see where the rough edges are.
1. The Gap: agents@0.35 Ships the Client, Not the Server Paywall
When I started cf-x402-mcp, I noticed that agents@0.35 ships the x402 client (agents/x402), but there is no server-side withX402 or paidTool helper.
So in src/x402.ts, I wrote a small, zero-extra-dependency paywall right in front of @modelcontextprotocol/sdk's WebStandardStreamableHTTPServerTransport (POST /mcp).
The request flow is straightforward:
- A paid tool call arrives without payment.
- The Worker returns HTTP
402with aPAYMENT-REQUIREDheader (x402 v2, schemeexact, USDC on Baseeip155:8453). - When a payment header is attached, it is verified and settled through a configurable x402 facilitator (
FACILITATOR_URL, defaulting tohttps://x402.org/facilitator). - Only after verification does the request reach the MCP transport.
2. Base USDC: cf-x402-mcp
The live endpoint is running on Cloudflare Workers:
- MCP Endpoint:
https://cf-x402-mcp.yan8925298.workers.dev/mcp - Discovery Manifest:
https://cf-x402-mcp.yan8925298.workers.dev/.well-known/x402 - OpenAPI 3.1 Spec:
https://cf-x402-mcp.yan8925298.workers.dev/openapi.json - x402scan Directory:
https://www.x402scan.com/server/9b24c611-587b-49f1-940c-c8c93b4b8bec(4/4 endpoints registered)
It exposes four paid tools (ci_log_sieve at 0.01 USDC, repo_sec_triage at 0.02 USDC, market_edge_feed at 0.01 USDC, web_md_distill at 0.01 USDC) plus a free sample_tools helper. Every paid tool also supports "sample": true so anyone can test the response shape at $0 before paying.
For example, ci_log_sieve pairs naturally with ap v2.96.0 when you want to compress noisy CI/build logs into root causes and deduped errors before feeding them back to an LLM.
3. Solana USDC: coingecko-longtail-agent
To check whether the same pattern holds on another chain, I built coingecko-longtail-agent (live demo at https://coingecko-longtail-agent.yan8925298.workers.dev) for the Superteam x CoinGecko Long Tail Hackathon.
It combines:
- CoinGecko Onchain API (
/networks/solana/new_pools,/networks/solana/trending_pools,/networks/solana/tokens/{mint}/pools,/search/pools?network=solana) for pool telemetry. - Solana JSON-RPC (
getAccountInfo,getTokenLargestAccounts) for SPL mint/freeze authority and holder concentration checks. - Jupiter read-only swap quotes (
$500and$2,500simulated exits against Solana USDC) to flag paper liquidity vs. real exit slippage. - Solana Memo Program v2 (
MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr) to hash audit decisions into unsigned memo instructions without the agent holding private keys. - Solana USDC x402 Paywall:
/premium/analyzereturns402withaccepts[0].network = "solana".
What I am unsure about
The plumbing works, and both Workers are live, but a few things are still open questions for me:
- Real agent payment volume is tiny. Right now these are working demos with real settlement paths, not a bustling market. I don't know how long it will take for MCP clients to handle
402challenges seamlessly out of the box. - Facilitator dependency. Verification and settlement route through an external facilitator (
X402_FACILITATOR_URL). That is a liveness and trust assumption worth calling out explicitly. - Heuristic risk scoring limits. The deterministic scoring in
coingecko-longtail-agent(src/risk.ts) is a useful filter for obvious rug/wash-trade signals, not a security guarantee.
If you are building paid MCP tools or experimenting with x402 on Cloudflare Workers, I would love to compare notes on how you handle facilitator timeouts and client-side 402 retries.
