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-mcpCheck 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: cardzero-mcp
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.
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | token4u model name (e.g. deepseek-v3) | |
| messages | Yes | ||
| max_tokens | No | Maximum tokens in the response | |
| temperature | No | Sampling temperature (0-2) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral disclosure. It reveals that each call is paid per-model via an EIP-3009 authorization from the local wallet, and that a wallet must exist. This is critical operational context. It doesn't mention return format or errors, but the payment trait is well covered.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, each earning its place: purpose and payment mechanism, per-model pricing, and prerequisite. No fluff or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema or annotations, the description covers the key aspects: what the tool does, how payment works, and what is required before calling. It doesn't explicitly state the response format, but 'chat' implies a model reply. Overall sufficient for a paid chat tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already provides descriptions for model, max_tokens, and temperature (75% coverage). The description adds an example model name and clarifies per-model pricing, but does not add significant meaning for the messages parameter or further parameter syntax. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Chat'), specifies the resource ('AI models via token4u'), and adds the payment mechanism (x402 micropayments). This clearly differentiates it from sibling tools like token4u_wallet (wallet management) and token4u_consumption (usage tracking).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a clear prerequisite: run token4u_wallet action=create first. It implies this tool is for chat actions requiring payment, but does not explicitly mention when to prefer this over token4u_consumption. Still, the wallet requirement is practical guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number, default 1 | |
| address | Yes | EVM wallet address (0x...) to query x402 consumption records for | |
| page_size | No | Page size, default 10 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It states the API is public and requires no login, and it lists the exact return fields (model, token usage, credits, amount paid in USD, transaction hash, timestamp). It does not mention rate limits or error handling, but for a read-only query this is reasonably transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the purpose, and includes only essential details (public API, return fields). Every sentence earns its place without waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers purpose, public access, and return fields, which is important because no output schema exists. For a simple query tool with three parameters, it is fairly complete. It lacks details on pagination behavior or error conditions, but the schema covers page/page_size and default values, so the description meets the core needs.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, and the description does not add significant new parameter semantics beyond what the schema already provides. The description mentions 'given EVM wallet address' which aligns with the address parameter but adds no additional detail about page or page_size beyond the schema's defaults.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool queries x402 consumption records for a given EVM wallet address, using the specific verb 'Query' and identifying the resource and scope. This distinguishes it from sibling tools like token4u_wallet and token4u_chat, which likely handle wallet and chat functions respectively.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for usage: it is a public API requiring no login, intended for querying per-call consumption records for a wallet address. It does not explicitly mention alternatives or when not to use it, but the context is sufficient for basic selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Which wallet operation to perform | status |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does so thoroughly. It discloses the wallet file location and permissions (~/.token4u-mcp/wallet.json, 0o600), that the private key never leaves the machine, how create loads or generates a keypair, and the underlying network (Base USDC). This far exceeds the minimum required.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded with the main purpose, followed by a concise context paragraph and an action list. Every sentence contributes useful information without fluff, making it scannable and appropriately sized for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given it has only one parameter, no annotations, and no output schema, the description is exceptionally complete. It explains the tool's purpose, all three actions with their effects, underlying network details, security properties, and prerequisite context (no token4u account needed), leaving no critical gaps for an agent to select and invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Although the schema covers the single parameter 'action' with an enum and description, the description adds substantial meaning by explaining what each enum value does: status shows address/newly-created flag, create generates/loads a keypair with security details, and setup provides funding/export steps. This goes well beyond the schema's minimal 'Which wallet operation to perform.'
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: 'Manage local x402 wallet — create keypair, check status, and get funding guidance.' It clearly distinguishes from sibling tools (token4u_chat, token4u_consumption) by focusing solely on wallet operations and explicitly noting this is for external x402 mode without a token4u account.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear usage context: it is for 'pure external x402 mode' and notes 'No token4u account or internal wallet required,' which implies when to use this tool over alternatives that might require an account. However, it does not explicitly state when not to use it or name alternative tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.3.0- First observed
token4u_chat - First observed
token4u_consumption - First observed
token4u_wallet
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.
Maintenance
Related MCP Connectors
Pay-per-call tools for autonomous agents, settled in USDC on Base via x402.
Pay-per-call NLP & embeddings APIs on Base via x402. No keys/signup; agents pay per call in USDC.
Pay-per-call NLP & embeddings APIs on Base via x402. No keys/signup; agents pay per call in USDC.
Give your AI agent an x402 wallet: discover and pay for services in USDC, or earn from your own.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceUSDC payments for AI agents on Base. Direct transfers, pre-funded tabs, x402 paywall handling, and service discovery.24 npmMIT
- 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.106 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to discover, pay for, and sell HTTP APIs using the x402 micropayment protocol, with USDC settlement on Base mainnet. Includes tools for payment requirements, paying and fetching resources, building seller configurations, and monitoring revenue.83 npm1MIT
- AlicenseAqualityDmaintenanceEnables AI agents to discover and pay for x402-gated HTTP APIs, handling 402 Payment Required flows with local signing. Supports EVM and Solana with non-custodial wallet management.286 npmMIT