Blender自然语言控制工具

通过Google Gemini AI使用自然语言控制Blender 3D,支持多步骤任务规划和场景推理。

  • by PocoLibre
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 PocoLibre/blender-mcp

使用说明

搅拌机MCP与Gemini AI代理

备注:叉子 搅拌机MCP 通过 悉达多Ahuja,增强了谷歌的ADK,用于自主执行多步任务。

使用自然语言与Google Gemini AI控制Blender 3D,由MCP和Google ADK提供支持。


🎯 特性

  • 多步骤任务规划:将复杂的请求分解为较小的操作。
  • 工具链:调用多种工具来实现目标。
  • 场景推理:在进行更改之前查询场景信息。
  • Blender Python执行:将自然语言翻译成可执行命令。

例子:

You: "Create a metallic red sphere above a blue cube with studio lighting"
Agent:
  1. Creates cube (blue material)
  2. Creates sphere (metallic red, positioned above)
  3. Adds studio lighting
  4. Returns: "Scene created with metallic red sphere, blue cube, and studio lighting"

🏗️ 建筑

┌─────────────┐ → ┌──────────────────┐ → ┌──────────────┐ → ┌─────────────┐
│   Gemini    │   │   MCP Server     │   │  Google ADK  │   │   Blender   │
│   Client    │   │   (FastMCP)      │   │    Agent     │   │   (Addon)   │
└─────────────┘   └──────────────────┘   └──────────────┘   └─────────────┘

🚀 快速开始

先决条件

安装

  1. 克隆仓库:
    git clone https://github.com/PocoLibre/blender-mcp.git
    cd blender-mcp
    
  2. 运行安装程序:
    • 窗户: ./install.bat
    • Linux/macOS: chmod +x install.sh run_server.sh run_client.sh && ./install.sh
  3. 设置 .env:
    GEMINI_API_KEY="your-api-key"
    
  4. 安装Blender插件:
    • 打开搅拌机→ Edit → 偏好设置→ 附加组件→ 安装 addon.py → 启用“搅拌机Gemini连接器”。

用法

  1. 启动MCP服务器:
    ./run_server.bat  # Windows
    ./run_server.sh   # Linux/Mac
    
  2. 启动搅拌机 启用插件后。
  3. 运行Gemini客户端:
    ./run_client.bat  # Windows
    ./run_client.sh   # Linux/Mac
    
  4. 输入命令:
    Enter your command for Blender (or 'quit' to exit): create a metallic sphere
    

🛠️ 代理工具

  • get_blender_scene_info:获取场景细节(对象、材质、照明)。
  • execute_blender_python_code:在Blender中执行Python代码。
  • web_search:搜索资源/教程。
  • download_asset:将文件下载到 assets/downloads/.

⚙️ 配置

.env 文件

GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-2.5-flash  # Free tier: 15 req/min
VERBOSE=false                  # Set to 'true' for detailed logging
BLENDER_HOST=localhost         # Blender addon host
BLENDER_PORT=9876             # Blender addon port

📁 项目结构

blender-mcp/
├── src/
│   └── blender_mcp/
│       └── server.py         # MCP server with Google ADK Agent
├── addon.py                  # Blender addon (socket server)
├── gemini_client.py          # Gemini client (calls MCP server)
├── install.bat/sh            # Installation scripts
├── run_server.bat/sh         # Server launcher
├── run_client.bat/sh         # Client launcher
├── pyproject.toml            # Python dependencies
└── README.md

💡 示例命令

简单:

  • “在原点创建立方体”
  • “制作一个红色球体”
  • “我运行的是哪个版本的Blender?”

复杂:

  • “在蓝色立方体上方创建一个金属红色球体”
  • “添加一个指向工作室照明场景的相机”

⚠️ 安全和费率限制

  • 安全:仅在受信任的本地网络上使用。执行前检查生成的代码。
  • 速率限制:免费等级允许15个请求/分钟 gemini-2.5-flash.

🙏 鸣谢

  • 原始项目: 悉达多Ahuja
  • 这个叉子:使用Google ADK Agent进行增强,以实现自主任务执行。

🤝 贡献

欢迎投稿!请随时提交拉取请求。


由以下材料制成❤️ 面向AI和Blender社区

许可证:MIT 构建于:Google ADK、FastMCP、Google Gemini AI、Blender Python API