token4u-mcp
OfficialThe token4u-mcp server enables AI agents to make paid LLM API calls using x402 micropayments (USDC on Base) and manage a self-custodial local wallet, with no token4u account required. Key capabilities:
Wallet Management (
token4u_wallet): Create/load a local signing wallet stored securely at~/.token4u-mcp/wallet.jsonwith 0o600 permissions; check status; get funding instructions. Private keys never leave the machine.Paid LLM Chat (
token4u_chat): Call AI models (e.g., deepseek-v3) with USDC payments via x402 using EIP-3009 authorization; configurable parameters (messages, max tokens, temperature).Consumption Records (
token4u_consumption): Query public on-chain x402 payment history for any EVM wallet, including model, token usage, cost (USD), transaction hash, and timestamp.
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., "@token4u-mcp Check my wallet status"
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.
Token4u MCP Server
透過 x402 微支付讓 AI agent 調用 LLM API + 查詢 x402 消費明細。
純 external x402 模式:MCP server 本地管理 wallet 私鑰(~/.token4u-mcp/wallet.json,0o600),所有支付走 x402 鏈上 USDC(Base network),無需 token4u 帳號。
Installation
via npx (recommended)
claude mcp add token4u-mcp -- npx -y token4u-mcpLocal build
npm install
npm run buildRelated MCP server: PayAgents MCP Server
Environment Variables
Variable | Default | Description |
|
| token4u API base URL |
| (optional) | Local wallet private key (takes priority over file) |
| (optional) | Max USD budget for LLM calls |
|
| Directory for wallet key and session storage |
Tools
1. token4u_wallet — Manage Local Wallet
Create and manage a local signing wallet for x402 payments.
Status(default)— check wallet state:
token4u_wallet action=statusCreate — generate a new local wallet keypair or load an existing one:
token4u_wallet action=createThe private key is stored at ~/.token4u-mcp/wallet.json with 0o600 permissions
and never leaves this MCP server.
Setup — get step-by-step funding guidance:
token4u_wallet action=setupShows your wallet address and instructions for depositing USDC on Base network.
2. token4u_chat — Paid LLM Chat
Call AI models via token4u, paid with USDC on Base via x402.
token4u_chat model=deepseek-v3 messages=[{"role":"user","content":"Hello!"}]3. token4u_consumption — View Consumption Records
Query x402 consumption records for a given EVM wallet address (public API — no login required).
token4u_consumption address=0xYourWalletAddress page=1Funding Your Wallet
This MCP server runs in pure external x402 mode — your local wallet must be funded with USDC on Base before making paid LLM calls.
Quick Start
Create a wallet(if you haven't already):
token4u_wallet action=createGet funding instructions:
token4u_wallet action=setupSend USDC on Base to the wallet address shown. You can use:
MetaMask (or any EVM wallet) connected to Base network
Coinbase / exchange withdrawal to Base
Any Base bridge to on-ramp USDC
Verify the balance is visible on-chain (e.g., basescan.org) — the x402 protocol reads your USDC balance directly from the chain.
Self-Custody
Your private key is at ~/.token4u-mcp/wallet.json (permissions: 0o600).
You can import it into MetaMask or any EVM wallet for self-management:
MetaMask: Settings → Import Account → paste the private key
Rabby / Frame: similar "Import Private Key" flow
⚠️ Anyone with this private key can spend your USDC. Never share it.
x402 Flow
Each paid LLM call follows the x402 micropayment protocol:
402 Quote — POST without payment → server responds with HTTP 402 + payment details (price, recipient, network)
Authorization Signature — Sign a typed data message authorizing the USDC transfer:
Permit2 (
uptoscheme withassetTransferMethod=permit2) — sign aPermitWitnessTransferFromauthorising a ceiling amount; the server settles only the actual cost post-execution (≤ ceiling)EIP-3009 (
exactscheme or legacyupto) — sign aTransferWithAuthorizationfor the exact amount
PAYMENT-SIGNATURE — Re-send the request with a base64-encoded
PAYMENT-SIGNATUREheader containing the signed authorizationSSE Stream — Server verifies the signature and streams the LLM response via Server-Sent Events
Security
Private keys are stored at
~/.token4u-mcp/wallet.jsonwith0o600permissionsPrivate keys never leave this machine — all EIP-3009 and Permit2 signing happens locally
No token4u account required — the MCP server manages its own local wallet
All payments are on-chain USDC transfers on Base network
Development
# Install dependencies
npm install
# Type check
npm run typecheck
# Run tests
npm test
# Build
npm run build
# Run locally
node dist/index.jsLicense
MIT
Available Tools
3 toolstoken4u_chatA
Chat with AI models via token4u using x402 micropayments (USDC on Base). Each call is priced per-model and paid via an EIP-3009 authorization from your local wallet. Requires a wallet — run token4u_wallet action=create first.
Inputs: model (required), messages (required), max_tokens, temperature.
token4u_consumptionA
Query x402 consumption records for a given EVM wallet address. Public API — no login required. Returns per-call records with model, token usage, credits, amount paid in USD, transaction hash, and timestamp.
Inputs: address (required), page, page_size.
token4u_walletA
Manage local x402 wallet — create keypair, check status, and get funding guidance.
This is a pure external x402 mode: the MCP server manages a local wallet (~/.token4u-mcp/wallet.json, 0o600). All payments go through on-chain x402 USDC transactions on Base network. No token4u account or internal wallet required.
Actions:
status (default): Show local wallet address and whether it is newly created.
create: Generate a new local wallet keypair or load an existing one. The private key is stored at ~/.token4u-mcp/wallet.json with 0o600 permissions and never leaves this machine.
setup: Show step-by-step funding instructions — how to send USDC on Base to your local wallet address, and how to export the private key for self-custody.
Inputs: action.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: wallet management, chat with micropayments, and consumption record querying. There is no overlap or ambiguity between them; even the actions within token4u_wallet are well-separated.
All tool names follow the consistent pattern 'token4u_<noun>' using snake_case. This makes the toolset predictable and easy to navigate for agents.
With only 3 tools, the server is tightly scoped to its purpose of handling x402 micropayments via a local wallet. Each tool provides a distinct and necessary function, and none feel redundant or superfluous.
The set covers the full workflow: wallet creation/funding guidance, chat with micropayments, and transaction consumption queries. A minor gap is the lack of a direct balance-check tool, but the core functionality is complete for the stated purpose.
Related MCP Connectors
Pay-per-call tools for autonomous agents, settled in USDC on Base via x402.
Pay-per-call agent tools over x402 (USDC on Base) — no signup or API key.
Pay-per-use MCP tools for AI agents. USDC on Base via x402. No API keys.
Pay-per-call AI and media tools over x402. USDC on Base, no signup, no API key.
Related MCP Servers
- AlicenseAqualityDmaintenanceGives AI agents a smart-contract wallet on Base (USDC) with 10 stdio tools: create wallets, send USDC payments, pay x402-protected HTTP resources, and run ERC-8183 escrow Jobs for A2A service delivery.10MIT

PayAgents MCP Serverofficial
AlicenseAqualityDmaintenanceEnables AI agents to autonomously make policy-controlled payments for APIs and tools via Bitcoin Lightning (L402) and Base USDC (x402), including paying paywalled endpoints, checking balances, and reviewing transactions.321 npm1MIT- AlicenseNot gradedqualityCmaintenanceEnables AI agents to autonomously pay for metered web APIs on a per-call basis, settling x402 v2 USDC micropayments via EIP-3009 authorization on Base Sepolia without human involvement. Spending is bounded by configurable per-call caps and host restrictions, and exposes tools to fetch paywalled URLs and inspect the agent wallet's address and balance.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to check their wallet address and USDC balance, preview the cost of an x402 call, and pay for API requests in USDC on Base without an account or API key. Spend caps, allow-lists and blocked contracts are enforced in code before anything is signed, so a prompt injection cannot bypass them.1MIT