Open-source Infrastructure for MCP and x402
MCPay is a growing TypeScript project in the AI payments / x402 ecosystem, focused on mcp, x402. It currently has 91 GitHub stars and 34 forks, and sits alongside related tools like daydreams, machi, blockrun-mcp, awesome-fintech, awesome-x402, lucid-agents.

MCPay is open-source infrastructure that adds on-chain payments to any Model Context Protocol (MCP) server using the x402 "Payment Required" protocol.
It enables MCP clients — such as ChatGPT, Cursor, and others — to make pay-per-call requests instead of relying on static subscriptions or API keys.
The goal is to let AI agents and applications pay only for what they use, automatically and transparently.
MCPay handles the entire payment lifecycle transparently for both developers and clients:
This mechanism ensures that any MCP-compatible app or agent can pay per call — either directly (via wallet) or through a delegated, policy-based proxy.
sequenceDiagram
participant C as MCP Client
participant CP as Client Proxy + Wallet
participant P as MCPay Proxy (Edge)
participant U as Upstream Service<br/>(Server Proxy / x402 MCP / api2 / mcp2)
participant B as Blockchain (USDC/EUROe)
participant D as Analytics/Dashboard
C->>CP: (1) MCP call
CP->>P: (2) Forward request
%% normal path: proxy upstreams the original call
P->>U: (3) Upstream original request
alt Upstream returns price-gated
U-->>P: (4) 402 + price metadata
alt Proxy is authorized to pay (MCPay Auth/wallet & policy allows)
P->>B: (5a) Pay on-chain
B-->>P: (6a) Payment confirmation
P->>U: (7a) Retry original request
U-->>P: (8a) Result
P-->>CP: (9a) Forward result
CP-->>C: (10a) Deliver result
else Proxy cannot/shouldn't pay
P-->>CP: (5b) Downstream 402 + price metadata
CP->>B: (6b) Client-side payment (sign via wallet/MCPay Auth)
B-->>P: (7b) Confirmation to proxy
P->>U: (8b) Retry original request
U-->>P: (9b) Result
P-->>CP: (10b) Forward result
CP-->>C: (11b) Deliver result
end
else Upstream returns success
U-->>P: (4') Tool result
P-->>CP: (5') Forward result
CP-->>C: (6') Deliver result
end
P-->>D: (✱) Emit usage & revenue events (both branches)
In practice, this means any MCP server can become a paid endpoint with zero friction.
The MCPay proxy acts as the coordination layer between clients, wallets, and upstream services — automatically handling 402 negotiation, on-chain payments, and retries.
Once a payment is confirmed, the same request is retried transparently, and the result is streamed back to the client along with usage and revenue data.
Discover MCP servers and their priced tools at mcpay.tech/servers. Searchable, machine‑readable, agent‑friendly.
Wrap existing HTTP endpoints or MCP servers with the MCPay proxy to enforce pay‑per‑call. Zero code changes to your upstream service.
You can monetize via MCPay Registry or programmatically.
MCPay lets you add on-chain pricing to any MCP or OpenAPI server.
Whether you prefer to configure everything from the dashboard or define logic in code, both paths use the same x402 standard.
| Path | Best for | What it does |
|---|---|---|
| Website | Fastest go-live, existing services | Configure prices per tool/route in the dashboard. |
| SDK | Custom logic & full control | Define paid tools in code, set pricing, and ship an MCP server that speaks x402 out of the box. |
Start an MCP stdio proxy to one or more remote MCP servers. Use either an API key or a wallet private key.
# Using an API key (recommended)
npx mcpay connect --urls https://mcpay.tech/v1/mcp/05599356-7a27-4519-872a-2ebb22467470 --api-key mcpay_YOUR_API_KEY
# Or using an EVM wallet private key (x402 payments)
npx mcpay connect --urls https://mcpay.tech/v1/mcp/05599356-7a27-4519-872a-2ebb22467470 --evm 0xYOUR_PRIVATE_KEY --evm-network base-sepolia
# Or using an SVM wallet secret key (x402 payments)
npx mcpay connect --urls https://mcpay.tech/v1/mcp/05599356-7a27-4519-872a-2ebb22467470 --svm YOUR_SECRET_KEY --svm-network solana-devnet
You can pass multiple URLs via a comma‑separated list to --urls.
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
import { withX402Client } from 'mcpay/client'
import { createSigner } from 'x402/types'
// Create signer for EVM network
const evmSigner = await createSigner('base-sepolia', process.env.EVM_PRIVATE_KEY!) // dev only; secure in prod
const url = new URL('https://mcpay.tech/v1/mcp/05599356-7a27-4519-872a-2ebb22467470')
// Create transport
const transport = new StreamableHTTPClientTransport(url)
// Initialize MCP client
const client = new Client({ name: 'my-mcp-client', version: '1.0.0' }, { capabilities: {} })
await client.connect(transport)
// Wrap client with X402 payment capabilities
const paymentClient = withX402Client(client, {
wallet: { evm: evmSigner },
maxPaymentValue: BigInt(0.1 * 10 ** 6) // limit max on‑chain value (base units, e.g. 6‑decimals for USDC)
})
const tools = await paymentClient.listTools()
console.log('Available tools:', tools)
Install:
npm i mcpay # pnpm add mcpay / yarn add mcpay / bun add mcpay
Features:
402 handling (x402 pattern).See js-sdk/README.md for API details.
import { Hono } from "hono"
import { createMcpPaidHandler } from "mcpay/handler"
import { z } from "zod"
const app = new Hono()
const handler = createMcpPaidHandler(
(server) => {
server.paidTool(
"weather",
"Paid tool",
"$0.001",
{ city: z.string() },
{},
async ({ city }) => ({
content: [{ type: "text", text: `The weather in ${city} is sunny` }],
})
)
server.tool(
"free_tool",
"Free to use",
{ s: z.string(), city: z.string() },
async ({ s, city }) => ({
content: [{ type: "text", text: `We support ${city}` }],
})
)
},
{
facilitator: {
url: "https://facilitator.mcpay.tech"
},
recipient: {
"evm": {address: "0xc9343113c791cB5108112CFADa453Eef89a2E2A2", isTestnet: true},
"svm": {address: "4VQeAqyPxR9pELndskj38AprNj1btSgtaCrUci8N4Mdg", isTestnet: true}
}
},
{
serverInfo: { name: "paid-mcp", version: "1.0.0" },
},
)
app.use("*", (c) => handler(c.req.raw))
export default app
Start a local stdio proxy to remote MCP servers:
{
"mcpServers": {
"Paid Server": {
"command": "npx",
"args": [
"mcpay",
"connect",
"--urls",
"https://mcpay.tech/v1/mcp/05599356-7a27-4519-872a-2ebb22467470",
"--api-key",
"mcpay_YOUR_API_KEY"
]
}
}
}
Run mcpay connect --help for all flags.
Daydreams is a set of tools for building agents for commerce
Agent behavior that compiles
Live data for AI agents — search, research, markets, crypto, X/Twitter. Pay-per-call via x402 micropayments.
A curated collection of open source fintech libraries and resources.
🚀 Curated list of x402 resources: HTTP 402 Payment Required protocol for blockchain payments, crypto micropayments, AI agents, API monetization. Includes SDKs (TypeScript, Python, Rust), examples, facilitators (Coinbase, Cloudflare), MCP integration, tutorials. Accept USDC payments with one line of code. Perfect for AI agent economy.
Lucid Agents Commerce SDK. Bootstrap AI agents in 60 seconds that can pay, sell, and participate in agentic commerce supply chains. Our protocol agnostic SDK provides CLI-generated templates and drop-in adapters for Hono, Express, Next.js, and TanStack, giving you instant access to crypto/fiat payment rails (AP2, A2A, x402, ERC8004).
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
The first agentic payment network: policy-controlled, gasless, and real money-ready. OmniClaw CLI + Financial Policy Engine let autonomous agents pay and earn safely at machine speed.
The A2A x402 Extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.
Aser is a lightweight, self-assembling AI Agent frame.
A small, powerful, open-source CLI coding agent that works with open models.
Open-source MCP servers for Latin American commerce — Pix, NF-e, banking, fiscal, logistics, and messaging across Brazil, Mexico, Argentina, Colombia, Chile, and Peru. MIT, on npm.