{"slug": "wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana", "title": "Wiring HTTP 402 Paywalls Into MCP Servers on Cloudflare Workers (Base USDC + Solana USDC)", "summary": "A developer built cf-x402-mcp, a Cloudflare Workers deployment that puts a per-call USDC paywall in front of an MCP server by issuing HTTP 402 challenges with a PAYMENT-REQUIRED header (x402 v2, scheme exact, USDC on Base) ahead of the Model Context Protocol SDK's WebStandardStreamableHTTPServerTransport, since the agents@0.35 package ships only an x402 client and no server-side paywall helper. The live endpoint exposes four paid tools priced at 0.01–0.02 USDC plus a free sample helper, and a second Worker, coingecko-longtail-agent, applies the same pattern on Solana USDC for pool telemetry, SPL authority checks, simulated exit slippage and memo-based audit hashing. The developer flags open questions around facilitator liveness and trust and notes the risk filter catches obvious rug or wash-trade signals but is not a security guarantee.", "body_md": "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.\n\nThere 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.\n\n`agents@0.35` Ships the Client, Not the Server Paywall\nWhen 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.\n\nSo in [`src/x402.ts`](https://github.com/xgbtxy/cf-x402-mcp), I wrote a small, zero-extra-dependency paywall right in front of `@modelcontextprotocol/sdk`'s `WebStandardStreamableHTTPServerTransport` (`POST /mcp`).\n\nThe request flow is straightforward:\n\n`402` with a `PAYMENT-REQUIRED` header (x402 v2, scheme `exact`, USDC on Base `eip155:8453`).` FACILITATOR_URL`, defaulting to `https://x402.org/facilitator`).` cf-x402-mcp`\nThe live endpoint is running on Cloudflare Workers:\n\n`https://cf-x402-mcp.yan8925298.workers.dev/mcp`\n`https://cf-x402-mcp.yan8925298.workers.dev/.well-known/x402`\n`https://cf-x402-mcp.yan8925298.workers.dev/openapi.json`\n`https://www.x402scan.com/server/9b24c611-587b-49f1-940c-c8c93b4b8bec` (4/4 endpoints registered)\nIt 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.\n\nFor example, `ci_log_sieve` pairs naturally with [`ap` v2.96.0](https://github.com/xgbtxy/ap) when you want to compress noisy CI/build logs into root causes and deduped errors before feeding them back to an LLM.\n\n`coingecko-longtail-agent`\nTo check whether the same pattern holds on another chain, I built [`coingecko-longtail-agent`](https://github.com/xgbtxy/coingecko-longtail-agent) (live demo at `https://coingecko-longtail-agent.yan8925298.workers.dev`) for the Superteam x CoinGecko Long Tail Hackathon.\n\nIt combines:\n\n`/networks/solana/new_pools`, `/networks/solana/trending_pools`, `/networks/solana/tokens/{mint}/pools`, `/search/pools?network=solana`) for pool telemetry.` getAccountInfo`, `getTokenLargestAccounts`) for SPL mint/freeze authority and holder concentration checks.`$500` and `$2,500` simulated exits against Solana USDC) to flag paper liquidity vs. real exit slippage.`MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) to hash audit decisions into unsigned memo instructions without the agent holding private keys.`/premium/analyze` returns `accepts[0].network = \"solana\"`.\nThe plumbing works, and both Workers are live, but a few things are still open questions for me:\n\n`X402_FACILITATOR_URL`). That is a liveness and trust assumption worth calling out explicitly.`src/risk.ts`) is a useful filter for obvious rug/wash-trade signals, not a security guarantee.\nIf 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.", "url": "https://wpnews.pro/news/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana", "canonical_source": "https://dev.to/xgbtxy/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana-usdc-8ja", "published_at": "2026-12-06 02:09:43+00:00", "updated_at": "2026-12-06 02:14:12.498691+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["Cloudflare Workers", "cf-x402-mcp", "x402", "agents@0.35", "Model Context Protocol", "coingecko-longtail-agent", "CoinGecko", "Solana"], "also_reported_by": [], "takeaway": "A zero-dependency HTTP 402 paywall can sit in front of an MCP server's WebStandardStreamableHTTPServerTransport on Cloudflare Workers, charging 0.01–0.02 USDC per tool call via x402 v2 with a PAYMENT-REQUIRED header and a facilitator URL, since agents@0.35 provides only the client side.", "recommendation": {"advice": "If you monetize MCP tools, implement the x402 server-side 402 challenge yourself in front of the transport and make the facilitator URL configurable, since agents@0.35 ships only the client.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana", "markdown": "https://wpnews.pro/news/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana.md", "text": "https://wpnews.pro/news/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana.txt", "jsonld": "https://wpnews.pro/news/wiring-http-402-paywalls-into-mcp-servers-on-cloudflare-workers-base-usdc-solana.jsonld"}}