bilibili-mcp
A Model Context Protocol server that provides tools for parsing and retrieving Bilibili video information, including video details, download links, and collection listings.
README
Bilibili MCP Server
一个用于解析哔哩哔哩(Bilibili)视频的 Model Context Protocol (MCP) 服务器,支持视频信息提取、下载链接获取和合集解析等功能。
功能特性
- ✅ 解析 Bilibili 视频链接(支持 b23.tv 短链接)
- ✅ 获取视频详细信息(标题、封面、简介、用户信息等)
- ✅ 获取视频下载链接(1080P 画质)
- ✅ 支持合集视频解析
- ✅ 获取合集视频列表
安装
方式一:使用 npx(推荐)
无需安装,直接运行:
{
"mcpServers": {
"bilibili": {
"command": "npx",
"args": ["-y", "mcp-server-bilibili"]
}
}
}
方式二:全局安装
npm install -g mcp-server-bilibili
然后在配置文件中使用:
{
"mcpServers": {
"bilibili": {
"command": "mcp-server-bilibili"
}
}
}
方式三:从源码运行
# 克隆仓库
git clone https://github.com/fysh1010/bilibili-mcp.git
cd bilibili-mcp
# 安装依赖
npm install
# 构建
npm run build
然后在配置文件中使用:
{
"mcpServers": {
"bilibili": {
"command": "node",
"args": ["E:\\path\\to\\bilibili-mcp\\build\\index.js"]
}
}
}
配置 Claude Desktop
Windows
-
打开 Claude Desktop 配置文件:
%APPDATA%\Claude\claude_desktop_config.json -
添加以下配置:
{
"mcpServers": {
"bilibili": {
"command": "npx",
"args": ["-y", "mcp-server-bilibili"]
}
}
}
- 重启 Claude Desktop
macOS
-
打开 Claude Desktop 配置文件:
~/Library/Application Support/Claude/claude_desktop_config.json -
添加以下配置:
{
"mcpServers": {
"bilibili": {
"command": "npx",
"args": ["-y", "mcp-server-bilibili"]
}
}
}
- 重启 Claude Desktop
Linux
-
打开 Claude Desktop 配置文件:
~/.config/Claude/claude_desktop_config.json -
添加以下配置:
{
"mcpServers": {
"bilibili": {
"command": "npx",
"args": ["-y", "mcp-server-bilibili"]
}
}
}
- 重启 Claude Desktop
可用工具
1. parse_bilibili_video
解析 Bilibili 视频链接,获取完整信息。
参数:
url(必填): Bilibili 视频链接,支持 b23.tv 短链接
示例:
请解析这个 Bilibili 视频:https://b23.tv/XhtfoyZ
返回数据:
{
"code": 200,
"msg": "解析成功!",
"data": {
"title": "视频标题",
"cover": "封面图片URL",
"description": "视频简介",
"url": "视频下载链接",
"user": {
"name": "UP主名称",
"avatar": "UP主头像URL"
},
"videos": [
{
"title": "视频标题",
"duration": 视频时长(秒),
"durationFormat": "04:45:58",
"url": "视频下载链接",
"index": 1
}
],
"totalVideos": 2
}
}
2. get_bilibili_video_info
获取 Bilibili 视频的详细信息。
参数:
url(必填): Bilibili 视频链接
示例:
获取这个视频的详细信息:https://b23.tv/XhtfoyZ
3. get_bilibili_download_urls
获取 Bilibili 视频的下载链接列表。
参数:
url(必填): Bilibili 视频链接
示例:
获取这个视频的下载链接:https://b23.tv/XhtfoyZ
4. get_bilibili_basic_info
获取 Bilibili 视频的基本信息。
参数:
url(必填): Bilibili 视频链接
示例:
获取这个视频的基本信息:https://b23.tv/XhtfoyZ
5. get_bilibili_collection
获取 Bilibili 合集中的所有视频列表信息。
参数:
url(必填): Bilibili 视频链接(合集链接)
示例:
获取这个合集的所有视频:https://b23.tv/XhtfoyZ
使用示例
示例 1:解析单个视频
用户输入:
帮我解析这个 Bilibili 视频:https://b23.tv/XhtfoyZ
Claude 会自动调用:
parse_bilibili_video工具
返回结果: 视频的完整信息,包括标题、封面、下载链接、UP主信息等。
示例 2:获取下载链接
用户输入:
获取这个视频的下载链接:https://b23.tv/XhtfoyZ
Claude 会自动调用:
get_bilibili_download_urls工具
返回结果: 视频下载链接列表,包括合集中的所有视频。
示例 3:查看合集视频
用户输入:
这个合集有哪些视频?https://b23.tv/XhtfoyZ
Claude 会自动调用:
get_bilibili_collection工具
返回结果: 合集中的所有视频列表,包括每个视频的标题和时长。
测试
使用 MCP Inspector 测试工具:
npm run inspector
这会启动一个交互式测试界面,您可以测试所有可用的工具。
开发
项目结构
bilibili-mcp/
├── src/
│ ├── BilibiliApi.ts # Bilibili API 封装层
│ └── index.ts # MCP 服务器主入口
├── build/ # 编译输出目录
├── package.json # 项目配置
├── tsconfig.json # TypeScript 配置
└── README.md # 项目说明
构建项目
npm run build
监听模式开发
npm run watch
API 说明
本 MCP Server 使用第三方 API:https://api.bugpk.com/api/bilibili
支持的特性:
- ✅ 解析 Bilibili 短视频
- ✅ 画质为 1080P
- ✅ 支持合集视频
- ✅ 支持 b23.tv 短链接
注意事项
- 视频链接格式:支持完整的 Bilibili 链接和 b23.tv 短链接
- 画质限制:当前仅支持 1080P 画质
- API 限制:使用第三方 API,可能会有调用频率限制
- 版权说明:请遵守 Bilibili 的用户协议和版权规定,仅用于个人学习和研究目的
故障排除
问题:无法连接到 MCP Server
解决方案:
- 检查 Claude Desktop 配置文件是否正确
- 确认网络连接正常
- 查看 Claude Desktop 日志获取详细错误信息
问题:解析视频失败
解决方案:
- 确认视频链接格式正确
- 检查视频是否为公开视频
- 确认第三方 API 服务是否正常
问题:npx 命令执行缓慢
解决方案:
- 使用全局安装方式:
npm install -g mcp-server-bilibili - 或者从源码运行
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
联系方式
- GitHub: https://github.com/fysh1010/bilibili-mcp
- Issues: https://github.com/fysh1010/bilibili-mcp/issues
致谢
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.