Skip to main content
Glama

bibi-proxy

BibiGPT 视频总结本地 MCP 代理 · 多账号 API Key 轮询

A local MCP proxy for BibiGPT (AI video & audio summarizer). Clients configure only the proxy URL; the proxy injects BibiGPT API keys with round-robin rotation, retry-on-auth-error, and hot-reload.

Qwen Code / any MCP client ──> http://localhost:8788 (this proxy)
                                      │  injects Authorization: Bearer <rotated key>
                                      ▼
                        https://bibigpt.co/api/mcp  (BibiGPT remote MCP)

功能特性 Features

  • 🔑 多账号轮询keys.json 数组里放任意数量的 BibiGPT API Key,每个请求轮换使用

  • 🔄 坏 Key 自动切换:认证失败(HTTP 401/403/429 或 JSON-RPC UNAUTHORIZED)自动换下一个 Key 重试

  • ♻️ 热重载:修改 keys.json 无需重启,fs.watch 自动加载

  • 🔐 Key 不进客户端:客户端只连代理地址,不接触任何 Key;日志全程打码

  • 🚀 32 个 MCP 工具:总结、分章节、字幕、异步长视频任务、个人库、笔记、合集、频道订阅、Feed、Notion 导出、思维导图、画面分析等

  • ⚙️ 可作 Windows 服务:随附 NSSM 脚本,开机自启、崩溃自愈

Related MCP server: video-toolkit-mcp

目录结构 Project Structure

bibi-proxy/
├── src/index.ts            # 代理源码(Node.js,零依赖,仅用 node:http)
├── package.json            # npm 脚本:build / start / dev
├── tsconfig.json
├── keys.example.json       # Key 配置模板(提交到仓库的占位符)
├── keys.json               # 真实 Key(本地创建,已被 .gitignore 排除,勿提交)
├── setup-service.cmd       # NSSM 服务安装脚本(可移植,自动探测 node/nssm)
├── nssm-2.24-101-g897c7ad/ # 随附的 NSSM 工具(win32/win64)
└── dist/                   # 编译产物(npm run build 生成,已被忽略)

快速开始 Quick Start(中文)

1. 环境要求

  • Node.js 18+(推荐 20+),node 在 PATH 中

  • Windows / macOS / Linux 均可运行;Windows 服务化需要 Windows + NSSM(已随附)

  • BibiGPT API Key:登录 https://bibigpt.co/user/integration 获取(多个账号可多放几个)

2. 安装依赖并构建

npm install
npm run build

3. 配置 API Key

copy keys.example.json keys.json

编辑 keys.json,填入你的 Key:

[
  "key_1",
  "key_2",
  "key_3"
]

Key 数量不限;keys.json 已被 .gitignore 排除,不会误提交。

4. 启动代理

npm run start        # 前台运行(开发调试用)

启动后应看到:

[proxy] keys reloaded (3) reason=startup
bibi-proxy listening on http://localhost:8788
Upstream: https://bibigpt.co/api/mcp

验证代理可用:

curl -s -X POST http://localhost:8788/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}"

应返回 BibiGPT 的 MCP 工具列表 JSON(HTTP 200)。

5. 接入 Qwen Code

qwen mcp add bibigpt http://localhost:8788 --transport http

然后在对话里直接说:

总结这个视频 https://www.bilibili.com/video/BV1xxxxxxxx

其他 MCP 客户端(Claude Desktop、Cursor 等)配置示例:

{
  "mcpServers": {
    "bibigpt": {
      "url": "http://localhost:8788",
      "type": "http"
    }
  }
}

安装为 Windows 服务(NSSM)

让代理开机自启、崩溃自动重启。需要管理员权限——请右键"以管理员身份运行"或在管理员终端中执行(会弹 UAC 由你确认)。

安装

setup-service.cmd

