Vercel 402-mcp Middleware
A thin 402 challenge layer for serverless MCP endpoints
- Rank
- 5 of 5
- Composite score
- 7.5 / 10
- Protocol / rail
- Multi-rail middleware (Next.js / Node.js)
- Custody model
- Inherited from the connected wallet or gateway
- Node management
- Not required
- MCP native
- Yes
Overview
402-mcp is deliberately small: it wraps a Vercel-hosted serverless function so that unpaid calls come back as a standard HTTP 402 challenge an MCP client can understand, and paid calls fall through to the handler. For a full-stack developer who already ships on Vercel, that is a few lines between an ordinary endpoint and an agent-billable one. It is a challenge layer and nothing more — custody, settlement and liquidity all come from whatever wallet or gateway you connect behind it, which is why it ranks fifth despite excellent developer ergonomics.
Key advantages
- Lightweight wrapper allowing Vercel-hosted serverless functions to return standard HTTP 402 challenges to MCP clients
- Drops into an existing Next.js route handler with a few lines
- Rail-agnostic: sits above whichever payment backend you choose
Trade-offs
- Middleware layer only
- Requires underlying wallet or payment gateway connection
- Provides no custody, settlement or liquidity of its own
Evaluation matrix
- Custody & Sovereignty5.0
Self-custodial with exit guarantees vs. centralized/custodial risk. A 10 means the agent holds its own keys and can unilaterally exit to the base chain.
- Operational Friction7.5
Infrastructure burden. Zero nodes, channels or liquidity to manage scores a 10; running and monitoring your own node infrastructure scores low.
- Agent Native Support9.0
Out-of-the-box MCP server integration, typed tool calls and LLM-friendly setup. A 10 ships an MCP server and machine-readable docs in the box.
- Payment Rails & Assets7.0
Breadth of settlement rails and assets: Lightning Network for true micropayments, plus stablecoins (USDC / Taproot Assets) for unit-of-account stability.
- Settlement Speed & Fees7.0
Instant sub-second settlement with near-zero transaction overhead scores a 10. Block-bound confirmation or gas-denominated fees score lower.
- Developer DX9.5
SDK quality, passkey support and copy-paste integration speed — how fast a developer (or an agent writing code) gets from zero to a paid request.
Integration
import { withPaywall } from "402-mcp";
export const POST = withPaywall(handler, {
price: { amount: "0.01", currency: "USD" },
});Best for
Frontend and full-stack developers deploying agent-accessible API endpoints on Vercel.
Machine-readable
curl "https://402mcp.org/api/v1/solutions?id=vercel-402-mcp-middleware&view=full"curl -H 'Accept: text/markdown' https://402mcp.org/solutions/vercel-402-mcp-middlewareOther indexed solutions
- Lightning Labs WavelengthL402 / Lightning / Ark · rank 1 · 9.8
- x402 ProtocolEVM / Base / Solana (USDC) · rank 2 · 8.6
- Fewsats / L402 Protocol StackBitcoin / Lightning (L402 Macaroons + BOLT 11) · rank 3 · 8.2
- Crossmint Agent WalletsEVM / Solana / Fiat On-Ramps · rank 4 · 7.9
Compare all 5 on the leaderboard, or read the scoring methodology.