Skip to content
Back to search

x402-mcp-agentcost

Standalone Pay-Per-Call x402 v2 MCP Server on Cloudflare Workers for AI Agent O(N^2) Cost Simulation, Pareto Routing & Prompt Cache Auditing

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/jettlin927--x402-mcp-agentcost/badge.svg)](/listings/jettlin927--x402-mcp-agentcost)

HTML

<a href="/listings/jettlin927--x402-mcp-agentcost"><img src="/api/listings/jettlin927--x402-mcp-agentcost/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 59 lines
  1. # x402-mcp-agentcost
  2. Standalone **Pay-Per-Call MCP Server** built for **Cloudflare Workers** implementing the **x402 v2 (`HTTP 402 Payment Required`)** machine-to-machine micropayment protocol over Base USDC.
  3. - **Web Companion UI**: [AgentCostLab](https://jettlin927.github.io/agentcostlab/) (`Jettlin927/agentcostlab`)
  4. - **Transport**: Streamable HTTP MCP (JSON-RPC 2.0 at `POST /mcp`)
  5. - **Discovery**: `GET /.well-known/mcp.json` & `GET /mcp`
  6. - **Payments**: `x402` v2 (`PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE`, `PAYMENT-RESPONSE` headers) + Facilitator `/verify` & `/settle`
  7. ## Tool Pricing
  8. | Tool | Price | Purpose |
  9. | :--- | :---: | :--- |
  10. | `list_models_pricing` | **FREE** | Discovery: 15 models with Nov-2026 pricing, AA Intelligence & SWE-bench scores |
  11. | `recommend_pareto_route` | **$0.005 USDC** | Pareto-optimal model + Hybrid Planner/Worker routing for a workload & budget |
  12. | `simulate_agent_cost` | **$0.005 USDC** | Full $O(N^2)$ multi-turn loop simulation with caching, retries & long-context step-ups |
  13. | `audit_prompt_cache_tax` | **$0.010 USDC** | Audit `CLAUDE.md` / `AGENTS.md` / `mcp.json` for token tax, secrets & cache-busters |
  14. ## Local Dev & Test
  15. ```bash
  16. npm install
  17. npm test
  18. npm run typecheck
  19. npm run dev
  20. ```
  21. ### Quick `curl` Verification (Local or Deployed)
  22. ```bash
  23. # 1. Free discovery
  24. curl -s http://localhost:8787/.well-known/mcp.json
  25. # 2. Unpaid call -> HTTP 402 Payment Required + PAYMENT-REQUIRED header
  26. curl -i -X POST http://localhost:8787/mcp \
  27. -H "Content-Type: application/json" \
  28. -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"recommend_pareto_route","arguments":{"turns":24}}}'
  29. # 3. Demo sandbox dry-run (when X402_ALLOW_DEMO=true)
  30. curl -s -X POST http://localhost:8787/mcp \
  31. -H "Content-Type: application/json" \
  32. -H "X-DEMO-MODE: true" \
  33. -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"recommend_pareto_route","arguments":{"turns":24}}}'
  34. ```
  35. ## Deploy to Cloudflare Workers
  36. ```bash
  37. # 1. Authenticate Wrangler
  38. npx wrangler login
  39. # 2. Set your Base USDC receiving wallet address (0x...)
  40. npx wrangler secret put X402_PAY_TO
  41. # 3. Deploy to global edge
  42. npm run deploy
  43. ```
  44. > To disable demo bypass in production, set `"X402_ALLOW_DEMO": "false"` in `wrangler.jsonc`.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.