npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

botpay-go-mcp

v0.2.0

Published

Guardrailed BotPay /go trading MCP for Binance, OKX, Coinbase, Hyperliquid, and Polymarket.

Readme

BotPay /go 多 Agent 交易 MCP

botpay-go-mcp 是一个默认关闭实盘、带预算和审批边界的 MCP/REST 网关。它让 Codex、Claude Code、Cursor、OpenClaw(“龙虾”)、Hermes、Manus 和 Grok Bot 通过同一个 /go 工作流访问:

  • Binance、OKX、Coinbase 现货
  • Hyperliquid 现货(当前安全基线不开放永续、杠杆)
  • Polymarket 事件合约限价单
  • 单笔委托和一次确认的批量委托

正式用户入口是 $botpay:成功支付 BotPay /go0.10 USDC access plan 后,npx -y botpay@latest go mcp 会启动固定版本的本连接器。/pay 仍只解锁 Bazaar;/go 支付只解锁连接器,不保存交易所密钥,也不代表用户批准了任何订单。

安全架构

Codex / Claude / Cursor / OpenClaw / Hermes / Manus / Grok
                       │ 每个 Agent 独立 Bearer Token
                       ▼
              HTTPS MCP + REST 网关
              ├─ 只读行情与账户查询
              ├─ 白名单、单笔/日累计限额
              ├─ 幂等键、价格漂移重验
              └─ SQLite 提案与审计日志
                       │
            人工 Operator Token(不交给 Agent)
                       │
                       ▼
 Binance / OKX / Coinbase / Hyperliquid / Polymarket

Agent 可以查行情、分析、生成单笔或整批提案;它不能调用 operator 路由给自己授权。人只需批准一次整批提案,随后 Agent 可调用 execute_batch。跨平台订单本质上不是原子事务,执行中断时可能只成交前几腿,网关会停止剩余腿并返回 partial

快速开始

要求 Node.js 24+。

npm install
cp .env.example .env
npm run check
npm test
npm run dev:http

通过正式 BotPay 入口连接 stdio MCP:

npx -y botpay@latest plan go
npx -y botpay@latest execute go --yes   # 仅在人工明确批准该 0.10 USDC 计划后
npx -y botpay@latest go status
npx -y botpay@latest go mcp

直接开发或自托管本连接器时可安装 [email protected];公开用户流程应使用上面的 BotPay access gate。支付授权、Agent MCP 权限和 operator 交易批准是三层独立权限。

环境变量不会自动从 .env 加载;请用你的进程管理器、容器 Secret 或 shell 注入。先保持 TRADING_MODE=read_only,配置每个 Agent 的独立 token 后切到 paper,通过完整演练后才使用 live

远程实盘必须使用 HTTPS,并设置:

  • GO_AGENT_TOKENS_JSON:token 到 Agent 身份的映射,每个 Agent 一个 token。
  • GO_OPERATOR_TOKEN_HASH:高熵 operator token 的 SHA-256,小写十六进制摘要。原始 token 只放在人的终端。
  • GO_ALLOWED_HOSTS:网关允许的 Host 名称。
  • GO_ALLOWED_SYMBOLS:现货白名单。
  • GO_ALLOWED_POLYMARKET_TOKEN_IDS:Polymarket outcome token 白名单;空值会禁止 Polymarket 下单,但仍可查市场。

生成 operator token 摘要时,可让 Node 从当前环境读取原始值,避免把值写进命令历史:

export GO_OPERATOR_TOKEN='use-a-password-manager-generated-secret'
node -e 'const c=require("node:crypto");process.stdout.write(c.createHash("sha256").update(process.env.GO_OPERATOR_TOKEN).digest("hex")+"\n")'

交易凭据

所有凭据只注入网关,绝不放进 Agent 配置或技能目录。

| 场所 | 网关变量 | 最小权限建议 | |---|---|---| | Binance | BINANCE_API_KEY, BINANCE_API_SECRET | 仅 Spot Trade,关闭提现,绑定网关出口 IP | | OKX | OKX_API_KEY, OKX_API_SECRET, OKX_API_PASSPHRASE | Read + Trade;关闭 Withdraw,绑定 IP | | Coinbase | COINBASE_API_KEY, COINBASE_API_SECRET | Advanced Trade View + Trade,不授予转账 | | Hyperliquid | HYPERLIQUID_API_WALLET_PRIVATE_KEY, HYPERLIQUID_ACCOUNT_ADDRESS | 每个交易进程单独 API/agent wallet;不要使用主钱包私钥 | | Polymarket | POLYMARKET_SESSION_PRIVATE_KEY, POLYMARKET_DEPOSIT_WALLET, 三个 API credential 变量 | Deposit Wallet 的 scoped session signer 及其派生 CLOB 凭据;不要使用 owner key/owner CLOB 凭据 |

网关没有提现、转账、资金划转、兑换、API 密钥管理、杠杆或永续工具。Polymarket 的 session key 当前仍是 Beta;首次授权需要 Builder API key 并受官方 rollout/地区可用性约束,授权动作应在网关外完成。收到 HTTP 451 等限制时网关会原样失败,不会绕过。

/go 工作流

单笔:

  1. Agent 调 get_ticker 或 Polymarket 搜索/订单簿工具并给出带时间戳的分析。
  2. Agent 调 prepare_orderprepare_prediction_order。此时不会下单。
  3. 人在隔离终端查看并批准:npm run go -- approve <proposal-id> --by <identity>
  4. Agent 调 execute_order。只有返回 status=executed 才能说已提交。

批量:

  1. Agent 调 prepare_batch,返回所有腿、总估算名义金额及 atomic=false
  2. 人只批准一次:npm run go -- batch-approve <batch-id> --by <identity>
  3. Agent 调 execute_batch
  4. 如果返回 partial 或某腿为 execution_unknown,停止自动操作,到对应场所按订单 ID/账户记录核对。

单笔和批量都受提案 TTL、单笔额度、每日已批准额度和执行前价格漂移限制。默认禁用市价单。

MCP 工具

只读工具:list_exchangesget_tickerget_balancesget_open_orderssearch_polymarket_marketsget_polymarket_bookget_polymarket_positionsget_polymarket_open_ordersget_proposalget_batch

提案工具(不交易):prepare_orderprepare_prediction_orderprepare_batch

执行工具(可能改变真实资金):execute_orderexecute_batch

MCP 地址为 https://YOUR-GATEWAY/mcp;本机测试为 http://127.0.0.1:8787/mcp。客户端模板在 configs,REST/OpenAPI 兼容定义在 configs/go-openapi.json

多 Agent 与并发

  • 所有客户端共享数据库和风险预算,因此多个 Agent 同时提交也受同一个日限额约束。
  • 提案和批次都需要调用方生成稳定、唯一的 idempotency key。
  • 数据库使用原子 claim,两个 Agent 不能把同一个已批准对象重复提交。
  • execution_unknown 永不自动重试,因为第一次请求可能已在交易所成功。
  • SQLite 适用于单机网关;多副本生产部署应替换为带事务锁和唯一约束的 PostgreSQL,并保持相同状态机。

开发验证

npm run check
npm test
npm run build

测试不会使用真实凭据,也不会发真实订单。实盘切换前还应在各平台测试网/小额账户做端到端演练、日志告警、备份和紧急停机测试。