mcp-for-blender

应用程序

ahujasid/mcp-for-blender

让任意大语言模型控制 Blender 的 MCP 插件。

项目简介

社区开发的集成工具,通过模型上下文协议(MCP)将 Blender 与任意大语言模型连接。包含 Blender 插件与 Python MCP 服务器,支持提示词辅助 3D 建模、场景创建、物体与材质操控及代码执行,并可导入 Poly Haven、Sketchfab 等资产与 AI 生成的 3D 模型。

README 预览

\n\n# MCP for Blender\n\n**Connect Blender to any LLM**\n\n*formerly `blender-mcp` — the PyPI package is now [`mcp-for-blender`](https://pypi.org/project/mcp-for-blender/).*\n*Existing setups keep working; no config change is required. [Read more](https://github.com/ahujasid/mcp-for-blender/issues/366)*\n\n**Disclaimer:** This is a third-party integration and not made by Blender\n\nPrompt-assisted 3D modeling, scene creation, and manipulation — driven by AI.\n\n[](https://pepy.tech/projects/blender-mcp)\n[](https://pypi.org/project/mcp-for-blender/)\n[](LICENSE)\n[](https://discord.gg/SNqPn4TcKQ)\n\n[**Website**](https://mcp-for-blender.com/) · [**Full Tutorial**](https://www.youtube.com/watch?v=lCyQ717DuzQ) · [**Discord**](https://discord.gg/SNqPn4TcKQ) · [**Sponsor**](https://github.com/sponsors/ahujasid) · [**Buy me a coffee**](https://buymeacoffee.com/ahujasid) · [**Feedback**](https://cal.com/siddharth-ahuja/feedback-call)\n\n\n\n\n\n**Supporters**\n\n[CodeRabbit](https://www.coderabbit.ai/)\n[Kevin Guanche Darias](https://github.com/KevinGuancheDarias)\n[Guillermo Rauch](https://github.com/rauchg)\n\n**All supporters:** [Support this project](https://github.com/sponsors/ahujasid)\n\n\n\n---\n\n## Quickstart\n\n> **Note:** the PyPI package `blender-mcp` is now **`mcp-for-blender`**. Existing setups\n> keep working — `uvx blender-mcp` still runs the server and **no config change is\n> required**. New installs should use `mcp-for-blender`.\n> [What changed and why](https://github.com/ahujasid/mcp-for-blender/issues/366)\n\n**One command** sets up your AI apps and the Blender addon:\n\n**macOS / Linux**\n\n```bash\ncurl -LsSf https://www.mcp-for-blender.com/install.sh | sh\n```\n\n**Windows** (PowerShell)\n\n```powershell\npowershell -ExecutionPolicy ByPass -c "irm https://www.mcp-for-blender.com/install.ps1 | iex"\n```\n\nAlready have uv? Run `uvx mcp-for-blender setup` instead.\n\nIt installs [uv](https://docs.astral.sh/uv/) if needed, finds the MCP clients on y

常见问题 (3)

故障排除
如何修复在德语/非英语 Windows 上运行 'uvx mcp-for-blender setup' 时出现的 UnicodeDecodeError 崩溃?

崩溃发生在 blender_is_running() 中,因为 tasklist 的输出使用 OEM 代码页(cp850),而 Python 使用 cp1252 进行解码,在遇到 'ü' 等字符时会失败。

**修复方法(适用于维护者/源码安装):** 在 blender_mcp/setup_cli.py 第 ~607 行,为运行 tasklist /FI "IMAGENAME eq blender.exe" /NH 的 subprocess.run 调用传入 encoding="oem"(或 errors="replace")。

**用户的临时解决办法:**
1. 在运行 uvx mcp-for-blender setup 之前,先运行 chcp 65001 并设置 $env:PYTHONUTF8=1(PowerShell)。
2. 或者跳过失败的步骤:插件文件在崩溃前已经复制完成,因此只需打开 Blender,在 编辑 > 偏好设置 > 插件 中手动启用该插件即可。

来源 Issue #380
故障排除
为什么 blender-mcp 在显示 'Successfully connected to Blender on startup' 后就卡住且没有任何响应?

它并没有卡住——这是正常行为。uvx blender-mcp 是一个基于 stdio 的 MCP 服务器,而不是交互式 CLI。连接到 Blender 后,它会在 stdin/stdout 上静默等待来自 MCP 客户端(Claude Desktop、Cursor 等)的 MCP 协议消息。直接在终端中运行它只是验证连接;之后不会再显示任何输出,而按下 Ctrl+C 时出现的回溯信息(asyncio CancelledError)只是正常关闭时的噪音,并非错误。

实际使用方法:
1. 在 Blender 中:Edit > Preferences > Add-ons,安装 addon.py 文件,启用 "Interface: Blender MCP"。在 3D 视口中按 N 键,打开 BlenderMCP 选项卡,然后点击 "Connect to Claude"(这会在端口 9876 上启动 socket 服务器)。
2. 配置你的 MCP 客户端,而不是手动运行服务器。对于 Claude Desktop,编辑 claude_desktop_config.json:
{"mcpServers": {"blender": {"command": "uvx", "args": ["blender-mcp"]}}}
对于 Cursor:Settings > MCP > Add new server,命令为:uvx blender-mcp。
3. 重启客户端,然后在客户端中发送提示(例如 "create a cube in Blender")——Blender 现在就会响应了。

仅在需要做连接测试时才单独运行 uvx blender-mcp,测试完用 Ctrl+C 关闭即可。

来源 Issue #73
故障排除
如何修复在 Windows 上通过 uvx 运行 blender-mcp 时出现的 pywin32 错误 "os error 32: file being used by another process"?

出现该错误是因为 uvx blender-mcp 每次运行时都会创建一个临时环境,而 uv 缓存中被锁定的 pywin32 文件无法被替换。解决方法是将 blender-mcp 安装为持久的 uv 工具:

1. 将其安装到 uv 的工具存储中:uv tool install blender-mcp
2. 强制更新它:uv tool upgrade blender-mcp
3. 验证安装:uv tool list

你的 MCP 配置可以保持不变("command": "uvx", "args": ["blender-mcp"]),因为此时 uvx 会直接解析已安装的工具,而不是重新构建临时环境并再次遇到文件锁定。仅手动删除被锁定的缓存目录(例如 C:\Users\<you>\AppData\Local\uv\cache\builds-v0\...)并不能解决问题,因为在下次临时安装时锁定会再次出现。

来源 Issue #196