Multi-provider AI router with x402 micropayment settlement on Base L2. 1% flat fee.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
AI payment router. Route across 300+ models, settle per request in USDC on Base or USDC.e on Tempo.
P402 sits between your AI application and every LLM provider. It handles intelligent multi-provider routing (cost / quality / speed / balanced), on-chain micropayment settlement via the x402 protocol and mppx on Base and Tempo, and spending guardrails for autonomous agents.
| Problem | P402 Solution |
|---|---|
| Hardcoded to one AI provider | Route across 300+ models automatically |
| $0.30 payment fees kill micropayments | USDC on Base: fractions of a cent per settlement |
| No spending limits for AI agents | Session budgets + AP2 mandate governance |
| Fragmented provider APIs | One OpenAI-compatible endpoint |
| No visibility into AI costs | Real-time analytics + optimization suggestions |
Install the extension β the MCP server is embedded, tools appear in Copilot agent mode immediately, no config files required:
Then run P402: Configure API Key from the command palette.
β VS Code Marketplace Β· Open VSX
β MCP docs Β· MCP Registry
| Mode | Optimizes For | Typical Provider |
|---|---|---|
cost | Lowest price | DeepSeek V3, Haiku 4.5, GPT-4o-mini |
quality | Best output | Claude Opus 4.6, GPT-5, Gemini 3 Pro |
speed | Lowest latency | Groq LPU, Flash models |
balanced | Equal weight (default) | Sonnet 4.6, GPT-4o, Gemini Flash |
Enforce hard spending caps for autonomous agents:
x402 is a machine-native payment protocol using HTTP 402. AI agents pay for resources using gasless EIP-3009 USDC transfers on Base L2.
Network: Base Mainnet (Chain ID: 8453) Β· Asset: USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
P402 implements the Google A2A spec over JSON-RPC 2.0. Agents communicate through structured tasks, discover capabilities via /.well-known/agent.json, and settle payments via the x402 extension.
| Package | Description | Version |
|---|---|---|
@p402/sdk | TypeScript SDK β P402Client, types, EIP-712 mandate helpers | |
@p402/cli | CLI tool β login, chat, sessions, mandates, analytics | |
@p402/mcp-server | stdio MCP server β 6 tools over Model Context Protocol | |
@p402/mpp-method | mppx payment methods β Base EIP-3009 and Tempo TIP-20 multi-rail settlement | |
p402 VS Code extension | Embedded MCP server for VS Code, Cursor, and Windsurf β zero config |
| Example | What It Shows |
|---|---|
| 01-quickstart | Login β chat β view spend in ~20 lines |
| 02-openai-migration | Drop-in OpenAI SDK replacement |
| 03-nextjs-session-budget | Budget-capped AI in a Next.js App Router project |
| 04-a2a-agents | Two agents communicating with x402 payment gate |
| Guide | |
|---|---|
| Getting Started | Account, API key, first request |
| Authentication | API keys, env vars, security |
| Routing Guide | Modes, scoring, providers, models |
| x402 Payments | EIP-3009, wire format, settlement |
| Sessions | Session lifecycle + budget enforcement |
| A2A Protocol | JSON-RPC, mandates, Bazaar |
| CLI Reference | Full CLI command reference |
| OpenAPI Spec | Machine-readable API schema |
MIT Β© P402 Protocol
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/p402)<a href="https://allmcps.com/mcp/p402"><img src="https://allmcps.com/api/badge/p402?style=directory" alt="P402 on AllMCPs" /></a>