token4u-mcp
Enables AI agents to call LLM APIs via x402 micropayments in USDC on Base network, manage a local wallet, and query consumption records.
README
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-mcp
Local build
npm install
npm run build
Environment Variables
| Variable | Default | Description |
|---|---|---|
TOKEN4U_API_URL |
https://token4u.ai |
token4u API base URL |
TOKEN4U_WALLET_KEY |
(optional) | Local wallet private key (takes priority over file) |
TOKEN4U_BUDGET_LIMIT |
(optional) | Max USD budget for LLM calls |
TOKEN4U_DATA_DIR |
~/.token4u-mcp |
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=status
Create — generate a new local wallet keypair or load an existing one:
token4u_wallet action=create
The 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=setup
Shows 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=1
Funding 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=create -
Get funding instructions:
token4u_wallet action=setup -
Send 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)
- EIP-3009 Signature — Sign a
TransferWithAuthorizationtyped data message authorizing the USDC transfer - PAYMENT-SIGNATURE — Re-send the request with a base64-encoded
PAYMENT-SIGNATUREheader containing the signed authorization - SSE Stream — Server verifies the signature and streams the LLM response via Server-Sent Events
Security
- Private keys are stored at
~/.token4u-mcp/wallet.jsonwith0o600permissions - Private keys never leave this machine — all EIP-3009 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.js
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。