x402ai-mcp
It lets AI clients call paid x402ai text endpoints with per-call USDC payments on Base, and inspect x402 endpoints for free.
embed: compute a 768-dimension text embedding for $0.01 per call.summarize: summarize input text for $0.02 per call.ask: get a short 2–3 sentence answer for $0.04 per call.health: check x402ai service status and local session spend/cap for free.inspect: probe an HTTPS URL free of charge, decode its 402 challenge, and validate/merchant-check it via Coinbase CDP.Paid tools take one
inputstring of 1–3,000 characters.Supports dry-run mode to quote prices without signing or spending.
Enforces per-payment and per-session spending safeguards using a configured buyer key and session cap.
Integrates with Coinbase's CDP services for x402 endpoint inspection, running Coinbase's x402 validator and a Bazaar merchant lookup when inspecting a URL's 402 payment challenge.
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., "@x402ai-mcp summarize this: x402 lets AI clients pay per API call in USDC."
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.
x402ai-mcp
A local MCP server that lets AI clients (Claude Desktop, Claude Code, Cursor and others) call the paid x402ai endpoints, paying per call in USDC on Base through the x402 protocol, plus a free inspector for any x402 endpoint.
It runs on your machine over stdio. You give it a buyer key; it answers each HTTP 402 payment challenge by signing a USDC authorization, and returns the result. Nothing is hosted for you and no account is needed.
Tools
Tool | Cost | What it does |
| $0.01 | 768-dimension text embedding (nomic-embed-text) |
| $0.02 | Summary of the input text (small local LLM) |
| $0.04 | Short answer, 2-3 sentences; no web access, no memory, can be wrong |
| free | x402ai service status, plus this session's spend and remaining cap |
| free | Takes a URL: decodes its 402 challenge, runs Coinbase's x402 validator and a Bazaar merchant lookup |
Paid tools take one input string of up to 3,000 characters. health and inspect need no key.
Related MCP server: PipRail
Before you start: use a dedicated wallet
This server holds a private key that can spend money. Use a new wallet that exists only for this, funded with a few dollars of USDC on Base at most. Payments are gasless for the payer (EIP-3009), so the wallet needs USDC only, no ETH. Never use a wallet that holds anything you can't afford to lose. The wallet balance is your real spending limit.
Can you trust this package?
This server asks for a key that can spend money, and fake "x402 MCP" packages that steal keys have been reported. Don't take this README's word for it: the claims below are meant to be checked.
The package never sends or logs your key. It is read once from
X402AI_BUYER_PRIVATE_KEYand used only to sign payment authorizations locally, and it is scrubbed from error messages. It stays in this process's environment and memory while the server runs, so anything that can read those (other code in this process, other programs running as your user, your client's config file) can read the key. Clearing the variable inside the process would not change that, because Linux keeps a process's starting environment readable under /proc.Every host it contacts. No request follows a redirect; a redirect is refused and the call fails.
https://api.x402ai.dev: the paid tools andhealth. Signed authorizations go only here, only for the calling tool's own route and price, and expire within 300 seconds.https://api.cdp.coinbase.com: only when you runinspect(Coinbase's validator and merchant lookup).The URL you pass to
inspect: one unpaid request (with a fixed body for POST). Nothing is signed.
No telemetry, analytics or update checks.
Small and readable. Five source files in
src/(about 660 lines), built withtscintodist/. The published package contains onlydist/, this README,LICENSEandpackage.json.Pinned dependencies. Direct dependencies are pinned to exact versions. npm resolves their dependencies fresh, within the ranges they declare, when you install, so those aren't frozen; the repository's
package-lock.jsonrecords the exact set that was tested. No dependency runs an install script. All dependencies have verified npm registry signatures (npm audit signatures). The x402 client is@x402/fetch2.29.0, with a per-payment cap set in code.The spend safeguards stop honest code from overspending; they do nothing against a malicious package. That is why the points above are checkable.
How to check: compare the published files with the source (npm pack x402ai-mcp@<version> downloads the exact
tarball for inspection), confirm the package name is exactly x402ai-mcp, and read src/.
Don't run unvetted MCP servers in the same client as a funded key. Any other program running as your user, including another MCP server, can typically read this process's environment and your client's config file, which holds the key in plain text.
Install
Requires Node.js 20 or later. Add it to your MCP client's configuration, for example:
{
"mcpServers": {
"x402ai": {
"command": "npx",
"args": ["-y", "x402ai-mcp"],
"env": {
"X402AI_BUYER_PRIVATE_KEY": "0x...",
"X402AI_MAX_SESSION_USD": "0.25"
}
}
}
}Note that most clients store this file in plain text, so the key sits on disk unencrypted. That is one more reason to use a dedicated low-balance wallet.
To try it without a key or any spending, set X402AI_DRY_RUN=1: paid tools then return the price quote they would
pay, and never sign anything.
Configuration
Variable | Default | Meaning |
| none | Buyer key (hex). Needed only for paid tools. Never logged; scrubbed from error messages. |
|
| Total the server may spend per process. An invalid value stops it at startup. |
| off |
|
The server logs to stderr only (stdout carries the MCP protocol). At startup it prints whether a key is configured, the buyer address and the session cap.
Spending safeguards
Per payment: before signing, each paid tool checks that the challenge is for Base mainnet, USDC, x402ai's payment address, and that tool's own route, at or below that route's price. Anything else is refused. A per-payment maximum of $0.04 is enforced as a second check.
Short-lived authorizations. A challenge that asks for an authorization valid longer than 300 seconds is refused before signing, so a leaked authorization cannot stay usable for long.
Per session: each payment attempt is reserved against
X402AI_MAX_SESSION_USDbefore signing. Once the cap is reached, paid tools refuse until the server restarts.The session cap is per process. It is counted in memory, resets when the server restarts, and each running copy of the server gets its own cap, even with the same wallet. The wallet balance is the only hard limit: fund it with only what you are willing to lose.
The cap has no upper limit. A typo such as
250means $250. The wallet balance is the backstop that always holds.
Things to know
A failed call can still count. If the server returns an error after the payment was signed, the reservation is kept, because a signed authorization can still settle. You are not charged when x402ai's handler fails, but the session cap treats the attempt as spent.
inspectsends the URL you give it to Coinbase's CDP (validator and merchant lookup). Don't inspect URLs you want to keep private.inspectrefuses local and private addresses (loopback, private ranges, link-local, CGNAT, IPv6 ULA, and IPv4 addresses wrapped in IPv6 forms), checked after DNS resolution. It allows https only. The request to the inspected URL checks the resolved addresses at connect time, in the same lookup the socket uses, so a DNS answer that changes after the early check cannot reach a local or private address. It follows no redirects and verifies the TLS hostname. This covers the request to the inspected URL;inspect's calls to Coinbase go to a fixed host.Treat tool output as untrusted data. Answers and summaries come from a small model and may be wrong; responses from inspected endpoints are third-party content. Don't let them act as instructions to your agent.
Latency:
embedis usually under a second;summarizeandasktake about 5-15 seconds (CPU inference).Claude Code may load tool schemas late. Claude Code defers MCP tool schemas by default, so the first call to a tool can go out with wrong or empty arguments. Starting Claude Code with
ENABLE_TOOL_SEARCH=falseloads them up front.
License
MIT. Not affiliated with Coinbase or the x402 Foundation.
Available Tools
5 toolsaskx402ai askA
Ask a question and get an answer. Costs $0.04 (USDC on Base) per call; takes 5-16 s. Spends real money; subject to a per-payment and per-session cap. Pass the question in input (max 3000 chars).
Inputs: input (required).
embedx402ai embedA
Compute a text embedding vector. Costs $0.01 (USDC on Base) per call. Spends real money; subject to a per-payment and per-session cap. Pass the text in input (max 3000 chars).
Inputs: input (required).
healthx402ai healthARead-only
Free. Check GET /health on api.x402ai.dev and show local session spend. No key needed.
Inputs: no named parameters.
inspectx402 inspectARead-only
Free, never signs or pays. Fetch an https URL unpaid, decode its x402 payment-required header, and check it with Coinbase CDP validate and merchant discovery. Sends the URL to api.cdp.coinbase.com.
Inputs: url (required), method.
summarizex402ai summarizeA
Summarize text. Costs $0.02 (USDC on Base) per call; takes 5-16 s. Spends real money; subject to a per-payment and per-session cap. Pass the text in input (max 3000 chars).
Inputs: input (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: embed computes vectors, summarize condenses text, ask answers questions, health checks service/session spend, and inspect handles unpaid x402 URL diagnostics. Health and inspect are both free diagnostics, but their descriptions make the boundary clear.
The tool names are short lowercase single words with mostly action verbs (embed, summarize, ask, inspect), and only health is a noun. This is a minor deviation from a strict verb pattern but remains highly readable and predictable.
Five tools is well-scoped for a small paid AI API surface: three paid operations plus two diagnostic utilities. Each tool earns its place without an excessive surface.
The surface covers the core paid AI operations and includes health/session-spend and x402 inspection utilities. A minor gap is the absence of a dedicated pricing, balance, or payment-status tool beyond local session spend in health.
Maintenance
Related MCP Connectors
Pay-per-call AI and media tools over x402. USDC on Base, no signup, no API key.
Pay-per-call AI gateway: models, speech, web search, on-chain reads and NLP tools, via x402.
Pay-per-call onchain reads (Base, Ethereum, Gnosis), token verdicts and LLM chat over x402 USDC
Pay-per-call onchain reads (Base, Ethereum, Gnosis), token verdicts and LLM chat over x402 USDC
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceLocal stdio MCP server for x402-powered paid crypto intelligence, decision verification, and agent automation search over USDC micropayments on Base.707 npmMIT
- AlicenseAqualityAmaintenanceA budget-bound x402 payment wallet for AI agents: it autonomously pays HTTP 402 payment-gated URLs across every major chain (EVM, Solana, and many non-EVM families). Self-custodial and backendless, your key, your RPC, with spend caps enforced before any on-chain send.810MIT

token4u-mcpofficial
AlicenseAqualityCmaintenanceEnables AI agents to call LLM APIs via x402 micropayments in USDC on Base network, manage a local wallet, and query consumption records.353 npmMIT- AlicenseAqualityCmaintenanceEnables AI assistants to call pay-per-call x402 endpoints on Base mainnet using the caller's own USDC wallet, covering single and batch token risk checks, the latest BTC radar signal, project info, and a free health probe. Payments are EIP-3009 signed with a configurable per-call spending cap, and any quote with an unexpected payee, network, or asset is refused before payment.5MIT