脚本会自动:

  1. 用脚本所在目录定位项目根和随附的 NSSM(nssm-2.24-101-g897c7ad\win64\nssm.exe

  2. 从 PATH 探测 node.exe

  3. dist 缺失先自动 npm run build

  4. 注册服务 bibi-proxy(自动启动,异常退出自动重启,日志写入 _service.log

  5. 启动服务

成功输出:SERVICE_INSTALLED_AND_STARTED

验证:

sc query bibi-proxy
netstat -ano | findstr :8788

管理命令

net start bibi-proxy     rem 启动
net stop bibi-proxy      rem 停止
sc query bibi-proxy      rem 查状态
  • 更新 Key:直接编辑 keys.json,服务内自动热重载,无需重启服务

  • 更新代码npm run buildnet stop bibi-proxy && net start bibi-proxy

卸载

在项目目录执行:

nssm-2.24-101-g897c7ad\win64\nssm.exe remove bibi-proxy confirm

使用示例 Usage

常用 MCP 工具

用户意图

工具

总结视频/音频 URL

summarize_video

自定义 prompt/模型/语言总结

summarize_video_with_config

分章节总结

summarize_by_chapter

提取字幕/转写

get_subtitle

长视频异步总结(>30 分钟)

create_summary_task + get_task_status 轮询

查账户/剩余额度

get_account_info

浏览/搜索已保存的视频

list_saved_videos / search_saved_videos

笔记、合集、频道、Feed、Notion 导出、思维导图等

详见 tools/list 返回的完整工具列表

curl 调用总结

curl -s -X POST http://localhost:8788/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"summarize_video\",\"arguments\":{\"url\":\"https://www.bilibili.com/video/BV1xxxxxxxx/\"}}}"

环境变量 Environment Variables

变量

默认值

说明

PORT

8788

监听端口

KEYS_FILE

./keys.json

Key 文件路径

BIBIGPT_MCP_BASE_URL

https://bibigpt.co/api/mcp

上游 MCP 地址

MAX_BODY_BYTES

1048576

请求体大小上限(字节)

MAX_ERROR_BODY_BYTES

262144

错误响应体缓冲上限(字节)

MAX_RESPONSE_BODY_BYTES

8388608

JSON 响应缓冲上限(字节,用于认证错误检测)

安全说明 Security

  • keys.json*.log 已被 .gitignore 排除,提交前请确认 Key 未入库

  • 代理注入 Authorization: Bearer <key>,忽略客户端自带认证头

  • 日志只记录 key 序号(key #1/5),绝不输出明文 Key

常见问题 Troubleshooting

症状

原因

解决

启动报 No API keys available

keys.json 缺失或为空

按上文第 3 步创建并填写

调用返回 UNAUTHORIZED 且全部 Key 都失败

所有 Key 均无效或额度用尽

检查 Key 有效性:curl https://api.bibigpt.co/api/version -H "Authorization: Bearer <key>";调用 get_account_info 查看剩余额度

端口 8788 被占用

已有进程监听

netstat -ano | findstr :8788 找到 PID,停掉或改用 PORT 环境变量

改了 keys.json 没生效

正常会自动热重载;日志应出现 keys reloaded (N) reason=fs.watch:rename

服务注册失败

未以管理员运行

以管理员运行 setup-service.cmd(会弹 UAC)

English Quick Start

npm install && npm run build
copy keys.example.json keys.json   # then fill in your BibiGPT API keys
npm run start

Connect from Qwen Code:

qwen mcp add bibigpt http://localhost:8788 --transport http

Install as a Windows service (elevated):

setup-service.cmd

Get API keys at https://bibigpt.co/user/integration.

第三方组件 Third-party components

  • NSSM — bundled under nssm-2.24-101-g897c7ad/ for Windows service management (see its own README.txt / ChangeLog.txt inside the folder).

  • BibiGPT — remote MCP service being proxied; API docs: https://docs.bibigpt.co

Related MCP Connectors

Related MCP Servers