Skip to main content

Blender integration through the Model Context Protocol

Project description

BlenderMCP-Hortor

BlenderMCP-Hortor 通过 Model Context Protocol (MCP) 将 Blender 连接到 AI 助手(Claude、Cursor、VS Code 等),实现 AI 驱动的 3D 建模、场景创建与操作。

本项目基于 ahujasid/blender-mcp 开发。

功能特性

  • 双向通信:通过 Socket 服务器连接 AI 与 Blender
  • 对象操作:创建、修改、删除 3D 对象
  • 材质控制:应用和修改材质与颜色
  • 场景检查:获取当前 Blender 场景的详细信息
  • 代码执行:在 Blender 中执行 Python 代码
  • Poly Haven 资产:下载模型、纹理和 HDRI
  • AI 3D 模型生成:支持 Hyper3D Rodin、Hunyuan3D、Meshy.ai
  • Sketchfab 模型:搜索和下载 Sketchfab 模型
  • 视口截图:截取 Blender 视口图片以便 AI 理解场景

系统组件

  1. Blender 插件 (addon.py):在 Blender 内部创建 Socket 服务器,接收和执行命令
  2. MCP Server (src/blender_mcp/server.py):实现 MCP 协议,连接 AI 助手与 Blender 插件

安装

前置条件

Mac 安装 uv:

brew install uv

Windows 安装 uv:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

安装后将 uv 添加到用户 PATH(可能需要重启编辑器):

$localBin = "$env:USERPROFILE\.local\bin"
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$userPath;$localBin", "User")

安装 Blender 插件

  1. 下载本仓库的 addon.py 文件
  2. 打开 Blender → Edit → Preferences → Add-ons
  3. 点击 "Install...",选择下载的 addon.py
  4. 勾选 "Interface: Blender MCP" 启用插件

Cursor 配置

进入 Settings → MCP → Add Server,粘贴以下配置:

  • 全局使用:点击 "add new global MCP server"
  • 项目级使用:在项目根目录创建 .cursor/mcp.json

Mac / Linux:

{
    "mcpServers": {
        "blender": {
            "command": "uvx",
            "args": [
                "blender-mcp-hortor"
            ]
        }
    }
}

Windows:

{
    "mcpServers": {
        "blender": {
            "command": "cmd",
            "args": [
                "/c",
                "uvx",
                "blender-mcp-hortor"
            ]
        }
    }
}

Claude Desktop 配置

进入 Claude → Settings → Developer → Edit Config → claude_desktop_config.json

Mac / Linux:

{
    "mcpServers": {
        "blender": {
            "command": "uvx",
            "args": [
                "blender-mcp-hortor"
            ]
        }
    }
}

Windows:

{
    "mcpServers": {
        "blender": {
            "command": "cmd",
            "args": [
                "/c",
                "uvx",
                "blender-mcp-hortor"
            ]
        }
    }
}

Visual Studio Code 配置

在 VS Code 的 MCP 设置中添加:

{
    "servers": {
        "blender": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "blender-mcp-hortor"
            ]
        }
    }
}

环境变量

可通过环境变量配置 Blender 连接参数:

变量名 说明 默认值
BLENDER_HOST Blender Socket 服务器地址 localhost
BLENDER_PORT Blender Socket 服务器端口 9876

在 MCP 配置中使用环境变量的示例:

{
    "mcpServers": {
        "blender": {
            "command": "uvx",
            "args": ["blender-mcp-hortor"],
            "env": {
                "BLENDER_HOST": "localhost",
                "BLENDER_PORT": "9876"
            }
        }
    }
}

使用方法

启动连接

  1. 在 Blender 中,打开 3D 视口侧边栏(按 N 键)
  2. 找到 "BlenderMCP" 标签页
  3. 如需 Poly Haven 资产,勾选对应选项
  4. 点击 "Connect to Claude"
  5. 确保 MCP Server 已在编辑器中运行

⚠️ 同一时间只运行一个 MCP Server 实例(Cursor 或 Claude Desktop,不要同时运行)

使用示例

以下是一些可以让 AI 完成的操作示例:

  • "创建一个低多边形的地牢场景,有一条龙守护着一罐金币"
  • "用 Poly Haven 的 HDRI、纹理和模型创建一个海滩场景"
  • "根据这张参考图创建 Blender 场景"
  • "通过 Hyper3D 生成一个花园侏儒的 3D 模型"
  • "把这辆车改成红色金属材质"
  • "创建一个球体并放在方块上方"
  • "设置成摄影棚灯光效果"
  • "把摄像机对准场景,并设为等距视角"

故障排除

  • 连接失败:确保 Blender 插件服务器正在运行,MCP Server 已在编辑器中配置,不要手动在终端运行 uvx 命令
  • 超时错误:尝试简化请求或拆分为更小的步骤
  • 连接仍有问题:重启编辑器和 Blender 插件

遥测控制

BlenderMCP 收集匿名使用数据用于改进工具。可通过以下方式控制:

  1. Blender 内:Edit → Preferences → Add-ons → Blender MCP,取消勾选遥测选项
  2. 环境变量:完全禁用遥测:
{
    "mcpServers": {
        "blender": {
            "command": "uvx",
            "args": ["blender-mcp-hortor"],
            "env": {
                "DISABLE_TELEMETRY": "true"
            }
        }
    }
}

安全提示

  • execute_blender_code 工具允许在 Blender 中运行任意 Python 代码,使用前请务必保存你的工作
  • Poly Haven 需要下载模型、纹理和 HDRI 图片,如不需要请在 Blender 中关闭
  • 复杂操作可能需要拆分为更小的步骤

许可证

MIT License

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

blender_mcp_hortor-1.5.6.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

blender_mcp_hortor-1.5.6-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file blender_mcp_hortor-1.5.6.tar.gz.

File metadata

  • Download URL: blender_mcp_hortor-1.5.6.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for blender_mcp_hortor-1.5.6.tar.gz
Algorithm Hash digest
SHA256 269f5650d1cdffc1c7cbc0113438d796802e367c6f349bb344107abc6a51eb93
MD5 bce39f4d94c51f4d7edcd523b6ddc349
BLAKE2b-256 9bfe9f15b534e3811c89e7421a54eb4ba67a030f93c605f2ff83007ad0c3471f

See more details on using hashes here.

File details

Details for the file blender_mcp_hortor-1.5.6-py3-none-any.whl.

File metadata

File hashes

Hashes for blender_mcp_hortor-1.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 93739b4846ac8824b9d2b12ba27f61e1f244fa5160beb1408da4dcac7b8cf941
MD5 554d9ab10ca12101582a8c91f9a87e50
BLAKE2b-256 04afad3d0b171b779862b208ff76d64aa9aa9a6c23dea93519e26d3009c41cf5

See more details on using hashes here.

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