Agent Tollbooth 402
An MCP server for monetizing APIs and MCP tools with HTTP 402 x402 payments, handling price quotes, prepaid agent wallets, signed receipts, payment verification, and ledger/pass management.
tollbooth_pricing_quote— Compute clearinghouse fee and developer net payout in integer microdollars for a given per-call price and monthly volume.tollbooth_wallet_balance— Read an agent wallet's credit balance, status, and remaining daily spend cap.tollbooth_issue_receipt— Mint a short-lived Ed25519-signedrcs_receiptbearer token that debits an existing prepaid wallet (with audience, method, and exact/upto scheme constraints).tollbooth_verify_x402— Validate an x402 V2PAYMENT-SIGNATURE(EIP-712 signer, USDC asset, network, payTo, amount, expiry, replay) without moving funds.tollbooth_create_topup_checkout— Generate a Stripe Checkout or sandbox URL to fund a wallet ($1+) or buy a Pro/Agency Pass.tollbooth_register_wallet— Create an empty prepaid agent wallet and return its ID and one-time wallet key.tollbooth_ledger_history— List recent top-ups, charges, and settlements for a wallet or developer account.tollbooth_pass_status— Show a developer's tier, fee rate, and whetheruptometering is enabled.
Supports Cloudflare D1 as a nonce store for replay protection in the tollbooth middleware.
Provides edge middleware for Cloudflare Workers to add HTTP 402 payment gating to APIs and routes, with optional D1-based nonce replay protection.
Scans Express routes to identify endpoints that can be wrapped with tollbooth monetization.
Offers Hono middleware (honoTollbooth) to monetize Hono app routes with HTTP 402 payments.
Enables adding withTollbooth payment gating to Next.js route handlers and supports scanning Next.js App Router endpoints.
Integrates with Stripe for fiat-funded agent wallets and Stripe Connect payouts in the hybrid clearinghouse payment rail.
This server has a remotely hosted endpoint. Open its connector listing for connection details, authentication requirements, and setup instructions:
Agent Tollbooth 402
Monetize APIs, Cloudflare Workers, Hono apps, Next.js routes, and MCP servers in under 60 seconds with HTTP 402 payments that go straight to your own wallet.
Built by Red Center Studio for Google Antigravity and Claude Code.
3-Line Quickstart (30-Second Zero-Config Sandbox)
npm install
npm run validate
npm run test:sandboxZero API keys, zero crypto wallets, and zero Stripe setup required to run your first 402 -> sign -> 200 OK loop locally.
Related MCP server: Loop MCP DualRail
5-Line withTollbooth Setup
Copy-paste into any Cloudflare Worker, Web Fetch handler, or Next.js route:
import { withTollbooth } from "@redcenterstudio/agent-tollbooth-edge";
export default withTollbooth({ priceUsd: 0.01, mode: "x402", payTo: "0xYourBaseUSDCWallet", network: "eip155:84532" }, async (request) => {
return Response.json({ ok: true, path: new URL(request.url).pathname });
});Local test without wallets or keys: change
mode: "x402"tomode: "sandbox"and callcreateSandboxReceipt()orcreateSandboxX402Header().Hono middleware:
app.use("/api/*", honoTollbooth({ priceUsd: 0.01, mode: "x402", payTo: "0xYourBaseUSDCWallet", network: "eip155:84532" })).Cloudflare D1 replay protection: pass
nonceStore: new D1NonceStore(env.DB)insidewithTollbooth((env) => ({ ... }), handler).
Live Clearinghouse & Screenshots
Live clearinghouse portal & MCP endpoint: https://tollbooth.redcenterstudio.com (/pay · /demo/402)
Setup Walkthrough Video (MP4): copying the install command, running the live
402check, and inspecting the browser checkout card.

