Bilibili MCP Server logo

Bilibili MCP Server

Community
L-Chris

这个MCP服务器提供了搜索和交互B站(哔哩哔哩)内容的功能,包括视频搜索、字幕获取和视频信息查询等。

PublisherL-Chris
Repositorybilibili-mcp
LanguagePython
Forks
4
Stars
21
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    Bilibili MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    21 stars and 4 forks from the linked repository.

Bilibili MCP 服务器

English | 中文

这个MCP服务器提供了搜索和交互B站(哔哩哔哩)内容的功能,包括视频搜索、字幕获取和视频信息查询等。

现在同时提供两种服务:

  • MCP 服务(默认 8000,SSE/stdio)
  • Flask REST API 服务(默认 8001)

功能特点

  • 搜索B站视频
  • 获取视频字幕(自动生成的AI字幕)
  • 查询视频详细信息
  • 使用必剪API获取媒体文件的AI字幕

组件

工具

  • search_video

    • 从B站搜索视频,支持按发布时间范围和排序方式筛选
    • 输入:
      • keyword (string): 搜索关键词
      • page (int, 可选): 页码,默认1
      • page_size (int, 可选): 每页数量,默认20
      • time_start (string, 可选): 发布时间起始,格式 YYYY-MM-DD
      • time_end (string, 可选): 发布时间截止,格式 YYYY-MM-DD
      • order_type (string, 可选): 排序方式,可选 totalrank(综合)/click(播放量)/pubdate(发布时间)/dm(弹幕)/stow(收藏)/scores(评论),默认 totalrank
  • get_video_subtitle

    • 获取B站视频的字幕
    • 输入:
      • bvid (string): 视频的BV号
      • format (string, 可选): 字幕格式,可选 txt(纯文本,默认)/srt(带时间戳)/raw(原始时间戳数据)
  • get_video_info

    • 获取B站视频的详细信息
    • 输入:
      • bvid (string): 视频的BV号
  • get_media_subtitle

    • 使用必剪API获取媒体文件的AI中文字幕
    • 输入:
      • url (string): 媒体文件URL
      • format (string, 可选): 字幕格式,同上
  • send_comment

    • 在B站资源下发送评论,支持顶级评论和回复评论
    • 输入:
      • text (string): 评论内容
      • oid (int): 目标资源ID(视频的aid,可通过 get_video_info 获取)
      • type (string, 可选): 资源类型,可选 video/article/dynamic/audio,默认 video
      • root (int, 可选): 根评论ID,0表示顶级评论
      • parent (int, 可选): 父评论ID,0表示顶级评论
  • get_comments

    • 获取B站资源的评论列表
    • 输入:
      • oid (int): 目标资源ID(视频的aid)
      • type (string, 可选): 资源类型,可选 video/article/dynamic/audio,默认 video
      • page_index (int, 可选): 页码,从1开始
      • order (string, 可选): 排序方式,可选 time(按时间)/like(按点赞),默认 time

开始使用

  1. 克隆仓库
  2. 安装依赖: pip install -r requirements.txt
  3. 设置环境变量(从B站官网cookie获取):
    • sessdata: B站SESSDATA
    • bili_jct: B站bili_jct
    • buvid3: B站buvid3
  4. 启动服务器: python server.py

如需同时启动 MCP + Flask REST API:

bash
python run_servers.py

Flask REST API

  • GET /api — 返回所有可用接口及其参数说明
  • GET /health
  • GET /api/video/search?keyword=关键词&page=1&page_size=20&time_start=2024-01-01&time_end=2024-06-30&order_type=pubdate
  • GET /api/video/info/<bvid>
  • GET /api/video/pbp/<bvid>?page_index=0
  • GET /api/video/subtitle/<bvid>?format=txt
  • POST /api/media/subtitle,JSON body: { "url": "媒体地址", "format": "txt" }
  • POST /api/comment/send,JSON body: { "text": "评论内容", "oid": 视频aid, "type": "video", "root": 0, "parent": 0 }
  • GET /api/comment/list/<oid>?type=video&page_index=1&order=time

与桌面应用集成

要将此服务器与桌面应用集成,请在应用的服务器配置中添加以下内容:

json
{
  "mcpServers": {
    "bilibili-mcp": {
      "command": "python",
      "args": [
        "{绝对路径}/server.py"
      ],
      "env": {
        "sessdata": "你的B站SESSDATA",
        "bili_jct": "你的B站bili_jct",
        "buvid3": "你的B站buvid3"
      }
    }
  }
}

开发

  • 安装依赖: pip install -r requirements.txt
  • 启动服务器: python server.py
  • 同时启动 MCP + Flask: python run_servers.py

依赖项

  • mcp: MCP SDK
  • bilibili-api-python: B站API Python库
  • aiohttp: 异步HTTP客户端/服务器框架
  • brotlicffi: Brotli 压缩解码支持(修复 aiohttp 3.13+ 与 B站 API 的 br 内容编码兼容问题)

资源

更新日志

最新变更

新增评论接口

  • 新增 send_comment MCP 工具:支持在视频/文章/动态等资源下发送评论,支持顶级评论和回复评论
  • 新增 get_comments MCP 工具:获取资源的评论列表,支持分页和排序
  • 新增 Flask REST API:POST /api/comment/send 和 GET /api/comment/list/<oid>

修复 Brotli 解码错误

  • 新增 brotlicffi 依赖,修复 aiohttp 3.13+ 无法解码 B站返回的 Content-Encoding: br 响应的问题,影响所有工具(search_video、get_video_info、get_video_subtitle)

字幕获取优化(PR #1 by @Zhao-zzzzZ)

  • 修复 get_video_subtitle:字幕列表获取改用 .get() 安全访问,避免视频无字幕时崩溃
  • 修复 AI 字幕语言匹配条件,放宽为只需 lan == "ai-zh",兼容更多视频
  • 异步化音频字幕获取:get_audio_subtitle 改为通过 asyncio.to_thread 包装为异步,避免阻塞事件循环
  • 修复错误处理:get_audio_subtitle 将错误由返回值改为正确抛出 APIError 异常
  • 修复 ResultRspSchema 模型:result 和 remark 字段改为可选,避免解析失败
  • 补全 requirements.txt 缺失的 requests、pydantic、tabulate 依赖
  • 支持音频格式扩展至 mp4/m4s,改进音频 URL 选择策略

许可证

本项目采用MIT许可证。

Installation

TypingMind
{
  "mcpServers": {
    "bilibili-mcp": {
      "command": "python",
      "args": [
        "server.py"
      ],
      "env": {
        "sessdata": "<sessdata>",
        "bili_jct": "<bili_jct>",
        "buvid3": "<buvid3>"
      }
    }
  }
}

Use Bilibili MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Bilibili MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Bilibili MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Bilibili MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "bilibili-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Bilibili MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Bilibili MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Bilibili MCP Server to help me with this task?
Bilibili MCP Server
Sure. I read it.
Here is what I found using Bilibili MCP Server.

Frequently asked questions

What is the Bilibili MCP Server MCP server used for?

Bilibili MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Bilibili MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Bilibili MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Bilibili MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Bilibili MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Bilibili MCP Server MCP to TypingMind?

Bilibili MCP Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Bilibili MCP Server MCP provide in TypingMind?

Bilibili MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Bilibili MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Bilibili MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