x402-mcp
Summary: Gives any AI agent a self-custodial Solana x402 wallet to discover, price-check, and pay paid HTTP/MCP services in USDC (or $THREE) without a custodial intermediary.
x402_wallet(read-only) — Show a Solana wallet's address and live SOL/USDC balance; defaults to the signer wallet so you can confirm funds before paying.find_services(read-only) — Search the live x402 bazaar (PayAI + Coinbase CDP) for paid HTTP APIs and MCP tools by query, type, network, price cap, and limit.inspect_endpoint(read-only) — Read any endpoint's 402 payment requirements (scheme, network, asset, price, pay-to) without paying, or get its result if it's free.pay_and_call(execution, destructive) — Pay an x402 endpoint in USDC or $THREE and return its result, either self-custodially with your own key or via a three.ws Payment Session token where the platform wallet pays within session budget/allowlist/cap.Safety bounds — Probes the 402 before spending, refuses if the price exceeds
max_usd/MAX_PAY_USD(default $1), requiresconfirm: truewhenREQUIRE_CONFIRMis on, and supportsidempotency_keyto prevent double-charges on retries.No key needed for reads —
find_servicesandinspect_endpointwork with noSOLANA_SECRET_KEY; a key is only required to spend.
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., "@x402-mcp search for affordable text-to-speech APIs"
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.
A Model Context Protocol server that turns any AI assistant into an autonomous economic agent on the x402 network. Search the live bazaar for paid services, read an endpoint's price before committing money, and
pay_and_callany x402 service in USDC — settled on Solana with your own key, never a custodial wallet.
This is the buyer side of the three.ws agent economy. The payment dance and Solana exact-scheme signing are handled by the real @x402/* libraries — nothing is mocked.
Install
npm install @three-ws/x402-mcpOr run with npx:
SOLANA_SECRET_KEY=<base58> npx @three-ws/x402-mcpRelated MCP server: BotWallet MCP Server
Quick start
Claude Code, one line:
claude mcp add x402 --env SOLANA_SECRET_KEY=<base58> -- npx -y @three-ws/x402-mcpClaude Desktop / Cursor (claude_desktop_config.json or mcp.json):
{
"mcpServers": {
"x402": {
"command": "npx",
"args": ["-y", "@three-ws/x402-mcp"],
"env": {
"SOLANA_SECRET_KEY": "<base58 secret of the wallet that holds USDC>",
"SOLANA_RPC_URL": "https://your-rpc-provider",
"MAX_PAY_USD": "1"
}
}
}
}SOLANA_SECRET_KEY is only needed to spend (pay_and_call, and x402_wallet defaulting to your wallet). find_services and inspect_endpoint work with no key.
Tools
Tool | Type | What it does |
| read-only | A wallet's address + live SOL/USDC balance. Defaults to your signer wallet — confirm funds before paying. |
| read-only | Search the live x402 bazaar (PayAI + Coinbase CDP) for paid HTTP/MCP services with prices. |
| read-only | Read any endpoint's 402 payment requirements (scheme, network, asset, price, pay-to) without paying. |
| execution | Pay an x402 endpoint in USDC from your Solana key and return its result. Bounded by |
Safety
pay_and_call carries destructiveHint: true, so annotation-aware clients (Claude Code, Claude Desktop, Cursor) prompt before running it. Beyond the client hint, every payment is bounded server-side: it probes the 402 first and refuses if the price exceeds max_usd or MAX_PAY_USD (default $1) before any money moves, and with REQUIRE_CONFIRM on (default) the call refuses until re-issued with confirm: true. Only the Solana (solana:*) exact-scheme requirement is settled — with the key you control.
Input parameters
x402_wallet — address (optional base58; defaults to the signer wallet).
find_services — query (required), type (http | mcp, default http), network (CAIP-2 filter), max_price_usdc, limit (1–100).
inspect_endpoint — url (required), method (GET | POST), body (object).
pay_and_call: url (required), method (GET | POST), body (object), max_usd (lowers the cap for this call), secret (per-call signer override), confirm (must be true when REQUIRE_CONFIRM is on), session_token, token, idempotency_key.
It has two settlement modes:
Self-custodial (default). Signs with
SOLANA_SECRET_KEY, or the per-callsecret. You hold the key.Session-governed. Pass
session_token, a three.ws Payment Session token, and the platform wallet signs on your behalf while enforcing that session's budget, host allowlist, and per-transaction cap. No private key needed. Solana USDC and Base USDC sessions are both supported, andsecretandtokenare ignored in this mode.
token selects the settlement asset: usdc (default), or three for the $THREE platform token when the endpoint advertises it. idempotency_key deduplicates a call, which is recommended with session_token so a retry cannot double-charge.
Example
// inspect_endpoint — what does it cost? (no payment)
> { "url": "https://three.ws/api/x402/vanity?prefix=ab" }
{
"ok": true, "paid": true,
"accepts": [
{ "scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "asset": "EPjFW…", "price": 50000 }
],
"payable_with_this_wallet": true
}
// pay_and_call — confirm:true required by default
> { "url": "https://three.ws/api/x402/vanity?prefix=ab", "confirm": true }
{ "ok": true, "paid": true, "payer": "Gx5E…", "price_usd": 0.05, "settlement": { … }, "result": { … } }Examples
Runnable, no-payment examples live in examples/:
node examples/list-tools.mjs # every tool with its full input schema
node examples/inspect-price.mjs # find_services + inspect_endpoint on live dataBoth spawn this server over stdio and hit the real bazaar. Neither reads a key or
calls pay_and_call, so nothing is signed and nothing is spent. See
examples/README.md for expected output.
Requirements
Node.js >= 20.
A Solana mainnet RPC endpoint (
https; onlyhttp://localhostis allowed for dev). Public cluster works for reads; bring your own for payment traffic.To pay: a Solana wallet holding USDC, as a base58
SOLANA_SECRET_KEY(or per-callsecret).
Environment variables
Variable | Required | Default |
| to pay only | — |
| no |
|
| no |
|
| no |
|
| no |
|
Links
Homepage: https://three.ws
MCP catalog: https://three.ws/docs/mcp
Changelog: https://three.ws/changelog
License: Apache-2.0, see LICENSE
Support the project
If x402-payments-mcp saves you time, star it on GitHub. Stars are how other developers and AI agents find the repositories worth trusting, and they cost you one click.
Know someone who would use it? Post on X · Share on Bluesky · Share on LinkedIn · Submit to Hacker News · Share on Reddit
Built for AI agents too
Coding agents and LLM tooling can read this repo directly: AGENTS.md, llms.txt, llms-full.txt. Point an agent at https://github.com/nirholas/x402-payments-mcp and it has the context it needs.
More from the same author
All repositories by nirholas: the full catalog, grouped by topic
three.ws: the platform for 3D AI agents with Solana wallets, a skill marketplace and x402 payments
Questions or ideas: open an issue or start a discussion
Contributors
Star history
Part of three.ws
three.ws is a platform for 3D AI agents with Solana wallets: avatars, a skill marketplace, x402 payments and more than seventy MCP servers. @three-ws/x402-mcp is one package from it.
Documentation site: https://nirholas.github.io/x402-payments-mcp/
Canonical source: https://github.com/nirholas/three.ws (this repository is a generated mirror of
packages/x402-mcp)Issues and ideas: https://github.com/nirholas/x402-payments-mcp/issues
Available Tools
4 toolsfind_servicesFind paid x402 services the agent can callARead-only
Search the live x402 facilitator network (PayAI + Coinbase CDP bazaar) for paid services (HTTP APIs and MCP tools). Returns each match with its price, networks, and resource URL. Use this when a task needs a paid API or tool you do not already have; to use a match, check its price with inspect_endpoint, then pass its resource into pay_and_call. Read-only.
Inputs: query (required), type, limit, network, +1 more.
inspect_endpointInspect an x402 endpoint (price + requirements, no payment)ARead-only
Fetch an x402 endpoint and return its 402 payment requirements — every accepted scheme, network, asset, price and pay-to address — WITHOUT paying. If the endpoint is free, returns its result instead. No signer required. Use this to learn the cost before pay_and_call.
Inputs: url (required), body, method.
pay_and_callPay an x402 endpoint in USDC or $THREE and return its resultADestructive
Call a paid x402 endpoint and settle the payment automatically, then return the result. Use this after inspect_endpoint has shown the price and the user has approved paying it; a settled payment cannot be undone.
Two modes:
• Self-custodial (default): signs with SOLANA_SECRET_KEY or secret arg; you hold the key.
• Session-governed: pass session_token (a three.ws Payment Session token); the platform wallet signs on your behalf; the session's budget, allowlist, and per-tx cap are enforced by the platform. No private key required. Supports Solana USDC and Base USDC sessions.
Pay in USDC (default) or, when the endpoint advertises it, in $THREE (set token:"three"). Bounded by max_usd and the MAX_PAY_USD cap; refuses before any money moves if the price is over the cap. With REQUIRE_CONFIRM on, the call refuses until re-issued with confirm:true.
Inputs: url (required), body, token, method, +5 more.
x402_walletThe agent's x402 spending wallet (address + balance)ARead-only
Show a Solana wallet's address and live SOL + USDC balance. With no address, derives the wallet from the configured signer (SOLANA_SECRET_KEY). Call this before pay_and_call to confirm there's USDC to spend. Read-only; never moves funds.
Inputs: address.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool occupies a distinct step in a linear workflow: x402_wallet checks balance, find_services discovers services, inspect_endpoint returns 402 requirements without paying, and pay_and_call settles. Descriptions explicitly cross-reference each other (check price with inspect_endpoint, then pass resource into pay_and_call), so boundaries are clear.
Three tools follow a consistent snake_case verb_noun pattern (find_services, inspect_endpoint, pay_and_call), with x402_wallet as a noun-only exception tied to the protocol. Minor deviation, but still predictable and readable.
Four tools is a well-scoped, minimal set for a payment agent: wallet check, discovery, price inspection, and payment execution. Each tool has a clear role with no redundancy.
The discover→inspect→pay loop is covered, but there's no way to list past payments/settlements, fetch receipts, or check session budget/allowlist status. These are notable gaps for an agent handling money that could hinder auditability.
Maintenance
Related MCP Connectors
USDC wallets, payment links and x402 payments on Solana for AI agents.
MCP marketplace: AI agents buy services from other agents per call in USDC, plus a bank cash-out
AI service marketplace — agents discover, call, and pay for API services automatically.
Native Solana staking for AI agents. 26 MCP tools, one-shot signing, webhooks.
Related MCP Servers
FlicenseNot gradedqualityDmaintenanceEnables AI agents to discover and pay for monetized services such as PDF processing and DeFi operations using USDC on the Base blockchain. It provides automatic payment processing and secure local wallet management for seamless integration with MCP-compatible clients.16 npm-- AlicenseAqualityBmaintenanceEnables AI agents to manage USDC wallets on Solana, allowing them to send payments, create invoices, and access paid APIs within human-defined spending limits. It uses threshold signatures to provide agents with financial autonomy while ensuring secure oversight and transaction approval.3629 npm4Apache 2.0
- AlicenseAqualityDmaintenanceThe MCP gateway that lets any AI agent discover and pay metered APIs on Base or Solana — without the user wiring payments themselves.324 npm1Apache 2.0
- AlicenseAqualityDmaintenanceLets AI agents discover, pay for, and call any HTTP API per request using USDC, with gasless nanopayments and no API keys or accounts needed.552 npmMIT