进阶

MCP(AI Agent 接入)

把 BoltTx 接入任何兼容 MCP 的 AI 客户端。你的 agent 接收自然语言指令 —— BoltTx 负责把交易投递上链。

为什么是 MCP?

MCP(Model Context Protocol)是连接 AI agent 与外部工具的开放协议。BoltTx 是 Solana 交易投递赛道首家原生提供 MCP server 的服务 —— 这意味着你的 AI agent 无需写任何粘合代码,就能查账户、查 tip 最低值、提交已签名交易。

私钥永不离开你的设备

MCP server 只接收 **已经签名好** 的交易。签名永远在本地完成 —— Phantom、Solflare、本地 keypair 文件、硬件钱包、或者你自己的签名服务都行。MCP server 的职责是「投递」,绝不是「托管」。

安装

无需手动安装 npm 包

你 **不需要** 执行 `npm install @bolttx/mcp-server`。下面配置片段里的 `npx -y` 会在第一次使用时把 server 下载到你的 npm 缓存(约 2-3 秒),之后每次启动都直接从缓存运行。升级也是自动的 —— 重启 agent 就会拉到最新版。

前置条件

  • 安装 Node.js 18+(用 `node --version` 确认)
  • 任意 MCP 兼容的 AI agent

在你的 MCP 客户端配置里加一段 JSON 即可。MCP 兼容的 AI agent 第一次调用 BoltTx 工具时会自动通过 `npx` 拉起 server。

config.json
{
  "mcpServers": {
    "bolttx": {
      "command": "npx",
      "args": ["-y", "@bolttx/mcp-server"],
      "env": {
        "BOLTTX_API_KEY": "btx_live_your_api_key_here"
      }
    }
  }
}
高级:全局安装(可选,替代 npx)

如果你想要固定版本(省掉每次启动 agent 时 npx 查缓存的时间,或者要在离线环境工作),可以全局安装:

shell
npm install -g @bolttx/mcp-server

然后把 MCP 配置改成直接调用全局命令(不走 npx):

config.json (global-install variant)
{
  "mcpServers": {
    "bolttx": {
      "command": "bolttx-mcp-server",
      "env": {
        "BOLTTX_API_KEY": "btx_live_your_api_key_here"
      }
    }
  }
}

可用工具

这些是 AI agent 看到的工具名。Agent 会根据你的自然语言请求自动决定调哪个。

参数描述
bolttx_get_my_accountInspect plan, TPS budget, cumulative tip, and upgrade progress for the current API key.
bolttx_list_tip_addressesReturns the 9 BoLt1-9 vanity tip addresses plus a recommended one (round-robin load distribution).
bolttx_get_tip_amountLooks up minimum tip (lamports + SOL) for a given plan name.
bolttx_send_transactionSubmits a single fully-signed base64 transaction. Server NEVER signs — agent must sign locally first.
bolttx_send_batchSubmits 1..100 pre-signed transactions concurrently. Per-tx status reported independently.
bolttx_get_statusLooks up BoltTx delivery telemetry for a signature your account submitted. Returns 404 for foreign signatures.

资源

Agent 在需要背景信息时主动拉取的只读上下文。回答「我是什么套餐?」、「最低 tip 多少?」这类问题无需走网络。

URI描述
bolttx://plansFull plan table — Starter / Growth / Pro / Whale with TPS, min tip, upgrade thresholds.
bolttx://tip-addressesThe 9 canonical BoLt1-9 tip addresses.
bolttx://quickstartStep-by-step minimum working example. Useful when the agent needs reasoning context for tx construction.

标准 Agent 工作流

当你对 AI 说「用 BoltTx 发 0.1 SOL 给 X,最低 tip」时,agent 内部按这个顺序走:

  1. 1

    调 `bolttx_get_my_account` → 知道你的套餐(例如 Growth)

  2. 2

    调 `bolttx_get_tip_amount("growth")` → 拿到最低 tip 的 lamports

  3. 3

    调 `bolttx_list_tip_addresses` → 选 9 个 tip 地址中的一个

  4. 4

    本地构造交易(你的指令 + 给 tip 地址的 SystemProgram transfer)

  5. 5

    本地用你的 keypair 签名(私钥永远不接触 MCP server)

  6. 6

    调 `bolttx_send_transaction(base64)` → 拿到签名

  7. 7

    (可选)稍等后调 `bolttx_get_status(signature)` → 确认上链

兼容性

任何兼容 MCP 的客户端都能用 —— 协议本身是标准化的,配置格式跨厂商完全统一。每家客户端的具体配置文件路径见 npm 上的 @bolttx/mcp-server README,新 MCP 客户端上线时我们会同步更新该文档。

环境变量

参数必填描述
BOLTTX_API_KEY必填你的 BoltTx API key,从 dashboard 创建。必填。
BOLTTX_BASE_URL可选覆盖 API 基础 URL(默认 https://bolttx.io)。仅用于 staging 或自部署测试。

常见问题

「找不到 bolttx 工具」

确认 server 出现在你 MCP 客户端的活跃 server 面板里。检查客户端开发者控制台是否有配置解析错误。改完配置要重启客户端。

「Rate limit exceeded」

你已超过套餐的 TPS 上限。错误体里有 `retry_after_ms` 字段,AI agent 应该尊重该值 —— 或者升级套餐。

「Transaction must include a tip transfer」

你的交易缺少给 BoltTx tip 地址的 SystemProgram transfer。确保 AI 调用了 `bolttx_list_tip_addresses` 并加入了 transfer 指令再提交。