Skip to main content

B2A (Bilibili to Agents) — 让 AI Agent 能「观看」B站视频,现已原生支持 MCP 协议

Project description

B2A

让 AI Agent(Claude Code、Codex、Cursor、Antigravity、Windsurf 等)原生具备「观看」和「倾听」B站视频能力的多模态 MCP 插件。

🌟 核心能力(v0.5.0 全新架构)

在 v0.5.0 的“三刀重构”后,B2A 彻底摒弃了可能造成大模型死锁或 C盘爆满的无脑提取模式。我们为所有 AI Agent 注入了最省流、防剧情断层的分层多模态阅读能力

  • CC 字幕与元数据(最快):以毫秒级速度直接拉取视频信息与自带字幕文本,是了解视频的最快轨道。
  • 全景故事板雷达(防反转架构):AI 将以极低分辨率均匀抽取视频的缩略图,以上帝视角综观整片节奏走向,绝不错过片尾的惊天大反转!
  • 局部下钻特写(精准截取):看完缩略图后,AI 能敏锐地锁定特定时间段(如 05:00-05:30)重新索取对应的高清切片,精准看清 PPT 甚至代码!
  • 强制缓存回收(绝对干净):你的存储守护神!分析结束后,AI 助手将强制调用清理协议,瞬间抹除由于抽帧与视频提取产生的各种残骸碎屑。

📦 安装说明

1. 安装 FFmpeg (前置依赖)

视觉抽帧和长音频处理依赖网络串流和 FFmpeg。如果忘记装,AI 会在聊天里贴心提示你如何一键上车:

  • Windows: winget install Gyan.FFmpeg (安装后需重启终端)
  • macOS: brew install ffmpeg
  • Linux: apt install ffmpeg

2. 安装 B2A 插件

pip install b2a777

🔌 MCP 接入指南 (核心用法)

安装完成后,你可以将它原生挂载到各种大模型 IDE 的上下文中。请根据你使用的客户端选择对应的配置方式:

1. Claude Code

在 Claude Code 的聊天对话框中输入以下斜杠命令:

/mcp add b2a-vision b2a-mcp

2. Codex

由于 Codex 同样深度集成了指令模式,可以直接在其命令行终端中添加挂载命令:

/mcp add b2a-vision b2a-mcp

3. Cursor

  1. 打开 Cursor Settings -> Features -> MCP
  2. 点击 + Add New MCP Server
  3. Type: 选择 command
  4. Name: b2a-vision
  5. Command: b2a-mcp

4. Antigravity

作为直接的衍生环境,与 Claude Code 保持一致,在对话框内执行即可:

/mcp add b2a-vision b2a-mcp

5. Windsurf

在配置目录下的 mcp_config.json 中添加:

{
  "mcpServers": {
    "b2a-vision": {
      "command": "b2a-mcp",
      "args": []
    }
  }
}

6. Claude Desktop

在配置目录下的 claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "b2a-vision": {
      "command": "b2a-mcp",
      "args": []
    }
  }
}

💬 与 Agent 互动的提示词示例

配置好 MCP 后,你不需要写任何代码。得益于内置的 [CRITICAL SAFETY LOCK] 安全锁,Agent 会以极度省流和尊重你的方式展开工作:

  • "总结一下这个视频的核心观点:BV1xx411c7mD" -> (Agent 瞬间抓取 CC 字幕并给你答复)
  • "帮我看看这个视频讲了什么?BV..." -> (Agent 返回询问:“为了更准确,是否允许我为您消耗空间去提取故事板画面?”)
  • "这没字幕,帮我听一下这个视频的 1分30秒 到 3分钟 说了什么" -> (Agent 自动调度 ASR 识别,并在结束后默默打扫卫生)

🛠️ 进阶:作为 CLI 工具独立使用

B2A 同时也可以作为极简的命令行工具在未接入 MCP 的环境中独立运行。

基础用法

# 获取视频信息与字幕
b2a BV1xx411c7mD

# 结构化 JSON 输出
b2a BV1xx411c7mD --format json

更多参数

  --asr              启用语音识别(提取音频轨并转文字)
  --visual           启用视觉提取(抽取视频关键帧截图)
  --start TIME       截取开始时间(如 01:30)
  --end TIME         截取结束时间(如 02:40)
  --page N           指定分P编号(从1开始)

🔑 极致简单的 ASR 语音配置

如果需要无字幕视频的听力功能,B2A 接入了火山引擎(豆包)。你甚至不需要自己去找环境变量文件怎么写,直接在聊天框里对 AI 说:

“我的豆包 API Key 是 XXXX,帮我存一下以备后面听译 B站 视频用。”

AI 会调用底层安全协议帮你自动安置好一切配置!

License

MIT

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

b2a777-0.5.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

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

b2a777-0.5.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file b2a777-0.5.0.tar.gz.

File metadata

  • Download URL: b2a777-0.5.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for b2a777-0.5.0.tar.gz
Algorithm Hash digest
SHA256 226709ec307477ded526008f22be9cbcaf8fc76ef734dada688f0a0c972690f3
MD5 285b1072dacb4b66aa195a52515fc995
BLAKE2b-256 3b804b3321930a175223c795ce3803fbbc3fd380a2f92d669ebf17e2201c5324

See more details on using hashes here.

Provenance

The following attestation bundles were made for b2a777-0.5.0.tar.gz:

Publisher: publish.yml on e8b298/B2A

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file b2a777-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: b2a777-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for b2a777-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa0ac90e10d8d44c54c7534f4c96472dc6c9c78b41c6f0472d1e2873dd97a3a3
MD5 38ca3956aeffd2da5e2d127d13a56d8d
BLAKE2b-256 367660c2d8efab444b8db7171a0dd49e26dd71d5e1ae54ef8cb774c8a3821de6

See more details on using hashes here.

Provenance

The following attestation bundles were made for b2a777-0.5.0-py3-none-any.whl:

Publisher: publish.yml on e8b298/B2A

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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