Config is the same across clients — only the file and path differ.
{
"mcpServers": {
"p402": {
"env": {
"P402_API_KEY": "p402_live_..."
},
"args": [
"-y",
"@p402/mcp-server"
],
"command": "npx"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
AI payment router. Route across 300+ models, pay per request in USDC on Base.
Run this in your terminal to verify the server starts. Then let us know if it worked — your result helps other developers.
npx -y 'p402' 2>&1 | head -1 && echo "✓ Server started successfully"
After testing, let us know if it worked:
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
Checked p402 against OSV.dev.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in finance / ai-ml
Persistent memory using a knowledge graph
Workspace template + MCP server for Claude Code, Codex CLI, Cursor & Windsurf. Multi-agent knowledge engine (ag-refresh / ag-ask) that turns any codebase into a queryable AI assistant.
Privacy-first. MCP is the protocol for tool access. We're the virtualization layer for context.
An open-source AI agent that brings the power of Gemini directly into your terminal.
MCP Security Weekly
Get CVE alerts and security updates for P402 MCP Server and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
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:
ext install p402-protocol.p402
Then run P402: Configure API Key from the command palette.
→ VS Code Marketplace · Open VSX
{
"mcpServers": {
"p402": {
"command": "npx",
"args": ["-y", "@p402/mcp-server"],
"env": { "P402_API_KEY": "p402_live_..." }
}
}
}
→ MCP docs · MCP Registry
npm install @p402/sdk
import P402Client from '@p402/sdk';
const p402 = new P402Client({ apiKey: process.env.P402_API_KEY });
// Drop-in OpenAI replacement — P402 picks the best provider
const response = await p402.chat({
messages: [{ role: 'user', content: 'Explain x402 payments in one sentence.' }],
p402: { mode: 'cost' } // cost | quality | speed | balanced
});
console.log(response.choices[0].message.content);
// p402_metadata: { provider: 'deepseek', cost_usd: 0.00031, latency_ms: 412 }
# Authenticate once
npx p402 login
# Chat using the cheapest provider
npx p402 chat "What is x402?" --mode cost
# Check facilitator health
npx p402 health
| 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:
// Create a $10 session — agent cannot spend a cent more
const session = await p402.createSession({ budget_usd: 10 });
// All chat requests are deducted from the session
const response = await p402.chat({
... [View full README on GitHub](https://github.com/Z333Q/p402-protocol#readme)