PayGate MCP
Monetization gateway for Model Context Protocol servers. Put any MCP server behind a pay-per-call toll that AI agents can settle autonomously — no signup, no API keys, no human in the loop.
Live endpoint: https://paygate-mcp.rendercriativo.workers.dev/mcp
[x402]
[network]
[license]
What it does
An agent calls a tool. If the tool is monetized, PayGate answers with an x402 v2 payment challenge instead of the result. The agent signs a USDC transfer authorization, retries, and gets its answer. Settlement happens on Base; the developer never touches payment code.
Payment is verified before the tool runs and settled after it returns. If the tool fails or returns an error, nothing is charged.
For agents
Discovery is free. Ask PayGate what is for sale:
Calling a monetized tool without payment returns a spec-compliant challenge — a tool result with isError: true whose structuredContent holds the PaymentRequired object:
Sign an EIP-3009 TransferWithAuthorization using exactly the domain in extra, then retry the call with the payment attached under params._meta["x402/payment"]. The settlement receipt comes back in _meta["x402/payment-response"].
The USDC EIP-712 domain name is "USD Coin" on Base mainnet and "USDC" on Base Sepolia. Using the wrong one makes every signature fail verification.
A working reference client is in scripts/pay-test.mjs:
The paying wallet needs USDC on Base — but no ETH: gas is covered by the facilitator.
Both x402 transports are supported. HTTP clients can use the base64 PAYMENT-REQUIRED / PAYMENT-SIGNATURE / PAYMENT-RESPONSE headers instead of the MCP _meta binding.
For sellers
The whole seller lifecycle is exposed as MCP tools, so an agent can run it end to end — tell your assistant to monetize your server and it can do everything below on its own:
Buyers pay your wallet directly on-chain. PayGate never holds your funds — there is no payout to wait for, no balance to withdraw, and no commission on direct payments. Your server is never modified: PayGate forwards initialize, tools/list, resources/list and prompts/list for free and charges only on tools/call.
The same operations exist as REST (POST /api/register, PUT /api/me/tools, GET /api/me/earnings) if you prefer curl:
Health and diagnostics
GET /health/x402 reports whether the payment rail is actually able to charge:
Configuration
Runtime values live in wrangler.jsonc (vars) and Cloudflare secrets.
Base Sepolia needs no credentials: the public facilitator at https://x402.org/facilitator settles testnet USDC for free — the cheapest way to try the whole flow.
Layout
Development
Built on Cloudflare Workers, Hono, and D1.
License
MIT