Skip to main content

B站 MCP Server - 查询直播状态、粉丝牌、历史评论、历史弹幕,支持直播内容 ASR+视觉分析

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bilibili_live_mcp-0.2.3.tar.gz (98.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bilibili_live_mcp-0.2.3-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file bilibili_live_mcp-0.2.3.tar.gz.

File metadata

  • Download URL: bilibili_live_mcp-0.2.3.tar.gz
  • Upload date:
  • Size: 98.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for bilibili_live_mcp-0.2.3.tar.gz
Algorithm Hash digest
SHA256 93a9895126cfe3d9497d9821c9e4f8c8a1f763eade211a0c8725337a5f9610aa
MD5 7ccdb935ffc68f66076854cf990ae868
BLAKE2b-256 bf29d6a267482121e191f7a925d3f5f5d3a02b442a8f13bdc132d6560562b41d

See more details on using hashes here.

File details

Details for the file bilibili_live_mcp-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: bilibili_live_mcp-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for bilibili_live_mcp-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9da74edff5e3ec89817aa9d3a254126450234238a97f311ba499300b08b4ee
MD5 11573349f793bd1474f2c3406313b41a
BLAKE2b-256 e588aa75e5f6d1758be91270596ffb4e7e6251d1b10ea3386ffa4d869701b229

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page