polylens-bilibili
只读的 B 站公开信息 MCP 服务:读取视频、评论、字幕等数据,并用 jq 在返回前筛选裁剪,可本地或 HTTP+OAuth 远程接入。
搜索与发现:
search_videos关键词搜索视频(每批 30 条,最多 30 批,可排序)、suggest_keywords搜索联想词、get_feed首页推荐流。UP 主:
get_up_info查资料(签名、粉丝、关注、获赞、等级、认证等,可批量)、list_up_videos查投稿(每批最多 40 条,按最新/播放/收藏排序,可按关键词筛选)。视频信息:
get_video_info获取标题、作者、发布时间、简介与各项统计(可批量、可分 P)、get_parts分 P 清单、get_danmaku_counts每段弹幕数(支持?p=1-12等范围)。评论:
get_comments取主评论(热度序或时间序、游标续取、带缓存)、get_comment_replies取某条主评论下的二级评论(分页、总数、被隐藏数)。字幕:
get_subtitles逐句字幕,含起止秒数,可指定语种。jq 精简:多数工具必须传
jq,返回前筛选条目或裁剪字段以减少上下文占用。登录管理:
start_qr_login/complete_qr_login扫码登录,get_login_status/logout查询状态与退出登录。版本检查:
get_version对比运行版本与 PyPI 最新版、查用法变化。部署方式:本地 stdio(uvx / Claude Code / Claude Desktop)或 HTTP + OAuth 远程连接器接入。
Reads public information from Bilibili, with tools for searching videos and keyword suggestions, listing an UP主's uploads, fetching UP主 profiles, home feed recommendations, video details, multi-part video lists, danmaku, comments and comment replies, subtitles, and video frame snapshots; some features (comments, subtitles, frames) require Bilibili login via QR code.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@polylens-bilibili 在B站搜索原神,看看有哪些热门视频"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
polylens-bilibili-mcp
读取 B 站视频、评论、字幕等公开信息的 MCP 服务,支持用 jq 在返回前筛选和裁剪结果,可本地运行,也可通过 HTTP + OAuth 远程接入。只读,不向平台写入任何数据。
工具
工具 | 说明 |
| 按关键词搜索视频,每批 30 条,最多 30 页 |
| 搜索框联想词 |
| 首页推荐流,每批 30 条 |
| UP 主资料:签名、粉丝、获赞、等级、认证等,可一次查多个 |
| UP 主投稿,每批最多 40 条,可按最新、播放、收藏排序 |
| 标题、作者、发布时间、简介与各项统计,可一次查多个视频或分 P |
| 分 P 清单,可一次查多个视频 |
| 每个分 P 的弹幕数,可一次查多个视频, |
| 主评论,热度序或时间序,游标续取 |
| 某条主评论下的二级评论 |
| 逐句字幕,含起止秒数,可指定语种 |
| 扫码登录 |
| 查询登录状态、退出登录 |
| 运行中的版本与 PyPI 最新版本,用于判断工具说明是否为旧缓存、服务是否需要升级;传 |
Related MCP server: Bilibili MCP Server
登录
除登录相关工具与 get_version 外都需要登录,每次调用前联网核验登录状态。start_qr_login 返回二维码,用 B 站 App 扫码确认后,由 complete_qr_login 完成登录。凭据保存在 ~/.cache/polylens-bilibili/cookie(设置了 XDG_CACHE_HOME 时位于其下),logout 会删除它。
用 jq 精简返回
search_videos、list_up_videos、get_feed、get_video_info、get_up_info、get_parts、get_danmaku_counts、get_comments、get_comment_replies、get_subtitles 必须传 jq 参数,在返回前筛选条目或裁剪字段,减少上下文占用。表达式由模型自行编写,传 . 则原样返回,例如:
用途 | 表达式 |
字幕只要文本 |
|
只看第 10 到 15 分钟的字幕 |
|
搜索结果只留高播放量 |
|
安装
需要 uv,没有 Python 3.13+ 时 uv 会自动下载。
接入 Claude Code:
claude mcp add polylens-bilibili -- uvx polylens-bilibili-mcp接入 Claude Desktop,在 claude_desktop_config.json 中加入:
{
"mcpServers": {
"polylens-bilibili": {
"command": "uvx",
"args": ["polylens-bilibili-mcp"]
}
}
}升级:重启客户端,uvx 启动时会取最新版本。
从源码运行
git clone https://github.com/liu-xindi/polylens-bilibili-mcp.git
cd polylens-bilibili-mcp && uv sync
claude mcp add polylens-bilibili -- uv run --directory /绝对路径/polylens-bilibili-mcp polylens-bilibili-mcp升级:git pull && uv sync。
远程访问(HTTP + OAuth)
供 claude.ai 网页端或手机端以连接器接入。服务以 Streamable HTTP 运行并内置 OAuth,默认只监听本机,需由反向代理以 HTTPS 暴露到公网地址。
POLYLENS_BILIBILI_TRANSPORT=http \
POLYLENS_BILIBILI_PUBLIC_URL=https://example.com \
POLYLENS_BILIBILI_AUTH_SECRET='<口令>' \
uvx polylens-bilibili-mcp然后在 claude.ai 添加连接器,URL 填 https://example.com/mcp,首次授权时在同意页输入上面的口令。
环境变量 | 命令行 | 默认 | 说明 |
|
|
|
|
|
|
| 监听地址 |
|
|
| 监听端口 |
|
| 无 | 公网地址 |
| 无 | 无 | 机主口令 |
| 无 | 否 | 关闭鉴权,仅限本机调试 |
| 无 | 无 | 取字幕用的 HTTP 代理,如 |
命令行优先于环境变量。http 模式下公网地址和口令缺一则拒绝启动。开启 INSECURE_NO_AUTH=1 后任何能连到端口的人都能调用全部工具,包括使用已保存的登录凭据。
评论限速
平台会拦截频繁的请求,被拦后约 15 分钟恢复。为此:
评论每分钟最多 30 页,超出时排队等待。
被拦后评论工具停用 15 分钟,恢复后自动可用,其他工具不受影响。
评论结果按整次调用缓存:除 jq 外参数相同的调用直接返回缓存,不占额度,被拦期间也能返回。只缓存完整的结果,不设有效期,总量超过约 50 MB 时淘汰最久没用的,服务重启后清空。
弹幕数按分段缓存,与评论共用上述上限,
refresh重取。
免责声明与许可证
本工具供个人学习与研究使用。需要登录的功能以使用者本人的凭据,在其账号权限范围内访问,不绕过付费墙或内容保护。所获内容版权归原发布方,使用者须自行遵守法律、平台条款与版权规定,并承担使用后果。
以 Apache License 2.0 授权,按现状提供,不附任何担保。
Available Tools
16 toolscomplete_qr_loginC
取回凭据并写入本地。
(finish QR code login, poll QR status)
Inputs: key (required), description (required). Returns: status, message
get_comment_repliesARead-only
二级评论按时间正序排列。
total 是该主评论下平台能列出的二级评论总数,可用来算页数。 withheld 是该主评论下平台未列出的二级评论条数(已删除或被折叠)。 某条主评论取不到(评论不存在、不属于这个视频)时只在它的 error 里说明,其他照常返回。 中途被风控或限流时,已取完的照常返回,其余的 error 里说明原因。 parent_id 为空表示直接回复主评论,否则是所回复的那条二级评论的 id。 parent_id 指向的二级评论不在列表里时,那条被平台隐藏了,取不到。 除 jq 外参数相同的调用返回同一结果,from_cache 表示是否来自缓存; 被限速的不完整结果不缓存,要新数据用 refresh。 调用没收到结果时服务端仍会取完,之后用相同参数再取直接用缓存。 image_urls、link_titles 是字符串,多个时以换行分隔。
(comment replies, sub-replies, thread)
Inputs: jq (required), pages (required), video (required), comment_ids (required), +3 more. Returns: results, video_id, cached_at, elapsed_s, +1 more
get_commentsARead-only
不含二级评论,二级评论通过 get_comment_replies 获取。
image_urls、link_titles 是字符串,多个时以换行分隔。
(video comments)
Inputs: jq (required), count (required), video (required), description (required), +4 more. Returns: count, message, comments, has_more, +6 more
get_danmaku_countsARead-only
每个视频一组,每段一行,段号看 page。不写 ?p= 取全部分段。
danmaku_count 由平台封顶,分段越长上限越高(如约 8 分钟的为 2000、约 30 分钟的 为 6000、45 分钟以上的为 12000),达到上限时实际弹幕更多。 按段缓存,cached_at 非空表示来自缓存及其抓取时间,要新数据用 refresh。 调用没收到结果时服务端仍会取完,之后再取直接用缓存。
(danmaku count per part)
Inputs: jq (required), videos (required), description (required), refresh. Returns: results, elapsed_s
get_feedARead-only
B 站首页推荐流,每批最多 30 条。
(homepage feed, recommendations, browse)
Inputs: jq (required), description (required). Returns: feed, count, jq_count, elapsed_s
get_login_statusBRead-only
联网向平台核验。
is_login 为 null 表示无法验证,与 false 不同。
(login status)
Inputs: description (required). Returns: is_login
get_partsCRead-only
即分 P,每个视频一组。单段视频返回一项。(video parts, pages)
Inputs: jq (required), videos (required), description (required). Returns: results, elapsed_s
get_subtitlesCRead-only
逐句返回。字幕可能为 AI 生成或机器翻译,存在误差。
(subtitles, captions, transcript)
Inputs: jq (required), video (required), description (required), lang, +1 more. Returns: lang, count, jq_count, video_id, +3 more
get_up_infoCRead-only
含昵称、签名、等级、粉丝数、关注数、总获赞、认证、大会员等。
(uploader profile, channel info, followers)
Inputs: jq (required), authors (required), description (required). Returns: count, failed, authors, jq_count, +1 more
get_versionBRead-only
本说明对应版本 0.13.0。running 与之不同表示工具说明是旧缓存:可把 0.13.0 传入 since 查看之后的用法变化。工具定义里没有的参数也可照传;工具列表里没有的工具需重连才能使用。running 低于 latest 表示服务未升级。latest 查不到时为 null。(server version)
Inputs: since, description. Returns: latest, changes, running
get_video_infoBRead-only
含标题、作者、发布时间、简介与各项统计。
统计口径:评论数含二级评论;弹幕数与整片时长是全部分段之和, 当前段时长只算这一段。单段视频忽略 ?p=,current_page 为空。 staff 仅联合投稿有值,格式为"名字(角色,mid)",以分号分隔。
(video info, metadata, stats)
Inputs: jq (required), videos (required), description (required). Returns: count, failed, videos, jq_count, +1 more
list_up_videosBRead-only
每批最多 40 条。total 是视频总数,带 keyword 时为匹配数。
(uploader videos, channel uploads, other videos by this author)
Inputs: jq (required), author_url (required), description (required), order, +2 more. Returns: count, total, author, videos, +5 more
logoutB
删除本地保存的凭据。(log out, sign out)
Inputs: description (required). Returns: deleted, message
search_videosARead-only
每批最多 30 条,最多翻 30 批。
结果已滤掉付费课程,一批可能不满 30 条。summary 是平台截断过的简介, 完整简介通过 get_video_info 获取。
(search videos, find video by keyword)
Inputs: jq (required), keyword (required), description (required), order, +1 more. Returns: count, results, has_more, jq_count, +2 more
start_qr_loginARead-only
返回内联二维码图片和对应的链接 url。不写入本地凭据,由 complete_qr_login 写入。
(QR code login)
Inputs: description (required).
suggest_keywordsARead-only
B 站搜索框的联想词,最多 10 条。
平台联想时会忽略 + # 等符号。
(search suggestions, autocomplete, related keywords)
Inputs: term (required), description (required). Returns: count, elapsed_s, suggestions
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Each tool targets a distinct resource or action: search/discovery (suggest_keywords, search_videos, get_feed, list_up_videos), video facets (info, parts, subtitles, danmaku counts), comments (top-level vs replies), user profile, and a clean login lifecycle. The descriptions clarify boundaries (e.g. suggest_keywords is autocomplete, search_videos does actual search), so an agent should select correctly.
All names are snake_case and verb-first (get_, list_, search_, suggest_, start_, complete_), with only the natural exception of logout. The pattern is predictable and readable throughout.
16 tools is slightly above the ideal 3-15 band but justified by the broad domain (search, video metadata, comments, replies, subtitles, parts, danmaku, user, feed, login). No obvious filler tools; each has a role.
Core read paths (search, video info, comments/replies, subtitles, parts, danmaku counts, user, feed, login) are covered, but notable gaps exist: no danmaku content retrieval despite counts, no write actions (post comment), no account-specific reads (favorites/history/following), and no video stream URL. These will cause dead ends for agents expecting a full Bilibili client.
Maintenance
Related MCP Connectors
Bilibili (B站) data without login: video stats, comments, danmaku, creators, trending, hot searches.
Bilibili videos for AI agents: search, creators, trending, stats, tags and danmaku comments.
Track Bilibili creators and get the latest updates on videos, dynamics, and articles. Fetch user p…
Bilibili public video, article, dynamic, creator, comments, reactions, and transcript tools.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAn MCP server that enables users to search Bilibili videos, access trending rankings, and retrieve detailed information about videos, content creators, and anime schedules. It allows AI applications to interact directly with Bilibili content via simple API interfaces.102 npm198MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server powered by public Bilibili APIs so AI agents can search videos and read public video and creator metadata.MIT
- AlicenseNot gradedqualityDmaintenanceEnables retrieving Bilibili video metadata, part lists, and timestamped official/AI subtitle transcripts through MCP tools, without downloading videos.MIT
- AlicenseAqualityCmaintenanceEnables AI clients to query and download Bilibili video data, including metadata, streams, danmaku, subtitles, comments, search, hot lists, users, live rooms, and account read-only items through MCP tools.151MIT