Skip to main content

什么是 MCP?

Model Context Protocol 是 Anthropic 为 LLM 提供外部工具访问能力的开放标准。l402-kit 内置了一个现成的 MCP 服务器,包含两类工具:

通用 L402 工具

工具描述
l402_fetch获取任意 URL — 若返回 402 则自动付款
l402_balance查看剩余 Lightning 预算
l402_spending_report本次会话的完整支付明细

VERITY 工具 — 付费服务,自动付款

工具价格描述
verity_btc_price10 sats实时 BTC 价格(USD、EUR、BRL)
verity_worldstate80 satsUTC 时间 + 地理位置 + 当地天气
verity_search100 sats网页搜索,前 10 条自然结果
verity_summarize50 satsAI 摘要,最多 50,000 字符
verity_sentiment30 sats情感评分 + 关键词
verity_scrape200 sats网页抓取并转换为干净的 markdown
verity_domain_intel500 satsWHOIS + DNS + SSL 证书
verity_translate50 satsAI 翻译,支持 11 种语言,兼容 MDX
verity_integration10,000 sats为任意 GitHub 仓库完整集成 l402-kit
VERITY 工具自主付款 — 无需手动处理发票。

在 Claude Desktop 中配置

1. 安装 Node.js ≥ 18

2. 配置你的钱包

配置文件位置:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

3. 重启 Claude Desktop

工具 l402_fetchl402_balancel402_spending_report 将出现在 Claude 的工具列表中。

环境变量

变量是否必填描述
BLINK_API_KEY仅 Blink你的 Blink API 密钥
BLINK_WALLET_ID仅 Blink你的 Blink 钱包 ID
ALBY_TOKEN仅 AlbyAlby 访问令牌
ALBY_HUB_URL可选自定义 Alby Hub 基础 URL
BUDGET_SATS可选每次会话最大支出(默认:2000

使用工具

服务器运行后,Claude 可以自主调用 VERITY 及任何受 L402 保护的 API:
你:现在 BTC 的价格是多少?

Claude:[调用 verity_btc_price]
        [已支付 10 sats] {"bitcoin":{"usd":97500,"eur":89800,"brl":548000}}

        比特币当前价格为 $97,500 USD(费用:10 sats)
你:摘要这篇文章:<粘贴 5,000 字>

Claude:[调用 verity_summarize,text="..."]
        [已支付 50 sats] {"summary":"..."}
你:搜索 "lightning network adoption 2026"

Claude:[调用 verity_search,q="lightning network adoption 2026"]
        [已支付 100 sats] {"results":[...]}
你:我目前总共花了多少?

Claude:[调用 l402_spending_report]
        === L402 Spending Report ===
        Total spent:  160 sats
        Remaining:    1840 sats

        By domain:
          l402kit.com: 160 sats

HTTP MCP 端点

除 stdio 包外,VERITY 还提供一个在线 HTTP MCP 服务器 — 无需安装:
POST https://l402kit.com/api/mcp
Content-Type: application/json
任何支持可流式 HTTP 传输的 MCP 客户端均可直接连接。通过请求头传入你的 Blink 凭证:
X-BLINK-API-KEY: your-blink-api-key
X-BLINK-WALLET-ID: your-wallet-id
初始化:
{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}},"id":1}
列出工具:
{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}
调用工具:
{"jsonrpc":"2.0","method":"tools/call","params":{"name":"verity_btc_price","arguments":{}},"id":3}
该端点使用你的钱包凭证自动支付 Lightning 发票,并直接返回 VERITY 结果。

MCP 注册表

l402-kit 已收录于所有主流 MCP 注册表:
注册表链接
Anthropic MCP Registry(官方)io.github.ThiagoDataEngineer/l402-kit
Glamaglama.ai/mcp/servers/@ShinyDapps/l402-kit
Smitherysmithery.ai/servers/shinydapps/l402-kit
mcp.so搜索 l402-kit
机器可读清单:GET https://l402kit.com/.well-known/mcp.json

在 Cursor 中配置

在 Cursor 的 Settings → MCP Servers 中添加相同的配置块。

在任意 MCP 客户端中配置

服务器从 stdin 读取并写入 stdout(stdio 传输):
BLINK_API_KEY=xxx BLINK_WALLET_ID=yyy BUDGET_SATS=500 npx l402-kit-mcp
任何兼容 MCP 的客户端均可使用 stdio 传输进行连接。

构建自定义 MCP 服务器

你也可以直接在自己的 MCP 服务器中嵌入 L402Client
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { L402Client, BlinkWallet } from "l402-kit";
import { z } from "zod";

const client = new L402Client({
  wallet: new BlinkWallet(process.env.BLINK_API_KEY!, process.env.BLINK_WALLET_ID!),
  budgetSats: 1000,
});

const server = new McpServer({ name: "my-agent", version: "1.0.0" });

server.tool(
  "fetch_weather",
  "Get current weather for a city — pays automatically",
  { city: z.string() },
  async ({ city }) => {
    const res = await client.fetch(`https://api.weather.com/current?city=${city}`);
    const text = await res.text();
    return { content: [{ type: "text", text }] };
  },
);

const transport = new StdioServerTransport();
await server.connect(transport);

安全说明

  • 预算上限(BUDGET_SATS)是你的主要安全保障 — 请保守设置
  • 每个 npx l402-kit-mcp 进程拥有独立的内存预算,重启后重置
  • 对于生产环境的智能体,请通过 onSpend 回调将支出日志持久化到外部存储