Blender-Mind-MCP
# Blender-Mind-MCP (Production AI 3D Modeling & Blender Bridge)
A production-grade Model Context Protocol (MCP) server and Blender Addon ecosystem for automated 3D modeling, procedural asset generation, shader authoring, and multimodal viewport inspection.
---
## ποΈ Prior Art & Architectural Inspiration
This project incorporates architectural lessons and benchmarks from leading GitHub Blender AI projects (such as `ahujasid/blender-mcp` and `djeada/blender-mcp-server`):
1. **Thread-Safe Main-Thread Dispatching**: Blenderβs Python C-API (`bpy`) is not thread-safe. As discovered in community issue audits, executing `bpy` calls inside raw socket listener threads triggers memory corruptions and segmentation faults. Our Blender Addon uses a thread-safe `queue.Queue` coupled with `bpy.app.timers` to ensure all scene modifications execute strictly in Blenderβs main render/GUI loop.
2. **Undo Step Isolation**: Every AI code execution is bracketed with `bpy.ops.ed.undo_push()`, enabling seamless `Ctrl+Z` rollbacks inside Blender.
3. **Multimodal Viewport Capture**: Uses offscreen OpenGL rendering (`bpy.ops.render.opengl`) to return Base64-encoded PNG screenshots of the 3D viewport directly to multimodal vision models.
4. **Hexagonal Architecture (Ports & Adapters)**: Decouples pure 3D geometry generation from physical drivers, supporting both Live Socket connections (`127.0.0.1:9876`), headless CLI batching (`blender -b`), and offline procedural glTF binary simulation.
---
## π¦ Project Structure
```
blender-mind-mcp/
βββ addon/
β βββ blender_mcp_addon.py # Full Blender 3.x/4.x Addon (UI Sidebar Panel, Socket Server, Viewport Capture)
βββ src/
β βββ index.ts # stdio JSON-RPC MCP Server entry point
β βββ bridge/
β β βββ socket_client.ts # Robust TCP Socket Client with reconnect & timeout handling
β βββ core/
β β βββ domain/
β β βββ types.ts # 3D Domain Types (Scene, Mesh, Material, Modifier, Transform)
β β βββ scene.ts # Pure in-memory 3D scene graph & polygon math
β β βββ bpy_generator.ts # Modern Blender 4.x/3.x Python code synthesizer
β βββ ports/
β β βββ driver.port.ts # BlenderDriverPort interface specification
β βββ adapters/
β β βββ live_socket.adapter.ts # Live Socket Adapter (talks to active Blender GUI)
β β βββ blender_cli.adapter.ts # Headless CLI Adapter (talks to blender.exe)
β β βββ mock_geometry.adapter.ts # Offline Simulation Adapter (glTF & OBJ binary synthesis)
β βββ tools/
β βββ index.ts # 10 MCP Tools registry & dispatcher
βββ tests/
β βββ unit/ # L1: Domain math & Python code generation
β βββ contract/ # L2: MCP tool schemas & argument contracts
β βββ integration/ # L3: Binary glTF headers & TCP Socket Bridge
β βββ run_tests.ts # Complete Truth Ladder test runner
βββ package.json
βββ tsconfig.json
```
---
## π Quick Start
### 1. Install Addon in Blender
1. Open Blender (3.6+ or 4.x).
2. Go to **Edit > Preferences > Add-ons > Install...** (or the Install from Disk arrow in 4.2+).
3. Select `addon/blender_mcp_addon.py`.
4. Enable **Development: Blender MCP Bridge**.
5. In the 3D Viewport, press `N` to open the sidebar, click the **Blender MCP** tab, and click **Start MCP Server**.
### 2. Configure MCP Client (Antigravity / Claude / Codex)
Add to your project or global MCP configuration (`.mcp.json`):
```json
{
"mcpServers": {
"blender": {
"command": "node",
"args": [
"--disable-warning=ExperimentalWarning",
"--experimental-strip-types",
"C:/Users/a1691/Documents/antigravity/noble-hypatia/src/index.ts"
]
}
}
}
```
---
## π οΈ 10 Core MCP Tools
| Tool Name | Description | Key Capabilities |
| :--- | :--- | :--- |
| `blender_create_primitive` | Create procedural 3D mesh | `cube`, `sphere`, `cylinder`, `torus`, `plane`, `cone`, `monkey` |
| `blender_apply_modifier` | Attach procedural modifiers | `subsurf`, `bevel`, `boolean`, `mirror`, `array`, `solidify` |
| `blender_procedural_material` | PBR Principled BSDF shader | `base_color`, `metallic`, `roughness`, `transmission` (glass), `emission` |
| `blender_setup_lighting` | Position & tune light sources | `SUN`, `POINT`, `SPOT`, `AREA` (wattage, radius, color tint) |
| `blender_setup_camera` | Camera framing & lens | `location`, `look_at` tracking, `focal_length` in mm |
| `blender_capture_viewport` | Visual viewport snapshot | Returns Base64 PNG image directly to multimodal LLMs |
| `blender_export_asset` | 3D model baking & export | `.glb`, `.gltf`, `.obj`, `.stl`, `.fbx` |
| `blender_inspect_scene` | Topology & scene tree inspection | Hierarchical object list, polycount, vertex count, modifiers |
| `blender_execute_bpy` | Raw parameter Python execution | Sandboxed execution with stdout/stderr capture |
| `blender_health` | System diagnostics | Reports active driver, port status, and Blender build |
---
## π§ͺ Truth Ladder Verification
```bash
npm test
```
Executes all 6 test suites across the 4-level Truth Ladder:
- **L1 Unit**: 100% pure domain modeling & Python code synthesizer AST checks.
- **L2 Contract**: Schema definitions and dispatch verification for all 10 tools.
- **L3 Integration**: Binary glTF v2 Header (`0x46546C67`) & OBJ structure validation.
- **L3 Integration**: Live TCP Socket Client-Server loopback test on `127.0.0.1:9899`.
- **L4 E2E**: Live stdio JSON-RPC pipe roundtrip.
TDQS
Scored across 10 tools
Each tool targets a distinct aspect of 3D workflow: camera setup, primitive creation, modifiers, materials, lighting, viewport capture, export, scene inspection, custom scripting, and health check. There is no functional overlap that would cause an agent to misselect a tool.
Almost all tools follow a consistent 'blender_verb_noun' pattern (setup_camera, create_primitive, export_asset, inspect_scene). Two exceptions exist: 'blender_procedural_material' lacks a verb, and 'blender_health' is a noun-only name, but they are still recognizable and do not break the overall pattern significantly.
With 10 tools, the set is well-scoped for a Blender integration. It covers the essential actions for scene creation, modification, inspection, and export without overwhelming bloat. Each tool earns its place, and the count is optimal for the domain.
The tool set covers the full modeling workflow: creating primitives, applying modifiers, materials, lighting, camera, viewport capture, export, and scene inspection. Minor gaps exist, such as direct editing of transforms or deletion of objects, but these can be managed via the custom `blender_execute_bpy` tool, so the surface is largely complete for typical tasks.