x402-mcp
Allows integrating with x402-compatible servers such as the Coinbase x402 example server, enabling automatic payment for APIs that require payment via the x402 protocol.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@x402-mcpget data from resource server"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
x402-mcp
Minimal MCP server that calls an x402-paid HTTP API and automatically pays when it receives an HTTP 402 Payment Required.
This is basically the official guide implemented as a standalone repo so we can reuse it as context for:
seo402agent-casinoany other x402-enabled project
What this does
Exposes an MCP tool:
get-data-from-resource-serverTool calls
GET ${ENDPOINT_PATH}against${RESOURCE_SERVER_URL}If the API responds with 402 + PAYMENT-REQUIRED, the x402 axios wrapper:
parses requirements
signs a payment with your wallet
retries the request with the payment signature
Related MCP server: x402 Stellar MCP Server
Prerequisites
Node.js 20+
pnpm 10+
An EVM wallet with USDC on Base Sepolia (recommended for testing)
An x402-compatible server to call
easiest: Coinbase x402 example server (
servers/express)
Setup
pnpm install
cp .env.example .envEdit .env:
EVM_PRIVATE_KEY=0x...RESOURCE_SERVER_URL=http://localhost:4021ENDPOINT_PATH=/weather
Run (MCP server)
pnpm devThis runs an MCP server over stdio (what Claude Desktop expects).
Run (x402 example resource server)
In another terminal (separate repo):
git clone https://github.com/coinbase/x402.git
cd x402/examples/typescript
pnpm install && pnpm build
cd servers/express
pnpm devClaude Desktop config
Add this to your Claude Desktop config (exact file location depends on OS):
{
"mcpServers": {
"x402": {
"command": "pnpm",
"args": [
"--silent",
"-C",
"<ABS_PATH_TO>/x402-mcp",
"dev"
],
"env": {
"EVM_PRIVATE_KEY": "0x...",
"RESOURCE_SERVER_URL": "http://localhost:4021",
"ENDPOINT_PATH": "/weather"
}
}
}
}Restart Claude Desktop.
Then ask Claude to call the tool get-data-from-resource-server.
How do non-crypto people / agents pay?
x402 always needs a signer somewhere. There are basically 3 viable UX models:
Power-user model (today): the human running the agent sets
EVM_PRIVATE_KEY(or a wallet connector) and pre-funds it with USDC.simple, works now
best for builders
Custodial / hosted wallet (most mainstream): the app generates a wallet for the user and stores the key server-side (or in an HSM).
the agent never touches keys
user pays with Stripe / card → we top up their USDC balance behind the scenes
best UX, but adds legal/ops complexity
Delegated spender / allowance model: user keeps their own wallet, but grants allowance to a payer service.
payer service signs x402 payments up to limits
better than full custody, but still more complex than (1)
For MVP, we should assume (1). For real distribution, we probably evolve toward (2) or (3).
This server cannot be deployed
Maintenance
Related MCP Connectors
Find paid APIs, check access policy and price, and route x402 requests. No autonomous spending.
Pay for APIs with USDC. Read-only x402 payment discovery, verification, evidence, and status.
Discover machine-payable APIs, probe x402 payment terms, and run seller operations. Non-custodial.
Pay for HTTP APIs and charge for your own: x402 micropayments in USDC on Base.
Related MCP Servers
- AlicenseAqualityBmaintenanceL402 + x402 client MCP. AI agents discover, pay for, and consume any payment-gated API autonomously. Supports Lightning (NWC), Cashu ecash, stablecoins, and human-in-the-loop payments.11159 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to pay for protected HTTP resources using Stellar USDC via the x402 protocol, facilitating automated payments and access to paid APIs.MIT
- AlicenseNot gradedqualityDmaintenanceEnables testing webhook endpoints by sending HTTP requests with custom headers, method, and body, measuring latency and TLS info, with pay-per-call via x402 micropayments.MIT
- AlicenseAqualityDmaintenanceEnables AI agents to discover and pay for x402-gated HTTP APIs, handling 402 Payment Required flows with local signing. Supports EVM and Solana with non-custodial wallet management.263 npmMIT