Skip to main content
Glama
bilibili-mcp
by only3412

Bilibili MCP Agent

一个可安装到本地 Agent 宿主的 Bilibili Model Context Protocol(MCP)服务器。它把 Bilibili 的搜索、视频、字幕、弹幕、评论、用户、账号、收藏、动态、专栏和直播能力整理成结构化工具,并提供显式确认的互动写入工具。

This repository is a portable local plugin package. It contains no account cookies, session tokens, gateway keys, browser profiles, build artifacts, or machine-specific paths.

Included capabilities

  • 42 MCP tools across 11 categories.

  • Public discovery: search, hot searches, popular videos, rankings, regions.

  • Video data: details, pages, statistics, related videos, tags, play URLs.

  • Subtitles and danmaku: subtitle tracks, subtitle text, XML danmaku.

  • Comments and users: comment pages, replies, public profiles, uploads, relations.

  • Personal reads: current account, history, watch later, favorites, feed.

  • Articles and live rooms: article metadata, areas, rooms, room status, play URLs.

  • Seven write tools, disabled by default and protected by per-call confirmation.

  • Chromium browser-cookie import through a one-time loopback pairing flow.

The complete machine-readable catalog is in capabilities.json.

Related MCP server: Bilibili MCP Server

Requirements

  • Python 3.12 or newer.

  • uv on PATH.

  • A Chromium-based browser is only needed for the optional cookie import flow.

Run as an Agent plugin

The root plugin.json and mcp.json are the Agent Plugins 1.0 manifests. Import the repository or package into a local plugin host that supports stdio MCP servers. The configured command is portable:

uv run --frozen --project ${PLUGIN_ROOT} bilibili-mcp

Dependencies are installed from uv.lock. Plugin hosts expand PLUGIN_ROOT and PLUGIN_DATA; the virtual environment is created in the host's writable plugin data directory, so the plugin files can remain read-only.

Use with any stdio MCP client

Add this server to a client that accepts mcpServers configuration and has uvx and Git on PATH:

{
  "mcpServers": {
    "bilibili": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/only3412/bilibili-mcp-agent@v0.1.0",
        "bilibili-mcp"
      ]
    }
  }
}

The client starts the server on demand. No API key or login is needed for public tools; import your own Bilibili session separately for personal tools. Clients with other configuration formats can use the same command and args.

Install locally

Windows PowerShell:

.\scripts\install.ps1

macOS/Linux:

./scripts/install.sh

The helpers create a repository-local virtual environment and install the editable package. The environment is ignored by Git.

Import a Bilibili session

The server can use public endpoints without login. For account-scoped tools, start the one-time browser pairing flow:

.\scripts\login-import.ps1

Then load the generated unpacked extension from the private directory shown by the command, open Bilibili in the same browser profile, and click Import. The extension sends cookies only to the local pairing port. The server calls Bilibili's nav endpoint to verify the session before replacing the previous private session file.

The private store defaults to:

Windows: %LOCALAPPDATA%\BilibiliMCP\credentials.local.json
Unix:    ~/.local/share/BilibiliMCP/credentials.local.json

Override it with BILIBILI_MCP_AUTH_FILE. The generated api_key is only a local gateway key for the optional loopback HTTP transport; it is not a Bilibili API key and is never included in this repository.

Check status without printing cookie or key values:

uv run --project . bilibili-mcp auth status

Start the server manually

stdio (the default Agent transport):

uv run --project . bilibili-mcp

Loopback Streamable HTTP:

.\scripts\run.ps1 -Http

The HTTP endpoint is http://127.0.0.1:17891/mcp and requires the generated local Bearer key. It is deliberately bound to loopback and is not a public remote MCP endpoint.

Enable the seven write tools only when needed:

.\scripts\run.ps1 -EnableWrites

Each write call still requires confirm: true and a valid bili_jct in the private session. The repository does not ship or request a credential.

Development and verification

uv sync --frozen
uv run --frozen python -m unittest discover -s tests -v
uv run --frozen python -m compileall src
uv run --frozen python scripts/export-capabilities.py
uv build

