Skip to main content

bilibili-mcp-server

B 站 MCP Server,为 AI 助手提供查询 B 站数据的能力。

功能

Tool 描述
search_user 按用户名搜索用户,返回 UID、昵称、粉丝数等
get_live_status 查询主播直播间开播状态(未开播/直播中/轮播中)
get_user_medals 查询用户持有的粉丝牌列表
get_user_comments 查询用户历史评论记录
get_user_danmaku 查询用户在视频中发送的历史弹幕
get_user_live_danmaku 查询用户在直播间发送的历史弹幕
get_live_content 录制直播片段,ASR 语音转录 + 视觉画面分析,描述直播内容

粉丝牌、历史评论、历史弹幕数据来源于 aicu.cc,数据非实时,有更新延迟。 get_live_content 需要硅基流动 API Key,通过环境变量 SILICONFLOW_API_KEY 配置。


本地安装(Cursor / Claude Desktop)

需要 Python 3.10+ 和 uv

cd bilibili-mcp-server
uv venv
uv pip install -e .

配置到 Cursor

~/.cursor/mcp.json 或项目级 .cursor/mcp.json 中添加:

{
  "mcpServers": {
    "bilibili": {
      "command": "uv",
      "args": ["run", "--directory", "D:/projects/bilibili-mcp-server", "bilibili-mcp"],
      "env": {
        "SILICONFLOW_API_KEY": "sk-你的硅基流动Key"
      }
    }
  }
}

配置到 Claude Desktop

%APPDATA%\Claude\claude_desktop_config.json 中添加(内容同上)。


云端部署(ModelScope MCP 广场)

1. 上传代码到 ModelScope

将项目推送到 ModelScope 的 Studio 仓库(类似 Hugging Face Space)。

2. 配置环境变量 / Secret

在 ModelScope Studio 的「设置 → 环境变量」中添加:

变量名 说明
SILICONFLOW_API_KEY 硅基流动 API Key(设为 Secret,不对外展示
MCP_TRANSPORT 设为 sse(ModelScope 使用 SSE 模式)
MCP_PORT 设为 7860(ModelScope Studio 默认端口,可不填)

3. 启动命令

在 Studio 配置中设置启动命令为:

python app.py

或者使用 uv:

uv run python app.py

4. 获取 SSE 地址并在客户端配置

ModelScope 会为你的服务生成一个专属 SSE 地址,格式类似:

https://modelscope.cn/studios/你的用户名/bilibili-mcp/sse

在 Cursor / Claude Desktop 中配置远程 MCP:

{
  "mcpServers": {
    "bilibili": {
      "url": "https://modelscope.cn/studios/你的用户名/bilibili-mcp/sse"
    }
  }
}

注意:SSE URL 是你的专属地址,包含鉴权信息,请勿对外泄露。


关于 get_live_content 的 API Key

SILICONFLOW_API_KEY 的优先级:

  1. 调用工具时显式传入的 api_key 参数(最高)
  2. 环境变量 SILICONFLOW_API_KEY(推荐,在 MCP 配置或云端 Secret 中设置)

推荐做法:在 MCP 配置的 env 或云端 Secret 中配置,对话中无需每次传入 Key。


使用示例

  • "帮我查一下 xxx 主播现在有没有在直播"
  • "查一下 UID 为 12345 的用户最近发了哪些评论"
  • "xxx 用户持有哪些粉丝牌"
  • "510 直播间现在在播什么内容?"(触发 get_live_content,录制 15 秒分析)

数据说明

  • 直播状态:B 站官方 API,实时数据,无需登录
  • 粉丝牌、历史评论、历史弹幕:aicu.cc,非实时,有更新延迟
  • 直播内容分析:ffmpeg 录制 + 硅基流动 SenseVoiceSmall(ASR)+ Qwen3-VL(视觉),需 API Key

Release files for bilibili-live-mcp 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bilibili-live-mcp 0.2.4
File Size Uploaded
bilibili_live_mcp-0.2.4.tar.gz 99.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bilibili-live-mcp 0.2.4
File Interpreter ABI Platform
bilibili_live_mcp-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 114.7 kB

Release files / bilibili_live_mcp-0.2.4.tar.gz

Download URL bilibili_live_mcp-0.2.4.tar.gz
Size 99.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0df7a8c7b1365d3559ad43a3d953c25236cbe4d990cff4585e55e2c90580d5a9
BLAKE2b-256 checksum
How to use checksums
e3c2137b6486e5cf1016039d9ed76b44398a5279dd0a479c0e4e8c1f46b79b42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / bilibili_live_mcp-0.2.4-py3-none-any.whl

Download URL bilibili_live_mcp-0.2.4-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb5e3613b07e279307837f498e13c9c6799d61bfd2553c47788e68fab2bcfcea
BLAKE2b-256 checksum
How to use checksums
d8c683b939f7538db91c365208568a473a3e66bd02a0e674690f93e7678c778e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page