-
Notifications
You must be signed in to change notification settings - Fork 4
Architecture
github-actions[bot] edited this page Jul 14, 2026
·
33 revisions
One Node 22 / Express process serving everything; deliberately boring where possible.
┌──────────────────────────────────────────────┐
agent (buyer) ───▶ │ Express │
│ free surfaces: /, /tools, /api/pricing, │
│ /openapi.json, /llms.txt, /api/stats, │
│ /api/pow*, /mcp, /privacy │
│ gate (per request): │
│ marketplace token? ──▶ bypass │
│ valid X-Pow-Solution? ──▶ bypass │
│ else ──▶ x402 paywall (402 quote / │
│ verify+settle via facilitator) │
│ 500+ tool handlers (pure fns + kits) │
└──────┬───────────────┬───────────────────────┘
│ │
Playwright Chromium SQLite (WAL) on /data volume
ffmpeg (no shell) (stats · memory · pow replay)
-
Catalog as data. Every tool is an entry
{ route, slug, price, description, discovery: { inputSchema, example }, handler }. The paywall, docs pages, OpenAPI spec, llms.txt, sitemap, MCP servers, and CI tests are all generated from the same catalog — one source of truth, so a new tool is automatically priced, documented, discoverable, and tested. -
Payments (
src/payments.js):@x402/expressmiddleware quoting USDC on Base, Solana, Polygon, Arbitrum, Monad, Stellar & Algorand, settled through the Coinbase CDP facilitator (CDP_API_KEY_ID/SECRET;FACILITATOR_URLoverrides) for the EVM/Solana rails, with dedicated facilitators for Stellar (OpenZeppelin) and Algorand (GoPlausible). Multi-chain USDC schemes are registered in code. Monad (EVM chain id 143, native Circle USDC) is opt-in viaPAYMENT_NETWORKS=…,monadand settles through its own dedicated facilitator (MONAD_FACILITATOR_URL, default the molandak-operated public facilitator) since CDP/PayAI don't advertiseeip155:143. Robinhood Chain (USDG / Global Dollar, chain id 4663) settles through an operator-supplied facilitator (ROBINHOOD_FACILITATOR_URL) with a custom USDG money parser. -
Proof-of-work (
src/pow.js): HMAC-signed challenges, difficulty 16 bits, single-use (replay table in SQLite), strictly slug-scoped. AWALLET_ONLY_SLUGSset keeps anything that costs real money out of the free tier. -
Browser tools (
src/tools/render.js): a shared headless Chromium with max 3 concurrent contexts, self-healing relaunch on crash, and per-request SSRF re-validation of every subresource the page loads (see Security Model). -
Media tools: ffmpeg via
execFile(no shell), 30 MB cap, 90 s timeout, max 2 concurrent with429 + Retry-After. -
Remote MCP (
src/mcp-http.js): stateless streamable-HTTP endpoint mounted before the paywall; it meters itself (free set + per-IP rate limit) and feeds the same stats counters. -
x402 Index + Router (
src/x402-index.js): a free, in-memory aggregation layer. Crawls the local catalog + operator seeds + auto-discovered sellers (from public x402 registries, refreshed hourly) every 5 minutes viasafeFetch. Every crawl outcome lands in a rolling 5-entry history per seller; the Smart Order Router (POST /api/route) skips sellers whose recent history shows errors, and tiebreaks on health then price. Public surfaces:/index(HTML),/api/index(JSON),/api/route(router). See x402-Index-and-Router. -
State: SQLite (better-sqlite3, WAL) on a Railway persistent volume at
/data— stats, memory namespaces, PoW replay protection all survive redeploys. - Shutdown: SIGTERM drains in-flight requests before exit, because a hard kill would take an agent's money and return nothing.
- No LLM in the serving path. Determinism is the product: schemas, flat prices, reproducible outputs.
- Payment is identity. No accounts means no credential database, no signup abuse surface, and memory ownership falls out of the payment protocol for free.
- Charge-then-fail is unacceptable. x402 settles before the handler runs, so anything that can't be served reliably (e.g. upstreams that block datacenter IPs) gets removed from the catalog rather than monetized.
agent402.tools · synced from wiki/ in the main repo — edit there, not here.
Using it (for agents / buyers)
- Getting Started
- Paying with x402
- Robinhood Chain (USDG)
- Paying with Compute
- MCP Connector
- Adapters
- AWS Bedrock AgentCore
- Tool Catalog
- Skill Packs
- x402 Index and Router
- x402 Leaderboard
- LLM Gateway (OpenAI /v1)
- LLM Proxy Gateway
- Image Generation Gateway
- Code Execution Sandbox
- Text-to-Speech
- Speech-to-Text
- Text Embeddings
- Payments and x402
- Memory and Coordination
Tollbooth (for site owners)
- Pay-per-crawl — what it is, install, modes
- Pay-per-crawl Walkthrough — 5-min hands-on
- Tollbooth for Agencies — many-site playbook
- Try Tollbooth Cloud (managed)
Website & Developer
- Quickstart — first call in 60 seconds
- Playground — try tools in your browser
- SDK REPL — live code editor
- API Explorer — browse OpenAPI
- Adapter Docs — per-framework guides
- Workflows — chaining patterns
- Blog · Changelog
Under the hood