The test suite uses local doubles and does not send Bilibili write requests.

Scope and attribution

This is an independent client-side MCP adapter. Bilibili names and endpoints belong to their respective owners. Use it only where your account and the service allow the requested operation, and follow the platform's current terms and rate limits.

License

MIT. See LICENSE.

Available Tools

42 tools
bilibili_article_infoC
Read-onlyIdempotent

[专栏] 读取专栏文章公开信息。

Inputs: id (required).

bilibili_auth_statusA
Read-only

只返回本地会话状态和账号,不返回Cookie或key;verify=true会实时校验B站登录。

Inputs: verify.

bilibili_capabilitiesC
Read-only

按分类查询本MCP工具、接口与参数约束。

Inputs: category.

bilibili_comment_addB
Destructive

[互动写入] 发布一条评论/回复;视频oid为aid,回复需root和parent。

Inputs: oid (required), confirm (required), message (required), root, +2 more.

bilibili_comment_deleteB
Destructive

[互动写入] 删除当前账号自己的指定评论。

Inputs: oid (required), rpid (required), confirm (required), type.

bilibili_comment_repliesC
Read-onlyIdempotent

[评论] 读取指定根评论下的回复。

Inputs: oid (required), root (required), pn, ps, +1 more.

bilibili_commentsB
Read-onlyIdempotent

[评论] 读取视频/专栏主评论;oid使用视频aid,type=1为视频、12为专栏。

Inputs: oid (required), pn, ps, sort, +1 more.

bilibili_danmakuC
Read-onlyIdempotent

[字幕与弹幕] 读取分P公开XML弹幕,最多返回limit条。

Inputs: oid (required), limit.

bilibili_dynamic_detailC
Read-onlyIdempotent

[动态] 读取指定动态内容。

Inputs: id (required).

bilibili_favorite_foldersB
Read-onlyIdempotent

[收藏] 列出收藏夹;不传up_mid时使用当前已绑定账号。

Inputs: up_mid.

bilibili_favorite_itemsC
Read-onlyIdempotent

[收藏] 分页读取可见收藏夹中的视频。

Inputs: media_id (required), pn, ps, tid, +2 more.

bilibili_live_areasB
Read-onlyIdempotent

[直播] 读取直播分区树。

Inputs: no named parameters.

bilibili_live_playurlC
Read-onlyIdempotent

[直播] 取得当前可见直播流地址。

Inputs: room_id (required), qn, codec, format, +2 more.

bilibili_live_room_infoC
Read-onlyIdempotent

[直播] 读取直播间信息和直播状态。

Inputs: room_id (required).

bilibili_live_roomsC
Read-onlyIdempotent

[直播] 按直播分区读取直播间列表。

Inputs: parent_area_id (required), page, area_id, page_size, +1 more.

bilibili_meB
Read-onlyIdempotent

[账号] 使用当前已绑定会话核验登录并读取本人资料。

Inputs: no named parameters.

bilibili_my_feedB
Read-onlyIdempotent

[动态] 读取当前登录用户关注动态;后续分页传offset。

Inputs: type, offset.

bilibili_my_historyA
Read-onlyIdempotent

[账号] 分页读取本人观看历史;首次max/view_at=0,后续沿用响应cursor。

Inputs: ps, max, view_at, business.

bilibili_my_watch_laterB
Read-onlyIdempotent

[账号] 读取本人稍后再看列表。

Inputs: no named parameters.

bilibili_rankingB
Read-onlyIdempotent

[发现] 按分区读取排行榜;rid=0为全站。

Inputs: rid, type.

bilibili_region_onlineC
Read-onlyIdempotent

[发现] 读取分区在线/投稿统计。

Inputs: no named parameters.

bilibili_search_hotC
Read-onlyIdempotent

[发现] 读取实时搜索热词。

Inputs: limit.

bilibili_subtitlesC
Read-onlyIdempotent

[字幕与弹幕] 查询分P字幕轨道;部分AI字幕依赖登录态及平台可见性。

Inputs: cid (required), bvid (required).

