Bilibili Comments MCP
Enables retrieval of comments from Bilibili videos and dynamic posts with support for pagination, sorting, and nested replies in both Markdown and JSON formats.
README
Bilibili-Comments-MCP
一个基于 Model Context Protocol (MCP) 的 B 站视频评论获取工具.
快速开始
1. clone本项目
git clone https://github.com/222wcnm/Bilibili-Comments-MCP.git
cd Bilibili-Comments-MCP
2. 安装依赖
npm install @modelcontextprotocol/sdk axios
3. 配置客户端(如Claude客户端)
在 MCP 客户端的配置文件中添加:
{
"mcpServers": {
"bilibili-comments": {
"command": "node",
"args": ["/path/to/bilibili_mcp.js"],
"env": {
"BILIBILI_SESSDATA": "your_bilibili_sessdata_here"
}
}
}
}
环境变量
配置方式
-
BILIBILI_SESSDATA:Bilibili Cookie 中的 SESSDATA 值。- 获取方式:登录 Bilibili 网站,打开浏览器开发者工具 (F12),在 Network (网络) 选项卡中刷新页面,找到任意一个
bilibili.com的请求,在 Request Headers 中找到 Cookie,提取SESSDATA=xxx部分的值。
- 获取方式:登录 Bilibili 网站,打开浏览器开发者工具 (F12),在 Network (网络) 选项卡中刷新页面,找到任意一个
工具功能
get_video_comments
获取 B 站视频评论,支持分页、排序和楼中楼回复。
参数:
bvid/aid- 视频ID(二选一)page- 页码,默认1pageSize- 每页数量(1-20),默认20sort- 排序:0按时间,1按热度includeReplies- 是否包含楼中楼回复,默认trueoutputFormat- 输出格式:markdown 或 json,默认markdowncookie- B站Cookie(可选)
示例(Markdown格式):
{
"bvid": "BV1xx411c7mD",
"page": 1,
"pageSize": 20,
"sort": 1,
"includeReplies": true,
"outputFormat": "markdown"
}
示例(JSON格式):
{
"bvid": "BV1xx411c7mD",
"page": 1,
"pageSize": 20,
"sort": 0,
"includeReplies": false,
"outputFormat": "json"
}
get_dynamic_comments
获取 B 站动态评论,支持分页和楼中楼回复。
参数:
dynamic_id- 动态ID(必需)page- 页码,默认1pageSize- 每页数量(1-20),默认20includeReplies- 是否包含楼中楼回复,默认trueoutputFormat- 输出格式:markdown 或 json,默认markdowncookie- B站Cookie(可选)
示例:
{
"dynamic_id": "123456789",
"page": 1,
"pageSize": 10,
"includeReplies": true,
"outputFormat": "markdown"
}
Cookie 获取
- 登录 B 站网页版
- 打开开发者工具 (F12)
- 切换到 Network 标签
- 刷新页面,找到任意请求
- 复制 Request Headers 中的 Cookie 值
动态ID获取方法
- 在B站手机App中打开想要获取评论的动态
- 点击分享按钮
- 选择"复制链接"
- 链接格式通常为:
https://t.bilibili.com/动态ID - 提取链接中的数字部分作为dynamic_id参数
常见问题解决
动态评论获取失败
- 错误代码-404: 动态不存在或已被删除,请检查dynamic_id是否正确
- 错误代码-101: Cookie已过期,请重新获取并更新SESSDATA
- 错误代码-403: 访问权限不足,某些动态可能需要登录才能查看评论
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.
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.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.
E2B
Using MCP to run code via e2b.