blender-2d-mcp
Blender 2D MCP
AI 驱动的 2D 绘制与动画,面向 Blender 5.x,通过 Model Context Protocol 实现。让 MCP 客户端(Claude Desktop、Cursor、VS Code Copilot agent 模式等)直接在运行中的 Blender 实例内创建 Grease Pencil 绘图、关键帧、材质和渲染。
基于 Blender 的 GPv3 API(bpy.ops.grease_pencil.*、GreasePencilDrawing)构建,参考了 ahujasid/blender-mcp。
flowchart LR
A[MCP Client<br/>Claude / Cursor / VS Code] <-->|stdio / JSON-RPC| B[blender-2d-mcp<br/>FastMCP server]
B <-->|TCP JSON<br/>localhost:9876| C[addon.py<br/>socket server in Blender]
C -->|main thread| D[Grease Pencil API<br/>GPv3]addon.py— Blender 插件,内嵌一个 TCP JSON 命令服务器。命令会排队并通过bpy.app.timers在 Blender 主线程上执行。src/blender_2d_mcp/server.py— FastMCP stdio 服务器,将插件的命令暴露为 MCP 工具。
要求
仅限 Blender 5.2 LTS(插件在旧版本上会拒绝启用;其使用的 GPv3 API 是 5.2 特有的)
Python ≥ 3.10,并安装
mcp[cli](会自动安装)
Related MCP server: Blender MCP Bridge
安装
1. 将插件安装到 Blender
在 Blender 中:编辑 > 偏好设置 > 插件 > 安装…
从此仓库中选择
addon.py。启用 界面:Blender 2D MCP。
打开侧边栏(视图 > 侧边栏,或按 N)→ Blender2DMCP 选项卡。
点击 连接到 MCP 客户端(默认端口
9876)。保持 Blender 运行。
提示:
blender-2d-mcp --install-addon会将addon.py复制到你的下载文件夹,并打印这些步骤。
2. 连接 MCP 客户端
服务器仅绑定到 localhost——本地使用无需身份验证令牌。
选项 A — uvx(无需安装):
uvx --from "g:\My Projects\blender-2d-mcp" blender-2d-mcp选项 B — 可编辑安装:
cd "g:\My Projects\blender-2d-mcp"
pip install -e .
blender-2d-mcp # runs the stdio MCP serverClaude Desktop(claude_desktop_config.json):
{
"mcpServers": {
"blender-2d-mcp": {
"command": "uvx",
"args": ["--from", "g:\\My Projects\\blender-2d-mcp", "blender-2d-mcp"]
}
}
}Cursor(.cursor/mcp.json)或通用 stdio 客户端:
{
"mcpServers": {
"blender-2d-mcp": {
"command": "C:\\Path\\To\\Python\\Scripts\\blender-2d-mcp.exe",
"args": []
}
}
}VS Code / GitHub Copilot Chat(.vscode/mcp.json——已包含在此仓库中):
{
"servers": {
"blender-2d-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "g:\\My Projects\\blender-2d-mcp", "blender-2d-mcp"],
"env": {}
}
}
}或者,如果
blender_2d_mcp已通过 pip 安装在某个环境中,请使用 该环境的 Python:"command": "C:\\Path\\To\\Python\\python.exe", "args": ["-m", "blender_2d_mcp.server"]。
使用方法:打开 Copilot Chat,将模式下拉菜单切换到 Agent,Blender 工具即可用(#blender-2d-mcp)。可通过命令面板中的 MCP: List Servers 启动/停止/重启服务器。编辑 mcp.json 后重新加载 VS Code 窗口。
2D 画布
使用 setup_2d_scene 后,视口会设置为前视正交视图,因此绘制平面为世界 XZ 平面:
你发送的 2D 点 | 世界坐标 | 含义 |
|
| x = 屏幕右,y = 屏幕上 |
|
| 原样使用 |
单位是米(Blender 默认);在默认相机缩放下,1920×1080 高清帧横向大约跨越 ±5 个单位。
工具目录
工具 | 用途 |
| 列出 GP 物体、图层、关键帧、笔画数量 |
| 常规场景/物体内省 |
| 插件/协议/Blender 版本 + 兼容性状态 |
| 白色背景、前视正交视图、高清分辨率 |
| 新建带图层 + 黑色笔画材质的 GP 物体 |
| 图层管理 |
| 图层堆栈编辑 |
| 不透明度、混合模式、隐藏、锁定 |
| GPv3 图层遮罩(镂空效果) |
| 幂等的空白关键帧创建 |
| 关键帧操作( |
| 自由手绘笔画;逐点半径/不透明度轮廓,用于渐细 |
| 一次调用批量绘制多条笔画 |
|
|
| 笔画检查与编辑(移动/缩放/旋转/平滑) |
| 笔画 + 填充颜色 |
| 在两个关键帧之间生成中间帧(缓动控制) |
| 关键帧物体位置/旋转/缩放 |
| 虚影显示前一帧/下一帧 |
| GP 修改器:噪波抖动、平滑、厚度、时间偏移… |
| 播放头、fps、帧范围、渲染引擎、胶片透明 |
| 适配画布的正交前视相机 |
| 用于临摹的背景图像空物体 |
| 非阻塞渲染,包括 mp4 视频输出 |
| 回退 AI 驱动的编辑 |
| 返回视口截图作为图像 |
| 逃生通道:任意 |
| 最后手段:任意 |
典型工作流
get_gp_scene_info+get_viewport_screenshot— 查看当前内容。如果从零开始,
setup_2d_scene→create_gp_object。使用
gp_draw_shape/gp_draw_stroke绘制;传入frame_number可将笔画放在关键姿势上(帧会自动创建)。使用gp_draw_strokes批量绘制精细图形。填充形状:创建
fill_alpha > 0的材质,然后设置fill=True+fill_material。按“一拍二”的方式制作动画(24 fps 下每 2 帧一个关键姿势):用
gp_copy_frame复制姿势,用gp_transform_stroke微调,再用gp_interpolate生成中间帧。添加 NOISE 修改器模拟手绘抖动。使用
render_animation(use_video=True)渲染,并轮询get_render_status。每次修改后务必截图 以进行视觉验证。错误可通过
undo撤销。
开发
pip install -e ".[dev]"
python -m pytest tests/ -v测试套件通过 AST 提升服务器类并配合模拟的 bpy,在 Blender 外部运行插件的 TCP 传输——无需安装 Blender。涉及真实 Grease Pencil 数据的处理器逻辑必须在 Blender 内部验证。
故障排除
症状 | 修复 |
MCP 客户端无法连接 | 先在 Blender 的侧边栏面板中启动服务器;检查端口是否匹配(默认 9876) |
端口已被占用 | 在侧边栏面板中更改端口,并在 MCP 命令中添加 |
启动时出现防火墙提示 | 允许 Blender 在专用网络上运行(服务器仅绑定 localhost) |
截图全黑 | 先点击一次 Blender 窗口(合成器问题),或确保 3D 视口可见;该工具会自动从离屏 GPU 捕获回退到窗口抓取 |
| 它需要 Blender 中可见的 3D 视口以及两个边界帧上的关键帧;请打开一个 |
模态操作符(画笔、笔刷笔画)不工作 | MCP 不支持 — 请改用 |
| 已不再使用 — 重启 MCP 服务器,并确保插件和 |
渲染似乎卡住 | 它们现在是非阻塞的 — 轮询 |
插件无法启用 | 此项目要求精确使用 Blender 5.2 LTS(仅支持 GPv3 API);旧版本按设计被拒绝 |
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
Generate images, video, audio and short films with 140+ AI models from any MCP client.
Generate game-ready 3D models, textures, and audio from natural language, over MCP.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceTransforms Blender into an MCP server with 50+ tools for AI-driven 3D workflows, enabling complete control over objects, materials, animations, physics simulations, and rendering through natural language commands.45MIT
- AlicenseAqualityDmaintenanceEnables remote control of Blender via the Model Context Protocol, allowing users to execute Python scripts, query scene data, and generate 3D models from images. It provides a bridge for AI clients to interact directly with Blender's internal environment and automate 3D content creation.36MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI clients to control Blender's 3D workflow via an embedded MCP server.645 PyPI47MIT
- AlicenseNot gradedqualityCmaintenanceEnables natural language control of Blender 3D through MCP clients, allowing creation, modification, and manipulation of 3D models, animations, and scenes.300MIT