Bilibili MCP (Playwright)
An MCP server that utilizes Playwright to automate Bilibili video uploads, including automated metadata entry for titles, tags, and descriptions. It features QR code login and cookie persistence to enable seamless interaction with the Bilibili creator platform.
README
Bilibili MCP (Playwright 版)
基于 Playwright 模拟浏览器操作实现的 Bilibili (B 站) MCP 服务器,支持视频上传功能。
特性
- ✅ 扫码登录 - 使用 Bilibili App 扫码登录
- ✅ 视频上传 - 模拟浏览器操作上传视频
- ✅ 自动填表 - 自动填写标题、简介、标签、分区
- ✅ Cookie 持久化 - 登录状态自动保存
- ✅ HTTP API - 提供 RESTful API 接口
目录结构
bilibili-mcp/
├── server-playwright.js # MCP HTTP 服务器 (端口 18061)
├── login-playwright.js # 扫码登录工具
├── package.json # 依赖配置
├── cookies.json # 登录状态 (自动生成)
└── README.md # 使用文档
安装
cd bilibili-mcp
npm install
Playwright 浏览器会自动安装。
使用方法
1. 登录 Bilibili
# 在 bilibili-mcp 目录
npm run login
# 或
node login-playwright.js
运行后会打开浏览器窗口,显示二维码:
- 打开 Bilibili App
- 点击右上角扫描图标
- 扫描浏览器中的二维码
- 在手机上确认登录
登录成功后会自动保存 cookies。
2. 启动 MCP 服务器
# 在 bilibili-mcp 目录
npm start
# 或
node server-playwright.js
服务器运行在 http://localhost:18061
3. 发布视频
使用 curl 调用 API:
curl -X POST http://localhost:18061/api/v1/publish \
-H "Content-Type: application/json" \
-d '{
"title": "视频标题",
"content": "视频简介",
"video_path": "/path/to/video.mp4",
"tid": 174,
"tags": ["标签 1", "标签 2"],
"copyright": 1
}'
API 接口
健康检查
GET http://localhost:18061/health
检查登录状态
GET http://localhost:18061/api/v1/login/status
发布视频
POST http://localhost:18061/api/v1/publish
Content-Type: application/json
{
"title": "视频标题",
"content": "视频简介",
"video_path": "/path/to/video.mp4",
"tid": 174,
"tags": ["标签 1", "标签 2"],
"copyright": 1
}
参数说明:
title- 视频标题 (最多 80 字)content- 视频简介video_path- 本地视频文件绝对路径tid- 分区 ID (默认 174=生活 - 其他)tags- 标签数组copyright- 1=原创,2=转载
配置 MCP Client
在 MCP 配置中添加:
{
"mcpServers": {
"bilibili": {
"command": "node",
"args": ["/path/to/bilibili-mcp/server-playwright.js"]
}
}
}
常见问题
1. 登录过期
Bilibili cookies 有一定的有效期,如果发布时提示未登录,需要重新运行登录工具:
node login-playwright.js
2. 浏览器窗口
- 登录时会显示浏览器窗口(方便扫码)
- 上传视频时无头模式运行(不显示窗口)
技术栈
- Playwright - 浏览器自动化
- Express - HTTP 服务器
- Node.js - 运行环境
参考
- 小红书 MCP - 灵感来源
- Playwright 文档
- Bilibili 创作中心
License
MIT
注意
本项目仅供学习和个人使用,请遵守 Bilibili 的使用条款和社区规范。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.