Provides comprehensive tools for interacting with Bilibili's platform, including searching videos and articles, retrieving detailed video information, fetching danmaku (bullet comments), getting video comments with nested replies, and accessing article content.
Bilibili MCP Server
基于bilibili-api和Playwright的B站MCP Server,关注于数据获取,支持多种相关操作。
工具列表
- search_videos: 搜索视频,支持关键词搜索,可指定返回数量和方法(API/网页抓取)
- search_articles: 搜索专栏文章,使用网页抓取方式获取真实数据
- get_video_info: 获取视频详细信息,包括统计数据、UP主信息、标签等(API/网页抓取)
- get_danmaku: 获取视频弹幕信息,返回XML格式数据
- get_comments: 获取视频评论,支持嵌套回复和数量控制(需要cookies)
- get_article: 获取专栏文章详细内容和相关数据
如果API获取失败,可以使用脚本方法(method = "script"
)尝试获取。
环境要求
- Python 3.8+
- pip 包管理器
使用方法
- clone 本项目
- 使用 pip 安装依赖
- 在任意 mcp client 中配置本 Server
- 在 client 中使用
快速测试
使用 MCP Inspector 进行测试:
使用示例
搜索视频
获取视频信息
获取评论
配置Cookies
如果需要获取评论功能,需要配置用户cookies:
按照提示操作即可自动保存cookies。
注意事项
- 请求频率: 已添加请求延迟,避免触发反爬机制
- Cookies: 获取评论功能需要有效的用户cookies
- 网络环境: 确保网络连接稳定
- API限制: 遵循B站API使用规范,避免过度请求
故障排除
- 412错误: 请求被拒绝
- 解决方案:检查cookies是否有效,尝试使用script方法
- 超时错误: 请求超时
- 解决方案:检查网络连接,减少请求数量
- Playwright错误: 专栏搜索失败
- 解决方案:运行
playwright install chromium
安装浏览器
- 解决方案:运行
项目结构
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables interaction with Bilibili (B站) platform through API and web scraping. Supports video search, article search, video info retrieval, comment fetching, danmaku extraction, and article content access.