MCPay: wrap any MCP server in x402
Monetize Model Context Protocol tools with x402 micropayments — proxy any MCP/HTTP endpoint, Solana and Base USDC, no rewrite of business logic.
devrels.xyz/a/243short linkMCPay: wrap any MCP server in x402. MCPay is open-source infrastructure that puts HTTP 402 / x402 in front of Model Context Protocol tools so agents pay per call in stablecoins instead of holding API keys or subscriptions.
Problem
MCP made tools easy to expose to Cursor, Claude, and custom agents. Monetization did not: you either keep the server free, bolt on OAuth + Stripe, or invent a prepaid credits ledger. Agents already understand x402 on the open web; MCPay brings that loop to MCP without rewriting the tool implementation.
Architecture
| Piece | Job |
|---|---|
| Proxy / monetizer | Sits in front of an existing MCP or HTTP endpoint; returns 402 with payment requirements; retries after on-chain payment |
| JS SDK | Client helpers for 402 handling, payment proofs, verification |
| Facilitator path | Same x402 facilitator model as other Solana/Base sellers (PayAI, etc.) |
| Events | Usage and revenue streams for the tool owner |
Business logic stays put. You point MCPay at the URL (or MCP transport) you already run; pricing and pay-to address live in the monetizer config.
Payment flow
- Agent invokes an MCP tool through the MCPay-facing endpoint.
- Proxy responds with 402 Payment Required and x402 payment details (amount, asset, payTo, network).
- Agent wallet pays USDC on Solana or Base (exact scheme depends on deployment).
- Proxy verifies settlement (facilitator or local verify), then forwards the original tool call and returns the result.
# Conceptual — see docs.mcpay.tech for current CLI flags
# Point monetizer at an existing MCP HTTP URL and set price + payTo
npx mcpay server \
--urls https://your-mcp.example/mcp \
--private-key <facilitator-or-server-key-if-required>
# Clients: wrap MCP SDK client with x402 payment (Solana or EVM signer)
# so tool calls auto-handle 402 → pay → retrySolana notes
- USDC on Solana is a first-class rail alongside Base in the x402 MCP ecosystem (confirm networks in your MCPay deploy config).
- Facilitators remove the need for every seller to run custom settlement logic — same pattern as PayAI.
- For agent CLIs that already speak 402, see pay.sh — complementary (CLI buyer) to MCPay (MCP seller proxy).
When to use MCPay vs build yourself
| Situation | Prefer |
|---|---|
| Existing MCP server, want price tags fast | MCPay proxy |
| Greenfield Next/edge route, not MCP | Direct x402 seller (build guide) |
| Only need paid HTTP APIs, no MCP | x402 middleware or Cloudflare monetization gateway |
| Agent needs to buy many tools | x402-capable MCP client + wallet; MCPay optional on supply side |
People and links
| Surface | Link |
|---|---|
| Site | mcpay.tech |
| Docs | docs.mcpay.tech |
| GitHub | microchipgnu/MCPay |
| X | @mcpaytech (project also references Frames migration — check latest handle) |
| Org | /organisations/mcpay |
Resources
Keep reading
Every API you use today requires an account, a key, a billing portal, and a rotation policy. x402 collapses that to one HTTP header. pay.sh implements it as a single binary that wraps curl — 76 providers across AI, data, compute, messaging, finance, and more. No keys to manage. No subscriptions.
Give an agent its own mailbox and delegated spend so verify → pay → receipt stays in one identity.
Agents still hit APIs that want a human account and credit card. pay.sh turns 402 Payment Required into a one-line wallet-approved call on Solana stablecoins.
Get new articles in your inbox
Technical deep-dives on Solana tooling, infrastructure, and ecosystem. No noise.
