内容
# anchor-x402-mcp
> MCP 服务器暴露了 14 个 [anchor-x402](https://anchor-x402.com) 服务,作为工具供任何 Claude Desktop / Cursor / Codex / Continue 代理调用。按需使用 USDC 通过 x402 在 Base 主网上支付 — 无需 API 密钥,无需订阅。
## 您能获得什么
十四种工具,调用价格为 $0.001–$0.05。
**普通原始工具** (9, $0.001–$0.010):
| 工具 | 价格 | 功能 |
|---|---|---|
| `anchor_hash` | $0.005 | 将任意 32 字节哈希锚定到 Base + Solana 主网,并返回两个交易 URL |
| `screen_wallet` | $0.001 | 对任意 EVM 或 Solana 钱包进行 OFAC SDN 制裁筛查 |
| `attest_decision` | $0.010 | 验证钱包对 (input_hash, output_hash, decision) 的签名;双链锚定结果 |
| `decode_tx` | $0.001 | 结构化解码任意主网交易(Base / Ethereum / Solana) |
| `resolve_name` | $0.001 | 跨链域名解析(ENS, Bonfida SNS) |
| `token_price` | $0.001 | 按符号或链 + 合约获取任意代币的美元现货价格 |
| `decode_calldata` | $0.001 | 原始 EVM 调用数据的 4 字节选择器 + ABI 参数解码 |
| `parse_datetime` | $0.001 | 自由格式日期时间字符串 → 结构化 ISO 8601 |
| `intel_wallet` | $0.005 | 捆绑钱包智能:余额 + 活动 + 身份 + 制裁,一次调用 |
**通用 LLM 端点** (5, $0.01–$0.05) — 在 v0.2 中添加:
| 工具 | 价格 | 功能 |
|---|---|---|
| `roast` | $0.05 | 对任意目标进行俏皮的 3-5 段 roast — 钱包、推文、代码、想法,任何事物 |
| `oracle` | $0.05 | 是/否神谕。返回 YES/NO/MAYBE + 原因 + 双链锚定 `(问题 \| 答案 \| 时间戳)` 哈希。您提问时的加密收据。 |
| `tldr` | $0.01 | 将 URL(获取最多 500KB)或粘贴的文本总结为 3-5 个简洁的要点 |
| `aura` | $0.01 | 返回颜色、等级(S/A/B/C/D/F)、分数 0-9999,以及一句俏皮的 2-3 句话的 aura 读取 |
| `grade` | $0.01 | 学术字母等级(A+ 至 F),带有红笔边缘注释和一段总结 |
调查员(`/v1/investigate`,$1.77 异步)和 [chat.anchor-x402.com](https://chat.anchor-x402.com) 上的托管聊天机器人不包含在 MCP 中 — 它们分别通过 HTTP API 和浏览器直接访问。
MCP 服务器自我付费 — 您的钱包将自动扣除每次调用的费用。无需预付,无需 API 密钥,无需账户。
## 安装
### Claude Desktop
添加到 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS)或 `%APPDATA%\Claude\claude_desktop_config.json`(Windows):
```json
{
"mcpServers": {
"anchor-x402": {
"command": "npx",
"args": ["-y", "anchor-x402-mcp"],
"env": {
"ANCHOR_WALLET_PRIVATE_KEY": "0xYOUR_BASE_WALLET_PRIVATE_KEY"
}
}
}
}
```
重启 Claude Desktop。询问: *"将哈希 `7646dda1564bde0ef3f3971f4c002962df64246da4aa1d8c47247e7632494710` 锚定到主网"* — 它将调用 `anchor_hash` 并从您的钱包支付 $0.005 USDC。
### Claude Code
添加到您的项目的 `.mcp.json`:
```json
{
"anchor-x402": {
"command": "npx",
"args": ["-y", "anchor-x402-mcp"],
"env": {
"ANCHOR_WALLET_PRIVATE_KEY": "0xYOUR_BASE_WALLET_PRIVATE_KEY"
}
}
}
```
### Codex CLI (OpenAI)
编辑 `~/.codex/config.toml`:
```toml
[mcp_servers.anchor-x402]
command = "npx"
args = ["-y", "anchor-x402-mcp"]
[mcp_servers.anchor-x402.env]
ANCHOR_WALLET_PRIVATE_KEY = "0xYOUR_BASE_WALLET_PRIVATE_KEY"
```
重启 `codex`。输入 `/mcp` 以确认 anchor-x402 显示在已加载的服务器列表中。
### ChatGPT Desktop
设置 → **集成** → **MCP 服务器** → **添加服务器**。粘贴:
```json
{
"command": "npx",
"args": ["-y", "anchor-x402-mcp"],
"env": {
"ANCHOR_WALLET_PRIVATE_KEY": "0xYOUR_BASE_WALLET_PRIVATE_KEY"
}
}
```
保存,重启,14 种工具在任何启用工具使用的聊天中都可用。
### Cursor
编辑 `~/.cursor/mcp.json`(全局)或 `<project>/.cursor/mcp.json`(项目范围):
```json
{
"mcpServers": {
"anchor-x402": {
"command": "npx",
"args": ["-y", "anchor-x402-mcp"],
"env": {
"ANCHOR_WALLET_PRIVATE_KEY": "0xYOUR_BASE_WALLET_PRIVATE_KEY"
}
}
}
}
```
### OpenAI 代理 SDK(编程)
```python
from openai_agents import Agent, MCPServerStdio
mcp = MCPServerStdio(
command="npx",
args=["-y", "anchor-x402-mcp"],
env={"ANCHOR_WALLET_PRIVATE_KEY": "0xYOUR_BASE_WALLET_PRIVATE_KEY"},
)
agent = Agent(name="researcher", model="gpt-4o", mcp_servers=[mcp])
```
与配置驱动的相同软件包、相同环境、编程方式。
### Continue / Smithery / 通用 MCP 客户端
相同的形状 — `command: npx`,`args: [-y, anchor-x402-mcp]`,环境变量携带您的钱包密钥。MCP SDK 处理传输。
或通过 [Smithery](https://smithery.ai) 一键安装:
```
npx -y @smithery/cli install anchor-x402-mcp --client claude
```
(将 `--client claude` 替换为 `cursor`、`codex`、`windsurf` 等)
### 独立运行
```bash
ANCHOR_WALLET_PRIVATE_KEY=0xYOUR_KEY npx anchor-x402-mcp
```
通过 stdio 提供 MCP。将其输送到任何兼容 MCP 的客户端。
## 资助您的钱包
您设置的钱包作为 `ANCHOR_WALLET_PRIVATE_KEY` 需要 **Base 主网上的 USDC**。任何金额都有效 — 即使 $1 也能购买 100 次 anchor 调用或 1000 次普通层调用。 将 USDC 发送到您的钱包的 Base 地址:
- Base 上的 USDC 合约:`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
- 通过 [bridge.base.org](https://bridge.base.org) 从以太坊主网桥接
- 直接在 Coinbase 购买并提现到 Base
MCP 服务器通过 [x402](https://github.com/coinbase/x402) 签署支付 — Coinbase 的开放式 HTTP 原生微支付协议。每个请求:
1. 访问 `anchor-x402` 端点
2. 获取带有支付要求的 402
3. 服务器使用您的私钥签署 USDC 转账授权
4. 重新尝试请求并附上签署的支付 — API 通过 Coinbase 的促进者结算
您会看到响应,您的钱包的 USDC 余额会因调用价格而减少。小于一秒,无账本,无账户。
## 环境变量
| 变量 | 是否必需? | 用途 |
|---|---|---|
| `ANCHOR_WALLET_PRIVATE_KEY` | 是,需付费调用 | EVM 私钥。钱包支付 x402 调用费用。 |
| `ANCHOR_API_URL` | 否 | 重写 API 基本 URL。默认为 `https://api.anchor-x402.com`。对于针对自行托管的分叉进行开发很有用。 |
如果未设置 `ANCHOR_WALLET_PRIVATE_KEY`,则付费工具调用将返回一个友好的 402 消息,解释如何设置它。 `/health` 和 `/openapi.json`(不是作为工具暴露,而是通过直接 `curl` 可访问)无需支付即可工作。
## 安全说明
- 私钥存储在 MCP 客户端的配置文件中。**像热钱包一样对待它** — 只资助您愿意自主花费的金额。
- 推荐:为代理使用生成一个新的钱包。定期充值;不要重复使用一个持有大量资金的钱包。
- MCP 服务器仅签署 USDC 支付授权到 anchor-x402 的已知金库地址(在 402 响应中可见)。它无法将您的钱包资金转移到任意地址。
- 源代码在 [github.com/hypeprinter007-stack/anchor-x402-mcp](https://github.com/hypeprinter007-stack/anchor-x402-mcp) 上完全公开。安装前请审计。
## 验证 anchor 收据
每次 `anchor_hash` 和 `attest_decision` 调用都返回 Base + Solana 交易 URL。这些可以在公共区块浏览器上独立验证 — 代理可以确认 anchor 存在而无需重复支付:
- Base:`https://basescan.org/tx/<base.tx>` — 输入数据字段包含默克尔根
- Solana:`https://solscan.io/tx/<solana.tx>` — 备注程序数据包含相同的十六进制
链上字节是收据;API 响应只是对它们的便捷封装。参见 [链上可验证性入门](https://anchor-x402.com/trust/on-chain-verifiability) 以获取完整的验证配方。
## 故障排除
**"需要支付(402)。请设置 ANCHOR_WALLET_PRIVATE_KEY..."**
您尚未配置钱包。请在 MCP 配置中添加环境变量并重启 Claude Desktop。
**"支付失败(402)。钱包可能已用完 USDC..."**
您的钱包已用完。请将 Base 上的 USDC 发送到服务器启动日志中显示的钱包地址(它将 `payer=0x…` 记录到 stderr)。
**"anchor-x402 请求失败:..."**
网络或 DNS 问题。请检查 `https://api.anchor-x402.com/health` 是否返回 200;如果不是,请参见 [状态页面](https://anchor-x402.betteruptime.com)。
## 链接
- **实时 API:** https://api.anchor-x402.com
- **网站 / 信任门户:** https://anchor-x402.com
- **状态:** https://anchor-x402.betteruptime.com
- **服务器源代码:** https://github.com/hypeprinter007-stack/anchor-x402
- **MCP 服务器源代码(此仓库):** https://github.com/hypeprinter007-stack/anchor-x402-mcp
- **x402 协议:** https://github.com/coinbase/x402
- **MCP 规范:** https://modelcontextprotocol.io
## 许可证
MIT