x402 Wallet
io.github.nirholas/x402-mcp · 231 stars · JavaScript · Apache-2.0
MCP server Self-custodial x402 wallet for AI agents: pay any service in USDC or $THREE from your own key.
Install
The repo has no one-line install. Follow its README.
Published as
- npm
@three-ws/x402-mcpstdio
From the server's entry in the official MCP Registry.
Configuration
| Name | Set as | What it is |
|---|---|---|
SOLANA_SECRET_KEYOptional · Secret | Env var | Base58 (or JSON byte-array) Solana secret key that signs payments and holds the USDC. Not needed for the read tools (find_services, inspect_endpoint, or x402_wallet with an explicit address). Treat like cash. |
SOLANA_RPC_URLOptional | Env var | Solana mainnet RPC endpoint. Defaults to the public cluster — bring your own (Helius / Quicknode / Triton) for production traffic. |
MAX_PAY_USDOptional | Env var | Max USD a single pay_and_call may spend. Bounds a runaway or injected payment. |
REQUIRE_CONFIRMOptional | Env var | When on (default), pay_and_call refuses until re-issued with confirm:true. Set 0/false to disable the gate. |
THREE_WS_BASEOptional | Env var | Base URL of the three.ws API that serves /api/bazaar/search for find_services. Override only when self-hosting. |
Files
@three-ws/x402-mcp
Give any AI agent a self-custodial x402 wallet — discover, inspect, and pay any paid service in USDC from your own Solana key.
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-mcp
Or run with npx:
SOLANA_SECRET_KEY=<base58> npx @three-ws/x402-mcp
Quick start
Claude Code, one line:
claude mcp add x402 --env SOLANA_SECRET_KEY=<base58> -- npx -y @three-ws/x402-mcp
Claude 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 |
|---|---|---|
x402_wallet |
read-only | A wallet's address + live SOL/USDC balance. Defaults to your signer wallet — confirm funds before paying. |
find_services |
read-only | Search the live x402 bazaar (PayAI + Coinbase CDP) for paid HTTP/MCP services with prices. |
inspect_endpoint |
read-only | Read any endpoint's 402 payment requirements (scheme, network, asset, price, pay-to) without paying. |
pay_and_call |
execution | Pay an x402 endpoint in USDC from your Solana key and return its result. Bounded by MAX_PAY_USD. |
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 data
Both 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 |
|---|---|---|
SOLANA_SECRET_KEY |
to pay only | — |
SOLANA_RPC_URL |
no | https://api.mainnet-beta.solana.com |
MAX_PAY_USD |
no | 1 |
REQUIRE_CONFIRM |
no | true |
THREE_WS_BASE |
no | https://three.ws |
Links
- Homepage: https://three.ws
- MCP catalog: https://three.ws/docs/mcp
- Changelog: https://three.ws/changelog
- Issues: https://github.com/nirholas/three.ws/issues
- License: Apache-2.0, see LICENSE
Part of the three.ws SDK suite — 3D AI agents, on-chain identity, and agent payments.
Website · Changelog · GitHub
Facts
- Kind
- MCP server
- Group
- Uncategorized
- Stars
- 231
- License
- Apache-2.0
- Language
- JavaScript
- Last push
- 2026-10-12
- Forks
- 63
- MCP Registry
- io.github.nirholas/x402-mcp
- Homepage
- three.ws
- Topics
- animation, avatar, gltf, llm, mcp, webgl, 3d-generation, ai-agents, digital-human, generative-ai, glb, image-to-3d, mcp-server, model-context-protocol, solana, text-to-3d, threejs, web-components, webxr, x402
- 1REAio.github.morluto/reaReverse engineer anything from your terminal or agent with one CLI and MCP server.125.3k
- 2com.browser-use/browser-usecom.browser-use/browser-useControl a real Chrome browser to complete any task: fill forms, extract data, book flights.117.7k
- 3World Monitorapp.worldmonitor/mcpLive markets, conflicts, country risk, chokepoints, energy, and China decision signals. 93 tools.88.3k
- 4Scrapling MCP Serverd4vinci/scrapling🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scraplingdev86.9k
- 5Everythingmodelcontextprotocol/serversThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.85.8k
- 6Fetchmodelcontextprotocol/serversA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.85.8k