bilibili-watch-mcp
An MCP server that turns Bilibili videos into agent-readable materials: subtitle text, danmaku (bullet comments), sprite keyframe contact sheets, and optional hi-res frames. Built for tool-using agents (Claude Code, Cline, etc.) that need to understand a video, not download it.
Bilibili 视频 → agent 可读材料 的 MCP server:字幕全文、弹幕、进度条关键帧拼图、可选高清抽帧。给 Claude Code 这类工具型 agent 提供"看懂视频"的能力。
Why this exists
- Most Bilibili MCP servers only expose search/metadata. The ones that expose
subtitles depend on
bilibili-api-python, which was taken down by a legal notice in 2026 and is unmaintained. This project's fetching is built on yt-dlp (actively maintained, quick to follow Bilibili's anti-bot changes) plus two signature-free endpoints for danmaku and sprite sheets — no dead dependencies. - The sprite contact sheet trick: one request returns Bilibili's own progress-bar preview thumbnails covering the whole video — no login, no video download. Good for coarse "where am I in this video" localization. Hi-res frames (854px) make on-screen code / slide text readable.
Tools
| Tool | What it does |
|---|---|
search_videos(keyword, limit) |
Login-free site search. Returns BV id, title, uploader, duration, plays. |
watch_video(video, with_frames, max_frames, subtitle_max_chars) |
Fetch one video: metadata + subtitle text inline + danmaku + sprite sheets. with_frames=True additionally downloads a low-quality stream and extracts uniform frames + scene-cut frames (854px), then deletes the video. |
video accepts a BV id or a full URL. AI-generated subtitles require the
account cookie (see BILI_SESSDATA below); CC subtitles and everything else
work login-free.
Install
pip install bilibili-watch-mcp # or: uvx bilibili-watch-mcp
Runtime dependencies (requests, yt-dlp, imageio-ffmpeg, mcp) are pulled
in automatically. No ffmpeg installation needed — imageio-ffmpeg ships a
static binary.
Configure your client
Claude Code:
claude mcp add bilibili-watch -- bilibili-watch-mcp
Or .mcp.json / claude_desktop_config.json:
{
"mcpServers": {
"bilibili-watch": {
"command": "bilibili-watch-mcp",
"env": {
"BILI_SESSDATA": "",
"BILI_WATCH_OUT": "./bili_watch_out"
}
}
}
}
Authentication (AI subtitles & better search)
Two ways to provide the Bilibili session cookie (SESSDATA), tried in order:
-
Automatic — via a debug-enabled browser (recommended). Since Chrome 136, the default profile cannot be opened with a debugging port, so use a dedicated profile. Start Chrome once, log in to Bilibili in that window; the session persists in the profile:
chrome.exe --user-data-dir="%USERPROFILE%\bili-watch-auth" --remote-debugging-port=9222 https://www.bilibili.comThe server auto-detects
127.0.0.1:9222and pullsSESSDATAover CDP on demand. Cookie values live in memory only — never written to disk, never echoed. If the debug browser is closed, tools fall back to login-free mode (danmaku/sprites/≤1080p still work; AI subtitles don't). -
Manual — environment variable. Set
BILI_SESSDATAto the cookie value from your browser's DevTools.
Note: yt-dlp cannot fetch Bilibili's AI-generated subtitles even when
authenticated, so this server additionally pulls them from the player API
directly (requires login state) and converts them to .srt.
Environment variables:
| Var | Meaning |
|---|---|
BILI_SESSDATA |
Optional. Your Bilibili session cookie value (browser DevTools → Cookies). Unlocks AI-generated subtitles. Give it only if you accept the account implications. |
BILI_WATCH_OUT |
Output directory for fetched materials. Default ./bili_watch_out. |
How an agent should use the output
watch_video returns a text report with:
- subtitle text inline — compact form: one line per minute with a
[mm:ss]timestamp, about a quarter of the raw srt size. For lecture/slide videos this alone is usually 90% of the content. Read it first. - sprite contact sheet paths — one or a few JPGs, each a 10x10 grid of thumbnails evenly covering the whole video. Cell k ≈ k × duration / total cells. Use for coarse time localization.
- frames paths (if
with_frames) —uniform_*.jpgwith a timestamp table, andscene_*.jpgat detected scene cuts. 854px wide; on-screen text (slides, code) is readable. Read these with your file/image tool.
Typical flows:
- Lecture / tutorial →
search_videos→watch_video(bvid)→ read subtitle text. - Hands-on coding demo →
watch_video(bvid, with_frames=true)→ locate the segment on sprite sheets → read nearbyframes/*.jpg.
Legal & etiquette
- Personal, low-volume use only. This project talks to Bilibili as a guest
client; abusive request rates will get your IP rate-limited (-352 / HTTP 412)
and may put your account at risk if you attach
BILI_SESSDATA. - Not affiliated with or endorsed by Bilibili. You are responsible for complying with their terms of service and local law. Bilibili has been actively sending legal notices to third-party API projects since 2026 — this project deliberately keeps its footprint minimal (yt-dlp + two signature-free endpoints) but cannot promise that never changes.
中文说明(简要)
给 agent 用的 B站视频理解 MCP。search_videos 免登录搜视频,watch_video 一键取字幕全文(直接返回文本)+ 弹幕 + 进度条关键帧拼图(粗定位画面)+ 可选高清抽帧(854px,PPT/代码可读,实操演示类用 with_frames=True)。取料底座是 yt-dlp(活跃维护、跟进B站风控),弹幕和拼图走两个免签名接口,不依赖任何已关停的第三方 SDK。
登录态(AI字幕/提高搜索成功率)推荐自动方式:开一个带调试端口的专用 Chrome 窗口并登录一次(chrome.exe --user-data-dir="%USERPROFILE%\bili-watch-auth" --remote-debugging-port=9222 https://www.bilibili.com),server 会自动经 CDP 取 SESSDATA(只在内存、不落盘);调试窗口关掉则自动降级为免登录模式。也可手动设 BILI_SESSDATA 环境变量。注意 yt-dlp 拿不到 B站 AI 字幕,本工具会登录态直连播放器接口补拉并转成 srt。仅供个人低频使用,请尊重平台条款。
License
MIT. See LICENSE.
Metadata
Release files for bilibili-watch-mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bilibili_watch_mcp-0.1.1.tar.gz | 19.5 kB | With provenance | Details for bilibili_watch_mcp-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bilibili_watch_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for bilibili_watch_mcp-0.1.1-py3-none-any.whl |
Total release size: 36.5 kB
Release files / bilibili_watch_mcp-0.1.1.tar.gz
| Download URL | bilibili_watch_mcp-0.1.1.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b23570f44ba413301a37f8c4f86e4d16a7fca9d3978b9278305962d51748a56b
|
|
BLAKE2b-256 checksum How to use checksums |
1a573ce15e084facb131bdf5a4e4c08871e9e4c36f9a0764b8d8bd14c4e269c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / bilibili_watch_mcp-0.1.1-py3-none-any.whl
| Download URL | bilibili_watch_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceb7d2776bc27454120d5533139c63584fce8404d647956767eb78545c6da36a
|
|
BLAKE2b-256 checksum How to use checksums |
22ef6d89877a8e66fc9e15cf88ac262a9f65834e185ec98d98c6c94c4f89983d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for bilibili-watch-mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bilibili_watch_mcp-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.