Skip to main content

Introducing x402-mcp: Open protocol payments for MCP tools

By Steven Van ·

Vercel's x402-mcp lets MCP tools and API routes charge AI agents per call over HTTP, with a one-click Next.js starter template.

Vercel has published x402-mcp, a package that adds payment support to Model Context Protocol servers using the x402 open protocol. x402 adds payment directly into HTTP requests via the standard 402 Payment Required status code, letting an API endpoint request payment without prior account setup, key exchange, or a separate billing relationship.

  • For APIs, routes are protected with a paymentMiddleware from the x402-next package, which declares a price per route; clients call the API with a wrapFetchWithPayment fetch wrapper from x402-fetch.
  • For MCP servers, x402-mcp wraps the existing mcp-handler package and adds a paidTool method for defining a price per tool call; clients add payments with a single withPayment wrapper around an MCP client built with the AI SDK.
  • Most current implementations settle as one-time payments in USDC on the Base blockchain, though Vercel says the protocol itself is payment-network agnostic and can support other currencies and schemes, including non-crypto payments.

Vercel also released an x402 AI Starter template built on Next.js, the AI SDK, AI Elements, and AI Gateway. It includes an API route protected by paymentMiddleware, an MCP server with a paidTool, an MCP client extended with withPayment, a page that charges crawlers using x402, server-managed wallets through Coinbase's developer platform, and a frontend chat and API playground. The template deploys to Vercel with one click. The x402-mcp package is available via npm install x402-mcp; read the full announcement for the starter template link.

Vercel
Vercel
The platform for frontend developers — deploy, preview, and scale web apps and AI agents with zero config.
View Vercel →

Original source

Read Introducing x402-mcp: Open protocol payments for MCP tools on Creators Toolbox