Equip your AI assistant with Bilibili video subtitles and comments.
Bilibili MCP Tool
✨ **为你的 AI 助手装上 B 站的眼睛**:一键提取视频字幕与热门评论,助力高效信息总结 🚀
✨ **Equip your AI assistant with "Bilibili Eyes"**: One-click extraction of video subtitles and popular comments for efficient information summarization 🚀
🌐 English Documentation (English read me version here)
📜 更新日志 (Changelog)
[!TIP] ⚠️ 提示:使用前请务必配置您的 B 站 Cookie,否则将无法提取视频字幕与评论。详见 **⚙️ 凭证配置**(凭证只会保存在本地,不会上传到任何地方)。
⚠️ Notice: Please make sure to configure your Bilibili Cookies before use, otherwise video subtitles and comments cannot be extracted. See **⚙️ Credential Configuration** (Cookies are only stored locally and will not be uploaded anywhere).
📑 目录
- Bilibili MCP Tool
- ✨ **为你的 AI 助手装上 B 站的眼睛**:一键提取视频字幕与热门评论,助力高效信息总结 🚀
- ✨ **Equip your AI assistant with "Bilibili Eyes"**: One-click extraction of video subtitles and popular comments for efficient information summarization 🚀
- 📑 目录
- ⚡ 快速预检
- 🌟 功能特性
- 📋 环境要求
- 🚀 安装方式
- ⚙️ 凭证配置
- 💡 工具使用示例
- 🛡️ API 限流机制
- 🛠️ 开发指南
- ⚖️ 安全性与免责声明
- 🛠️ 开发过程
- 💬 反馈与建议
⚡ 快速预检
[!IMPORTANT] 本工具需要 Bilibili 凭证 (Cookie) 才能发挥完整功能。 如果没有正确配置凭证,您可能无法获取视频字幕、评论
在开始安装前,请确保您已经了解如何获取并配置 Cookie。
🌟 功能特性
1. 视频总结 (`get_video_info`)
- 优先获取视频的 CC 或 AI 字幕
- 无字幕时自动降级为视频标题、简介和标签
- 支持多语言字幕选择(默认优先简体中文)
- 可手动指定偏好字幕语言(如
en,zh-Hant等)
2. 评论总结 (`get_video_comments`)
- 获取视频热门评论,辅助判断视频真实口碑
- 自动过滤表情占位符(如
[doge])以保持文本整洁 - 优先保留包含时间戳的评论(如
05:20),方便定位高能片段 - 支持两种详细程度:
brief: 10 条热门评论速览detailed: 50 条热门评论 + 高赞连带回复
3. 🛡️ 稳健性增强
- Cookie 过期智能检测:当字幕获取为空时自动验证登录状态,区分“无字幕视频”与“凭证失效”,并抛出明确的
COOKIE_EXPIRED错误,避免静默降级。
📋 环境要求
- Node.js: v18.0.0 或更高版本
- Bilibili 账号凭证 (Cookie)
🚀 安装方式
🖱️ Cursor
Cursor 同样原生支持 MCP,你可以通过图形界面快速添加:
- 打开 Cursor 设置:
Cursor Settings>Features>MCP Servers - 点击 + Add New MCP Server
- 填写以下信息:
- Name:
bilibili-mcp(或任意你喜欢的名字) - Type: 选择
command - Command:
npx -y @xzxzzx/bilibili-mcp(如果 Windows 遇到路径问题,可尝试cmd /k npx -y @xzxzzx/bilibili-mcp)
- Name:
- 点击 Add 保存。配置完成后,可能需要点击列表旁的刷新按钮来加载工具库。
提示:高级用户也可直接在项目根目录创建
.cursor/mcp.json配置文件。
Claude Code
方法一:通过 CLI 命令快速安装(推荐)
直接在终端运行以下命令:
claude mcp add bilibili-mcp --command "npx" --args "-y" --args "@xzxzzx/bilibili-mcp"
完成后重启 Claude Code 即可使用。
方法二:通过配置文件手动添加(高级)
- 打开 Claude Code 配置文件(通常在
~/.claude.json) - 在
mcpServers节点下添加:
{
"mcpServers": {
"bilibili-mcp": {
"command": "npx",
"args": ["-y", "@xzxzzx/bilibili-mcp"]
}
}
}
- 保存后重启 Claude Code。
Claude Desktop (桌面客户端)
Claude Desktop 支持通过全局配置文件接入 MCP 服务器:
方法一:通过配置文件手动添加
- 打开 Claude Desktop 配置文件:
- Windows 路径:
%APPDATA%\Claude\claude_desktop_config.json - macOS 路径:
~/Library/Application Support/Claude/claude_desktop_config.json - 提示:您也可以在 Claude Desktop 的 Settings -> Developer 中点击 Edit Config 直接打开该文件。
- Windows 路径:
- 在
mcpServers节点下添
Tools (2)
get_video_infoExtracts video subtitles, title, description, and tags for summarization.get_video_commentsRetrieves popular video comments with support for different detail levels.Environment Variables
BILIBILI_COOKIErequiredBilibili account cookie required for accessing subtitles and comments.Configuration
{"mcpServers": {"bilibili-mcp": {"command": "npx", "args": ["-y", "@xzxzzx/bilibili-mcp"]}}}