Integrating x402 with MCP (Model Context Protocol)
How to expose pay per call tools and datasets to Claude, Cursor, and autonomous MCP compatible agents.
Pay per call MCP tools
Model Context Protocol standardizes how language models invoke external tools. Combining HTTP MCP servers with x402 middleware lets each tool call require payment authorization.
Security best practices
Always enforce per call caps on the agent client, verify signatures server side before running tool logic, and publish capabilities in your MCP Server Card.
server.tool("premium_lookup", schema, async (args, ctx) => {
await verifyX402Payment(ctx.headers, { priceUsdc: "0.02" });
return await fetchDataset(args.query);
});