HTTP 402 Browser Checkout Card | Mobile Responsive Layout ( |
|
|
How It Works & Browser 402 Card
agent-tollbooth-402 takes x402 V2 on-chain USDC authorizations paid straight to your payTo wallet. Prepaid Red Center agent wallet receipts are accepted on Red Center Studio's own routes only; they are not a way for other developers to get paid.
Programmatic AI Agents (
Accept: application/json): Receive402 Payment Requiredwith Base64PAYMENT-REQUIRED,WWW-Authenticate, CORSAccess-Control-Expose-Headers,priceUsd,acceptedRails,code, and a plain-Englishfix_hint.Human Browser Requests (
Accept: text/html): Receive a responsive Red Center Studio402Checkout Card (#24181aIronstone,#d9622bRed Ochre,#e3a23cSpinifex Gold,#f5efe6Sand) displaying endpoint details, price, a payment snippet, and a How AI agents pay link.
flowchart LR
Agent["AI Agent / Browser"] -->|1. Request API or /mcp| Edge["@redcenterstudio/agent-tollbooth-edge"]
Edge -->|2. Unpaid -> 402 JSON or HTML Card| Agent
Agent -->|3A. Rail A: PAYMENT-SIGNATURE x402 V2| Edge
Agent -->|3B. Studio routes only: Bearer rcs_receipt_...| Edge
Edge -->|4A. /verify & /settle| Facilitator["Clearinghouse Worker / Facilitator"]
Edge -->|4B. HMAC-SHA256 / Ed25519 + D1 used_nonces| NonceDB[("Cloudflare D1")]
Facilitator -->|Atomic Debit & Ledger| NonceDB
Edge -->|5. 200 OK + PAYMENT-RESPONSE| AgentPricing
Tier | Price | Fee on your payments | What You Get |
Free (DIY) |
|
| The connector (MCP server), plugin and skills ( |
Tollbooth Pro Pass |
|
| Hosted Base mainnet ( |
Agency Pass |
|
| The same as Pro for multiple projects and client sites. |
Done-For-You Integration | From | Custom | End-to-end custom MCP + HTTP 402 Tollbooth wrapping, D1 ledger setup, and verification by Red Center Studio. |
Payments always go straight to your own payTo wallet in USDC. Red Center Studio never holds your money and takes 0% of payments.
DIY setup in 4 steps
Register a developer account with your Base wallet as the payout address (
POST /developer/registeror the connector).Run
/install-tollboothin Claude Code (or add the middleware by hand) withpayToset to that wallet.Test free on Base Sepolia with
/test-agent.Buy a Pro Pass to go live on Base mainnet.
Plugin Installation (Antigravity + Claude Code)
Install in Claude Code:
/plugin install agent-tollbooth-402 --marketplace Red-Center-Studio/agent-tollbooth-402Install in Antigravity (~/.gemini/config/plugins/):
git clone https://github.com/Red-Center-Studio/agent-tollbooth-402.git ~/.gemini/config/plugins/agent-tollbooth-402Install the zero-dependency Edge Middleware in a Worker, Hono, or Next.js project:
npm install @redcenterstudio/agent-tollbooth-edgeRemote MCP Server (
mcp_config.json&.mcp.json): Connects tohttps://tollbooth.redcenterstudio.com/mcpvia Streamable HTTP (tollbooth_pricing_quote,tollbooth_wallet_balance,tollbooth_issue_receipt,tollbooth_verify_x402,tollbooth_create_topup_checkout,tollbooth_register_wallet,tollbooth_ledger_history,tollbooth_pass_status). See our Privacy Policy.Skills (
skills/):scan-routes: Audits Cloudflare Workers, Hono, Next.js App Router, Express, and MCP endpoints.install-tollbooth: Auto-detects framework, previews diff, and injects 1-stepwithTollbooth(...).test-agent: Runs the 30-second zero-config sandbox402 -> sign -> 200 OKsmoke test.
Scoped Guardrails (
rules/http-402-guardrails.md): Enforces bypass exemptions, constant-time Web Crypto checks, replay protection, downstream5xxidempotency, integer microdollar math, and spend caps.
Accounts, keys and receipts
POST /developer/registercreates a developer account and returns a developer key (rcs_dk_...), shown once. Send your Base wallet aspayoutAddress.POST /wallet/registercreates an empty prepaid agent wallet (rcs_wk_...); prepaid wallets pay Red Center Studio's own routes only, not other developers. Only SHA-256 hashes of keys are stored;POST /keys/rotatereplaces a key.A wallet key can read only its own balance and ledger, and can only request receipts that spend from its own wallet.
Receipts for Red Center Studio routes are signed with Ed25519. They are verified with the public key at
https://tollbooth.redcenterstudio.com/.well-known/tollbooth-jwks.jsonand never hold a secret that could mint receipts:
import { fetchTollboothPublicKey, withTollbooth } from '@redcenterstudio/agent-tollbooth-edge';
const ed25519PublicKey = await fetchTollboothPublicKey(); // cache this
export default withTollbooth({ mode: 'x402', payTo: '0xYourBaseUSDCWallet', fiatWallet: { ed25519PublicKey } }, handler);x402 settlement
/verifyrecovers the EIP-712TransferWithAuthorizationsigner with secp256k1 and checks it is the payer, along with the USDC asset, network, recipient, amount, expiry and replay records./settlesubmits the transfer through an on-chain facilitator: the public x402.org facilitator on Base Sepolia (eip155:84532), free. Hosted Base mainnet (eip155:8453) settlement needs a Pro or Agency Pass; without one, settle mainnet through your own facilitator. A settlement that cannot run is refused, never faked.Payments go straight to your
payTowallet, so x402 carries no Red Center fee.
Troubleshooting FAQ
Error Code | Meaning | Fix ( |
| Request had neither | Attach an x402 V2 |
| Payment authorization or wallet balance is below | Authorize at least |
|
| Re-sign a fresh receipt or x402 authorization using synchronized UTC seconds. |
| The receipt | Generate a new unique |
| Web Crypto HMAC/Ed25519 verification failed, or | Confirm |
Browser CORS blocked reading headers | Browser client cannot read | Middleware automatically sets |
Reference Clearinghouse Note (
packages/clearinghouse-worker): Includes placeholder D1 IDs (wrangler.jsonc) and.dev.vars.exampleplaceholders. Supply your own D1 database and Wrangler secrets before deploying to your own Cloudflare account.
License
MIT, Red Center Studio (https://redcenterstudio.com)
Available Tools
8 toolstollbooth_create_topup_checkoutGenerate Checkout Link URLARead-onlyIdempotentInspect
Return a Stripe Checkout or sandbox link URL that a user can open in a browser to fund a wallet ($1+) or purchase a Pro ($39) / Agency ($79) Pass. Never charges automatically.
Inputs: passTier, walletId, amountUsd, developerId.
tollbooth_issue_receiptIssue Signed Bearer ReceiptAInspect
Issue a short-lived Rail B rcs_receipt bearer token (Ed25519-signed, verifiable with /.well-known/tollbooth-jwks.json) that spends from an existing prepaid wallet balance. Needs the wallet key for that wallet. Does not move bank or crypto funds.
Inputs: audience (required), walletId (required), developerId (required), amountMicros (required), +3 more.
tollbooth_ledger_historyLedger HistoryARead-onlyIdempotentInspect
List recent ledger entries (top-ups, charges, settlements) for a wallet or a developer account, newest first. Read-only. Needs that account's wallet or developer key.
Inputs: limit, walletId, developerId.
tollbooth_pass_statusPass StatusARead-onlyIdempotentInspect
Show a developer account's tier (hybrid, pro or agency), its Fiat Agent Wallet fee rate and whether upto metering is on. Read-only. Needs the developer key.
Inputs: developerId (required).
tollbooth_pricing_quotePricing & Net Revenue QuoteARead-onlyIdempotentInspect
Compute clearinghouse fee and developer net payout across Free BYO x402 (0%), Hybrid (7%), and Tollbooth Pro/Agency (3%) tiers in integer USD microdollars.
Inputs: priceMicros (required), callsPerMonth (required).
tollbooth_register_walletRegister Agent WalletAInspect
Create an empty prepaid Fiat Agent Wallet and return its wallet ID and wallet key (shown once). Moves no money; fund it later with tollbooth_create_topup_checkout.
Inputs: email, label, dailySpendCapUsd.
tollbooth_verify_x402Verify x402 V2 Payment HeaderBRead-onlyIdempotentInspect
Verify an x402 V2 exact payment: EIP-712 TransferWithAuthorization signature recovered against the payer, USDC asset and network, recipient, amount, expiry and replay records. Read-only; does not execute on-chain transfers.
Inputs: x402Version (required), paymentPayload (required), paymentRequirements (required).
tollbooth_wallet_balanceCheck Wallet Credit BalanceARead-onlyIdempotentInspect
Inspect an agent wallet credit balance, status, and remaining UTC daily spend cap. Read-only. Needs the wallet key for that wallet (Authorization: Bearer rcs_wk_...).
Inputs: walletId (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool maps to a distinct action (status, balance, issue receipt, verify payment, register, ledger, checkout, quote) and descriptions name the required credential, which strongly separates them. The only mild overlap is between tollbooth_pass_status and tollbooth_wallet_balance, both read-only status reads that differ mainly by key scope.
All eight tools use a uniform tollbooth_ prefix followed by a verb_noun pattern (register_wallet, create_topup_checkout, issue_receipt, verify_x402, ledger_history). Naming is predictable and readable across the whole set.
Eight tools is well within the ideal range and each covers a discrete step in the wallet lifecycle (status, balance, register, fund, issue, verify, ledger, price). Nothing feels redundant or padding-like.
The surface covers onboarding (register), funding (Stripe checkout), spend authorization (receipt issuance, x402 verification), reporting (balance, ledger), pricing, and tier status, which is most of the domain. Gaps remain around key rotation/revocation, wallet closure, and explicit refund/dispute or settlement actions, which agents would have to work around.
Maintenance
Related MCP Connectors
Pay-per-action access to APIs and MCP tools over Lightning L402 and Base USDC x402.
Monetize any MCP server: x402 paywall, pay-per-call billing in USDC on Base, agent marketplace.
Billing proxy for MCP servers. Adds Stripe and x402 crypto payments without writing billing code.
Free self-hosted x402 USDC billing for Cloudflare MCP servers, with a Base Sepolia test endpoint.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceHTTP 402 paywall middleware for MCP servers. XRPL/RLUSD native settlement, Phase 3 compliance receipts, zero API keys required.1MIT

Loop MCP DualRailofficial
AlicenseNot gradedqualityBmaintenanceEnables AI agents to pay for MCP tool calls using either Bitcoin/Lightning (L402) or USDC (x402) rails, with unified settlement and a 21% discount for Bitcoin payments.32 npmMIT- AlicenseNot gradedqualityDmaintenanceNon-custodial payment engine for AI agents supporting BTC, ETH, USDT, USDC, XRP, XMR, and ZEC. Exposes wallet, invoice, and payment tools over MCP with per-agent spend limits, plus x402 pay-per-call support.59 npmBusiness Source 1.1
- AlicenseBqualityCmaintenanceMCP server providing AI agents access to 38 pay-per-call APIs (LLM, image, code, audio, crypto, web, IPFS) via HTTP 402 micropayments in USDC/USDm.22140 npm1MIT