bilibili_subtitle_textC
Read-onlyIdempotent

[字幕与弹幕] 读取字幕接口返回的hdslb字幕JSON,合并时间戳文本。

Inputs: url (required).

bilibili_user_feedC
Read-onlyIdempotent

[动态] 读取指定UP主公开动态。

Inputs: host_mid (required), offset.

bilibili_user_followB
Destructive

[互动写入] 关注/取消关注UP主;act=1关注、2取消。

Inputs: act (required), fid (required), confirm (required), re_src.

bilibili_user_followingsC
Read-onlyIdempotent

[用户] 分页读取用户公开关注列表;平台会限制可见范围。

Inputs: vmid (required), pn, ps.

bilibili_user_infoB
Read-onlyIdempotent

[用户] 读取UP主公开资料,自动附加WBI签名。

Inputs: mid (required).

bilibili_user_relation_statsB
Read-onlyIdempotent

[用户] 读取用户关注数、粉丝数等关系统计。

Inputs: vmid (required).

bilibili_user_videosC
Read-onlyIdempotent

[用户] 读取UP主视频投稿列表,自动附加WBI签名。

Inputs: mid (required), pn, ps, tid, +1 more.

bilibili_video_favoriteB
Destructive

[互动写入] 将视频加入/移出指定收藏夹,夹ID以逗号分隔。

Inputs: rid (required), confirm (required), type, add_media_ids, +1 more.

bilibili_video_infoB
Read-onlyIdempotent

[视频] 读取视频标题、简介、UP主、aid、cid、分P与统计。

Inputs: bvid (required).

bilibili_video_likeA
Destructive

[互动写入] 点赞/取消点赞视频;like=1点赞、2取消。

Inputs: aid (required), like (required), confirm (required).

bilibili_video_pagesB
Read-onlyIdempotent

[视频] 读取视频各分P的cid、标题与时长。

Inputs: bvid (required).

bilibili_video_playurlB
Read-onlyIdempotent

[视频] 取得当前会话可播放的临时媒体地址与清晰度;地址有时效。

Inputs: cid (required), bvid (required), qn, fnval, +1 more.

bilibili_video_statB
Read-onlyIdempotent

[视频] 读取视频播放、弹幕、评论、收藏、投币与点赞计数,从当前详情接口提取stat。

Inputs: bvid (required).

bilibili_video_tagsC
Read-onlyIdempotent

[视频] 读取视频标签。

Inputs: bvid (required).

bilibili_watch_later_addB
Destructive

[互动写入] 将视频加入稍后再看。

Inputs: aid (required), confirm (required).

bilibili_watch_later_deleteC
Destructive

[互动写入] 从稍后再看移除指定aid,逗号分隔。

Inputs: avids (required), confirm (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 42 tools

    Disambiguation4/5

    Categories and resource-oriented names make most tools easy to distinguish, including public-versus-self user tools and read-versus-write interactions. The main ambiguity is bilibili_video_info overlapping with bilibili_video_pages and bilibili_video_stat because the info tool also exposes video parts and statistics.

    Naming Consistency4/5

    Every tool uses the bilibili_ prefix and snake_case, with generally predictable resource qualifiers and suffixes such as _info, _add, and _delete. Feed/dynamic terminology and a few noun-only discovery names introduce minor variation, but there are no disruptive convention changes.

    Tool Count2/5

    At 42 tools, the surface is well beyond the recommended range and creates a substantial discovery and selection burden. Bilibili's breadth justifies many endpoints, but some narrowly split metadata and statistics tools could potentially be consolidated.

    Completeness4/5

    For its read-centric scope, workflows are strong: discovery connects to video, user, and live details, playback, subtitles, comments, and account collections, while core engagement writes are present. Coverage is more selective for management and publishing, with gaps such as favorite-folder creation/deletion, content upload, and broader history or account controls.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables interaction with Bilibili (哔哩哔哩) through its API, supporting video search and recommendations, user search, dynamic feeds, video collections, and danmaku retrieval through natural language.
      5
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      An 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 npm
      198
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables 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.
      10
      4
      MIT