About X402 MCP
X402 MCP is an MCP server published by ethanniser in the Developer Tools category: x402 USDC micropayments MCP + A2A storefront on Base — city compliance, agent discovery, payTo funding.
The repository has 22 stars and 15 forks, with the last commit 10 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/ethanniser/x402-mcpThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about X402 MCP
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- ✓License declaredUsable under a stated license.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- ✓Dependencies pinnedA lockfile pins dependency versions.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
x402 + MCP + AI SDK
Check out apps/example for a working example!
// server
import { createPaidMcpHandler } from "x402-mcp";
import z from "zod";
const handler = createPaidMcpHandler(
(server) => {
server.paidTool(
"get_random_number",
"Get a random number between two numbers",
{ price: 0.001 },
{
min: z.number().int(),
max: z.number().int(),
},
{},
async (args) => {
const randomNumber =
Math.floor(Math.random() * (args.max - args.min + 1)) + args.min;
return {
content: [{ type: "text", text: randomNumber.toString() }],
};
}
);
},
{
recipient: process.env.WALLET_ADDRESS,
}
);
export { handler as GET, handler as POST };
// client
import { convertToModelMessages, stepCountIs, streamText, UIMessage } from "ai";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { experimental_createMCPClient as createMCPClient } from "ai";
import { withPayment } from "x402-mcp";
const mcpClient = await createMCPClient({
transport: new StreamableHTTPClientTransport(url),
}).then((client) => withPayment(client, { account: process.env.PRIVATE_KEY }));
const tools = await mcpClient.tools();
const result = streamText({
model,
tools,
messages: convertToModelMessages(messages),
stopWhen: stepCountIs(5),
onFinish: async () => {
await mcpClient.close();
},
system: "ALWAYS prompt the user to confirm before authorizing payments",
});
README fetched from the repository 5 days ago. The original is authoritative.