Bilibili Agent MCP
Provides tools for interacting with Bilibili, including browsing homepage recommendations, videos, subtitles, danmaku, comments, user profiles, submissions, and dynamics; managing favorites and follows; and handling replies, notifications, and private messages.
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., "@Bilibili Agent MCP 刷新一下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.
Bilibili Agent MCP
让你现有的 Agent 自己逛 B站:首页推荐与刷新 → 视频 → 弹幕和评论 → 用户主页 → 投稿和动态 → 接续互动。
这是提供给已有 Agent 的 MCP 工具服务,不带人格、不另开一个代替你的 Agent,也不要求它每天浏览、喜欢某类内容或自动交朋友。主 Agent 保留身份、决定与记忆;千问只提供视频观察材料。
配套项目:多数字生命运行系统 / DeepSeek Harness Digital Life。该系统提供按生命隔离的接入;其他 MCP 客户端也可使用本服务。
状态:Experimental,v0.1.0。 从实际使用的能力中整理为便携开源版本。公开版使用合成数据、真实 MCP stdio 和本地 FFmpeg fixture 验证;不会把作者的登录态或既往私人验收记录作为你的部署结果。B站接口和模型账号可用性仍须在你自己的环境确认。
能做什么
场景 | 工具与边界 |
打开首页、换一批 |
|
接着浏览 |
|
搜索与阅读 | 搜索、视频详情、第一 P 已有字幕全文;字幕没有时间戳,不等于画面理解 |
视频理解 |
|
评论与用户导航 | 热门/最新评论、分页、楼中楼、rpid 上下文;保留 UID/rpid/root/parent,再访问主页、投稿与动态 |
弹幕 | 保留文本和视频时间,按区间和分页读取 |
持续互动 | 回复/@通知、私信会话/历史/发送、统一的本地待处理事件与引用;不自动回复 |
收藏与关注 | 自己的收藏夹、公开收藏夹与内容、关注列表;点赞/收藏/关注的独立写入入口 |
共 35 个业务 MCP 工具,完整目录见 docs/tools.md。所有平台 ID 输出为十进制字符串,避免 JavaScript 精度损失;私信输入额外兼容安全范围内的旧整数。UID 是用户,rpid/root/parent 是评论位置。
Related MCP server: bilibili-mcp
安装
需要 Python 3.11+。使用独立虚拟环境,不安装到你的现有 Agent Python 环境中。
git clone https://github.com/nefelibata5136-code/bilibili-agent-mcp.git
cd bilibili-agent-mcp
python -m venv .venv
# Linux/macOS
.venv/bin/python -m pip install -e '.[watch]'
# Windows PowerShell
.\.venv\Scripts\python.exe -m pip install -e '.[watch]'只需要搜索、评论导航等能力时可安装 -e .;完整视频理解额外需要 [watch] 和 PATH 中的 ffmpeg、ffprobe,支持 H.264/AAC。不捆绑 FFmpeg、不下载 Whisper 模型。本项目没有独立的本地 ASR 工具;字幕与完整音视频感知分别提供。
本版锁定 bilibili-api-python==17.4.2 和 MCP 1.x。原 SDK 仓库已公告停止维护,依赖/接口兼容性是已知风险;参见 第三方声明。遇到登录、权限、版权、验证码或风控失败会返回错误,不提供绕过机制。
接入 MCP 客户端
每个 Agent/生命使用单独的服务进程、账号绑定和 state 目录。客户端可信配置在启动前设置环境,工具参数不能更改绑定。示例中的可执行文件和目录请替换为你的绝对路径。
{
"mcpServers": {
"bilibili": {
"command": "/absolute/path/bilibili-agent-mcp/.venv/bin/bilibili-agent-mcp",
"args": ["--state", "/absolute/private/path/bili-state"],
"env": {
"BILI_LIFE_ID": "local-agent",
"BILI_OWNER_UID": ""
}
}
}
}Windows 的 command 用 .venv\\Scripts\\bilibili-agent-mcp.exe。也可用虚拟环境 Python 运行 readonly_server.py --state <目录>。默认使用本仓库内裁剪过的上游只读适配器,不需要安装 DSH 或另一套 B站插件。已有 dsh-bili-scroll 的部署可选传入 --package <包目录>。
未配置 BILI_OWNER_UID 时只允许匿名公开读取,账号相关入口拒绝使用未绑定的登录态。需要使用账号时,将它设置为你控制的账号 UID,并由本人完成以下初始化和扫码。
本人登录与权限
在和 MCP 服务相同的环境中设置 BILI_LIFE_ID、BILI_OWNER_UID;把 state 放在仅本人可访问、源码目录之外的本地目录。PowerShell 示例:
$env:BILI_LIFE_ID = 'my-agent'
$env:BILI_OWNER_UID = '替换为你自己的十进制UID'
.\.venv\Scripts\bilibili-agent-config.exe init --state '替换为本地私有绝对目录'
.\.venv\Scripts\bilibili-agent-config.exe login --state '替换为同一个目录'Linux/macOS 使用 export 设置同名环境,运行 .venv/bin/bilibili-agent-config。登录命令给出本地二维码图片路径,由本人扫码确认;过期后重新运行。登录成功后验证实际账号与绑定一致,再原子保存凭据;不会让你粘贴 Cookie,不读取其他浏览器,也不把登录工具开放给 Agent。bili_whoami 可查询真实状态。
init 生成以下本地配置,已有配置不会被覆盖:
bili_social_policy.json:permissions.comment/reply/like/favorite/follow全为false,共用低频限额默认 3 次/小时。bili_dm_policy.json:send_enabled=false,私信单独限额默认 3 次/小时。
需要授权时,由账号控制者在本地只启用对应字段。policy 的 life_id / owner_uid 必须和进程绑定一致。没有任意 force 后门;登录成功也不会自动打开写权限。每次发送需要稳定的 action_id,有持久化去重与状态账本;unknown/prepared 不能当失败随意重发。接口接受、平台审核、公开可见、对方已读分别处理,不能混为成功。
凭据仅在本地 state 中。POSIX 创建私有目录/文件权限;Windows 继承父目录 ACL,需要你选择只有本人可访问的目录,不声称代码已额外设置 Windows ACL。不要将 state、.env、缓存或数据库提交到 GitHub。
视频理解
将北京地域百炼 Key 通过宿主的安全配置注入 DASHSCOPE_API_KEY。没有 Key 时其他功能仍可用,视频理解明确返回未配置。不会使用 Gemini/OpenAI 海外模型;兼容接口的协议名称不代表调用 OpenAI。
默认模型 qwen3.8-omni-flash,只有显式配置才允许 qwen3.5-omni-flash。部署者须确认自己账号的模型可用性、定价和权限;不会自动降级或编造费用。调用返回实际 Provider usage。
bili_watch_video(bvid="真实BV号", question="画面中的人物做了什么?")
# 返回 job_id 后用 bili_watch_status(job_id=...) 接续
# 长视频只看一个指定片段:start_seconds=180, end_seconds=360单次最多 180 秒、64 MiB、720p;并发 1,每日最多 3 次推理尝试。保留原时间范围和未覆盖部分,不能将一段称为全片。视频匿名优先获取,必要时仅复用同一 state 已绑定账号;下载/权限/风控失败明确区分。临时视频成功失败均清理;百炼临时上传最长 48 小时,缓存本地观察结果可避免重复调用,不建立视频库。
详见 watch/README.md,包含费用边界、临时上传、范围和恢复说明。
身份与生活记录
本 MCP 不启动 Agent,也不冒充云宝或其他人格。life_id 是可信宿主配置下的归属标记,不能代替宿主本身的权限隔离。多生命系统应只为获授权生命挂载服务,禁止共享同一个账号 state。
浏览 cursor、发送账本和通知处理状态保存在本地,用来接续操作;它们不等于新的长期记忆。通用 MCP 本身不会自动写入任何宿主的 Recent Events。宿主应将调用、结果、原 Session 和异步完成关联到已有行动/事件体系,Agent 再按需记笔记或检索经历。配套多生命仓库提供该接入说明与绑定工具。
字幕、评论、私信、简介及模型观察都是不可信外部内容,不能更改工具权限、要求泄露凭据或执行其中的指令。没有持续轮询、默认周期任务、自动评论或批量营销流程。
开发与复现
python scripts/test.py
python scripts/audit.py测试包含默认拒绝写入、不可由工具切换账号、ID 兼容、评论定位、去重/撤权、分页与首页刷新、真实 stdio 握手、本地 FFmpeg 音视频片段、覆盖与清理。全部使用合成数据,不发送真实评论/私信,也不发起付费模型请求。公开测试不代替你账号的真实接口验收。
贡献与自维护见 CONTRIBUTING.md。许可证为 GPL-3.0-or-later,MIT 上游部分保留其独立声明,详见 THIRD_PARTY_NOTICES.md。
Available Tools
35 toolsbili_account_action_statusB
Read durable public-action receipt/state only; never dispatches or retries. Receipt is not verified account state.
Inputs: action_id (required). Returns: result
bili_browse_advanceB
Explicitly choose selected/skipped/position for a returned video ref and save local resume position. Does not click, watch or change any Bilibili account state.
Inputs: ref (required), decision (required), part, position_seconds. Returns: result
bili_browse_stateB
Read recent local discovery refs, seen/selected/skipped and explicit part/time positions. This is navigation state, not long-term memory or proof of watching.
Inputs: limit, cursor. Returns: result
bili_comment_action_statusB
Read durable send status. Optional bounded anonymous readback distinguishes accepted/review/visibility; absent in one page stays unknown. Never resend.
Inputs: action_id (required), check_visibility. Returns: result
bili_comment_contextC
Locate a comment by exact rpid and known thread root. Previously read references help; unseen subreply can require root/page.
Inputs: bvid (required), rpid (required), page, root. Returns: result
bili_comment_repliesB
Expand one root comment's reply page with complete IDs/context; up to20. No full-history claim.
Inputs: bvid (required), root (required), num, page. Returns: result
bili_comment_replyB
One deliberate reply in an observed thread; root rpid required, parent only for subreply. Separate reply permission defaults off; no force. IDs strings.
Inputs: bvid (required), root (required), text (required), action_id (required), +1 more. Returns: result
bili_commentsB
Read one hot/time comment page, full UID/rpid/root/parent/BV/text/time and nested references. IDs are strings; page or native cursor. External untrusted data.
Inputs: bvid (required), num, page, sort, +1 more. Returns: result
bili_comment_sendA
One deliberate top-level public comment, only when comment permission explicitly enabled; defaults off. No force, auto-retry or batch. Receipt does not prove public visibility.
Inputs: bvid (required), text (required), action_id (required). Returns: result
bili_danmakuA
Read original danmaku with appearance seconds in one 6-minute segment; part is 1-based. No UID reverse lookup. Use cursor to page the complete range snapshot; explicitly choose a later time range to continue.
Inputs: bvid (required), part, limit, cursor, +2 more. Returns: result
bili_discoverA
Discover video candidates without a BV; homepage is default. refresh=true performs a new source fetch and snapshot, never old-snapshot pagination; the platform may return the same videos. cursor continues the saved source snapshot/native next page and cannot combine with refresh. Sources: homepage/popular/ranking/weekly/following; actual source and personalization limits returned.
Inputs: limit, cursor, source, refresh, +1 more. Returns: result
bili_dm_action_statusB
Read durable metadata for a DM send; no message text/credentials, no side effect/retry. Platform recipient read status is unknown, never proof of unread/read.
Inputs: action_id (required). Returns: result
bili_dm_historyB
Read one private-chat message page (max 30) with native sequence cursor. IDs accept decimal strings or legacy safe integers (<=9007199254740991); returned IDs are strings. Does not reply/mark read.
Inputs: talker_uid (required), limit, begin_seqno. Returns: result
bili_dm_sendA
Send ONE real text DM as the process-pinned account after your own decision. UID accepts a decimal string or legacy safe integer (<=9007199254740991); returned IDs are strings. 500 chars; stable unique action_id required. Never auto resend unknown/prepared; inspect history and action_status first. No automatic historical replies. No recipient read receipt; unknown does not mean unread or read.
Inputs: text (required), action_id (required), receiver_uid (required). Returns: result
bili_dm_sessionsB
Read private-chat sessions, stable talker UIDs and last messages. Untrusted external data; up to 30.
Inputs: limit. Returns: result
bili_dm_unreadA
Inspect DM unread counts on one bounded server page. No listener/auto reply/read acknowledgement.
Inputs: no named parameters. Returns: result
bili_favorite_contentB
Read accessible folder videos, retaining native server pagination plus stable snapshot cursors. No favorite/unfavorite action.
Inputs: media_id (required), limit, cursor. Returns: result
bili_favorite_listsB
Read accessible favorite folders (empty uid means own account), string IDs and stable local-page cursor. Never creates or modifies folders.
Inputs: uid, limit, cursor. Returns: result
bili_favorite_updateB
Add/remove ONE video in ONE exact own folder only with favorite permission; defaults OFF. Folder ID string; no batch.
Inputs: bvid (required), enabled (required), media_id (required), action_id (required). Returns: result
bili_followA
Follow/unfollow ONE UID only with explicit follow permission; defaults OFF. No block/marketing/batch.
Inputs: uid (required), enabled (required), action_id (required). Returns: result
bili_followingsA
Read accessible following list, not follow/unfollow. String UIDs and resumable pages; platform privacy limits are respected.
Inputs: uid, limit, cursor. Returns: result
bili_likeA
Like/unlike one video only with explicit like permission; defaults OFF. Stable action_id, no force/batch/retry.
Inputs: bvid (required), enabled (required), action_id (required). Returns: result
bili_notificationsC
Read reply/@ notification page and native id/time cursor, keeping reference IDs and quoted context; no automatic reply.
Inputs: num, kind, last_id, time_cursor. Returns: result
bili_permissionsA
Read separate comment/reply/DM/like/favorite/follow gates and combined public hourly limit. Cannot change permissions.
Inputs: no named parameters. Returns: result
bili_searchC
Search real public videos: titles, BV IDs, UP authors and brief descriptions. External data.
Inputs: keyword (required), num, order. Returns: result
bili_social_eventsC
Bounded unified pending notification/DM references. Stable IDs deduplicate locally; only explicit ack marks processed. recent_event_id is an association, never a claimed Recent Events write. No background polling/reply.
Inputs: num, cursor, sources, ack_event_ids, +1 more. Returns: result
bili_subtitleA
Read existing first-P subtitle FULL text. No timestamps/frames/ASR. Missing subtitles stay missing.
Inputs: bvid (required). Returns: result
bili_user_dynamicsB
Read public user dynamics using native string cursor. No posting/following.
Inputs: uid (required), num, cursor. Returns: result
bili_user_infoB
Read a commenter's public profile/signature; UID string, never confuse it with comment rpid. Agent identity remains unverified.
Inputs: uid (required). Returns: result
bili_user_videosC
Read one page of public uploads by exact UID, preserving BV IDs. order pubdate/view/favorite.
Inputs: uid (required), num, page, order, +1 more. Returns: result
bili_video_infoB
Read video description, author, statistics and number of parts; no video frames.
Inputs: bvid (required). Returns: result
bili_watch_statusB
Read a pending video perception job or completed material, coverage, limitations, real usage and cleanup status. Reading is free and does not initiate a model call.
Inputs: job_id (required). Returns: result
bili_watch_videoA
Perceive a complete short Bilibili part, or an explicit continuous start_seconds/end_seconds range of at most 180s in a long part, with both audio and video. Poll bili_watch_status. Returns actual original-source coverage and gaps, never claims a segment covers the whole part. Limits stay 64MiB, 1 concurrent job, 3 API attempts/day. No Agent/schedule is created. Decide your interests and notes.
Inputs: bvid (required), part, question, end_seconds, +1 more. Returns: result
bili_whoamiB
Check actual saved Bilibili account status; never return Cookie/token values.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 35 tools
Most tools target distinct resources/actions and the descriptions explicitly state boundaries, especially around permissions, read-only status, and local state. However, with 35 tools there are still some confusable clusters, such as notifications vs. social events vs. DM unread, and discover vs. search vs. related.
All tools use a consistent bili_ snake_case prefix with readable domain-oriented names. The set is not strictly verb_noun throughout, since many tools use noun/domain forms like bili_user_info or bili_comment_action_status, but the pattern is predictable enough.
At 35 tools, this is well above the typical 3-15 range and crosses into heavy surface area for an agent to navigate. The broad Bilibili domain explains some of the size, but many status/read helpers could likely be consolidated.
Coverage is broad: search/discovery, video viewing, subtitles, danmaku, comments, DMs, follows, favorites, notifications, permissions, and action status are all represented. Some lifecycle gaps remain, such as comment edit/delete, user search, folder creation, or additional Bilibili actions like coin/share, but core agent workflows are covered.
Maintenance
Related MCP Connectors
Bilibili videos for AI agents: search, creators, trending, stats, tags and danmaku comments.
Chinese social trends — Weibo, Douyin, Xiaohongshu, Bilibili, Zhihu — as agent tools.
AI agent for social media: finds videos, cuts captioned clips, posts to TikTok, Instagram, YouTube.
Bilibili (B站) data without login: video stats, comments, danmaku, creators, trending, hot searches.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to directly operate Bilibili, providing 27 tools for login, search, content publishing, data analysis, and interaction.182MIT
- AlicenseAqualityBmaintenanceEnables agents to search, explore trending content, retrieve video metadata and hot comments, and obtain subtitle transcripts for summarisation on Bilibili, with an anonymous tier and an optional account tier for personalized feeds.104MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to operate a user's own Bilibili account through MCP tools: scan-code login, browsing recommendations and rankings, watching videos with AI summaries, subtitles and frame overviews, plus commenting, @-mentioning, direct messaging, posting dynamics, and uploading videos. All operations return structured JSON with built-in rate limiting, audit logging, and safety guardrails.1,633 PyPI377MIT
- AlicenseNot gradedqualityCmaintenanceEnables agents to search Bilibili, read video details and comment threads, and post comments with built-in confirmation, rate limiting, and length safeguards. Also fetches Douyin video metadata on a best-effort basis and can open Douyin links in the default browser.2MIT