agent-x402
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-x402what's my USDC balance, and what would a call to api.venice.ai cost?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agent-x402
x402 micropayments for AI agents — pay per API call in USDC on Base. No account, no API key, no subscription. With a spend policy a prompt injection cannot talk its way past.
Docs · Contributing · Security · Issues · Discussions
The problem
x402 turns a 402 Payment Required into a signed USDC transfer. That means an agent can buy inference, data and compute without an account — but it also means an agent can spend money. A model that can sign payments is one prompt injection away from draining a wallet.
agent-x402 is the missing layer: a client that pays, and a policy that decides whether it may.
Related MCP server: token4u-mcp
Install
# tarball из релиза: без токена и без npm-логина
npm i -g https://github.com/rustemmustafingovua-byte/agent-x402/releases/download/v0.1.0/agent-x402-0.1.0.tgznpm i -g @rustemmustafingovua-byte/agent-x402 --registry=https://npm.pkg.github.comimport { X402Client, SpendPolicy, createAgentWallet } from "agent-x402"
const wallet = createAgentWallet() // or load an existing key
const policy = new SpendPolicy({
dailyUsd: 5,
perRequestUsd: 0.5,
allowPayees: ["0x2670b922ef37c7df47158725c0cc407b5382293f"],
})
const client = new X402Client({ privateKey: wallet.privateKey, policy })
const res = await client.fetch("https://api.venice.ai/api/v1/chat/completions", {
method: "POST",
body: { model: "claude-haiku-5-5", messages: [{ role: "user", content: "hi" }] },
})
console.log(res.paid, res.amountUsd, res.body)What the policy enforces
Rules live in code, outside the model:
Rule | Example |
daily cap |
|
per-request cap |
|
payment count |
|
allow-list | only these contract addresses may be paid |
block-list | these assets are never paid (sandbox tokens, honeypots) |
per-network cap |
|
policy.check() runs before signing; policy.commit() records what was actually spent. The day counter resets on the UTC day boundary.
How the payment flows
sequenceDiagram
participant A as Agent
participant S as Service (402)
participant W as Wallet (USDC, Base)
A->>S: GET /v1/chat/completions
S-->>A: 402 + payment-required (accepts, 5 USDC)
A->>A: policy.check() — caps, allow-list
A->>W: balanceOf(address)
W-->>A: 12.40 USDC
A->>A: sign EIP-3009 transferWithAuthorization
A->>S: retry + SIGN-IN-WITH-X
S-->>A: 200 answer
A->>A: policy.commit() — record the spendUnder the hood
GET/POSTthe endpoint →402with apayment-requiredheader (base64 JSON)pick an accepted option (
eip155:8453preferred, Solana supported)policy.check()→ refuse if it breaks the rulescheck the USDC balance on Base
sign an EIP-3009
transferWithAuthorization(USDC,exactscheme, 15-minute window)retry with the signed payment in
SIGN-IN-WITH-X/X-PAYMENT/PAYMENT-SIGNATURE
Services that accept x402 today
Service | What | Price |
| Claude Haiku 5.5 / Sonnet 5.5 / Opus 5.5 | from $0.10 / 1M in |
| open-weight models on their own GPUs, no key | from $0.001 / call |
MCP server — wallet operations as tools
The private key stays inside the process; the policy is enforced before the client signs anything.
// opencode.json
{
"mcp": {
"agent-x402": { "type": "local", "command": ["ax402-mcp"], "enabled": true }
}
}Tool | What it does |
| address + USDC balance (never the key) |
| what would this call cost — pays nothing |
| call + pay, policy enforced before signing |
| show or update caps, allow-list, blocked contracts |
CLI
ax402 new # create an agent wallet
ax402 balance # USDC balance on Base
ax402 pay <url> [json] # call any x402 endpoint, paying automatically
ax402 quote <url> # show what a call would cost, pay nothing
ax402 policy # show the current spend reportPart of a portfolio
Project | What it does |
route to free models, fall back automatically | |
web search and page reading for agents, zero credits | |
pay per API call in USDC with a spend policy | |
check that MCP servers work, and say why they do not | |
one endpoint, many MCP servers, with keys and limits | |
lint MCP tool schemas before agents misuse them | |
what does your system prompt cost per request? | |
a budget in front of any OpenAI-compatible endpoint | |
audit an OpenCode install in one command | |
know your free quota before it runs out | |
the price list of x402 endpoints, without paying | |
find instructions hidden in files the agent reads itself | |
why nobody uses your repository — checked in one command |
Donate
MIT, forever. USDC on Base:
0x8aC6a229f254980CCd3Dd35CF5E1B7c08880B40ERoadmap
x402 v2 "exact" scheme on Base (EIP-3009)
spend policy: caps, allow-list, block-list, per-network
CLI and tests
MCP server exposing wallet and policy operations
policy file (
~/.config/agent-x402/policy.json)Solana USDC (SPL) signing
spend report exporter (CSV/JSON) for accounting
hosted relay with a take rate
License
MIT © rustemmustafingovua-byte
This server cannot be deployed
Maintenance
Related MCP Connectors
Pay-per-call agent tools over x402 (USDC on Base) — no signup or API key.
Let an AI agent find and pay for x402 APIs and products in USDC on Base, within owner-set limits.
Pay-per-call tools for autonomous agents, settled in USDC on Base via x402.
Give your AI agent an x402 wallet: discover and pay for services in USDC, or earn from your own.
Related MCP Servers
AlicenseAqualityAmaintenanceEnables AI agents to call paid APIs and settle HTTP 402 payment challenges with USDC on Base, without private keys ever being involved.7129 npmMIT
token4u-mcpofficial
AlicenseAqualityBmaintenanceEnables AI agents to call LLM APIs via x402 micropayments in USDC on Base network, manage a local wallet, and query consumption records.343 npmMIT
@bridgenode/mcpofficial
AlicenseAqualityCmaintenanceEnables AI agents to make pay-as-you-go AI inference requests through x402 with automatic Solana USDC payments, no API keys or registration, while enforcing configurable spending limits.3466 npm1MIT No Attribution- FlicenseNot gradedqualityBmaintenanceEnables AI agents to pay per tool call in USDC via the x402 micropayment protocol, with no API keys or subscriptions required.-