All articles
mcpayx402mcpsolanaagentspaymentsusdc

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 link

MCPay: 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

MCPay stack
PieceJob
Proxy / monetizerSits in front of an existing MCP or HTTP endpoint; returns 402 with payment requirements; retries after on-chain payment
JS SDKClient helpers for 402 handling, payment proofs, verification
Facilitator pathSame x402 facilitator model as other Solana/Base sellers (PayAI, etc.)
EventsUsage 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

  1. Agent invokes an MCP tool through the MCPay-facing endpoint.
  2. Proxy responds with 402 Payment Required and x402 payment details (amount, asset, payTo, network).
  3. Agent wallet pays USDC on Solana or Base (exact scheme depends on deployment).
  4. Proxy verifies settlement (facilitator or local verify), then forwards the original tool call and returns the result.
bash
# 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 → retry

Solana 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

Chooser
SituationPrefer
Existing MCP server, want price tags fastMCPay proxy
Greenfield Next/edge route, not MCPDirect x402 seller (build guide)
Only need paid HTTP APIs, no MCPx402 middleware or Cloudflare monetization gateway
Agent needs to buy many toolsx402-capable MCP client + wallet; MCPay optional on supply side

People and links

MCPay triad
SurfaceLink
Sitemcpay.tech
Docsdocs.mcpay.tech
GitHubmicrochipgnu/MCPay
X@mcpaytech (project also references Frames migration — check latest handle)
Org/organisations/mcpay

Resources

Keep reading

Get new articles in your inbox

Technical deep-dives on Solana tooling, infrastructure, and ecosystem. No noise.

MCPay: wrap any MCP server in x402 | devrels.xyz