Skip to main content
Glama
README.md
# Blender MCP - Claude's Creative Toolkit

Comprehensive Blender integration for Claude AI through the Model Context Protocol (MCP).

## Features

### Core Operations
- **Scene Management**: Get scene info, object details, viewport screenshots
- **Code Execution**: Run arbitrary Python code in Blender's environment

### Object Operations
- Create primitives (cube, sphere, cylinder, torus, etc.)
- Modify transforms (location, rotation, scale)
- Duplicate and delete objects
- Selection and active object management

### Modeling
- Add and apply modifiers (subdivision, bevel, mirror, array, etc.)
- Boolean operations (union, difference, intersect)
- Mesh editing (subdivide, extrude)

### Materials
- Create and apply materials
- Set PBR properties (color, metallic, roughness)

### Animation
- Insert keyframes for any property
- Set frame range
- Animate with Mixamo FBX (via CSM.ai integration)

### Rendering
- Configure render settings (engine, resolution, samples)
- Render still images
- Render animations to video

### Export
- FBX export (with animation support)
- glTF/GLB export (for web and game engines)
- OBJ export (universal compatibility)

### Asset Sources (Integrations)
- **PolyHaven**: Free HDRIs, textures, and 3D models
- **Sketchfab**: Downloadable 3D models
- **CSM.ai**: 3D models and animation
- **Hyper3D Rodin**: Text/Image-to-3D generation
- **Hunyuan3D**: AI 3D generation

## Installation

### 1. Install the MCP Server

```bash
cd blender_mcp
pip install -e .
```

Or install directly:
```bash
pip install blender-mcp
```

### 2. Install the Blender Addon

1. Open Blender
2. Go to Edit > Preferences > Add-ons
3. Click "Install..." and select `src/blender_mcp/addon.py`
4. Enable "Claude Creative Toolkit - MCP Bridge"

The addon will auto-start a socket server on port 9876.

### 3. Configure Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "blender": {
      "command": "blender-mcp",
      "args": []
    }
  }
}
```

Or with Python:
```json
{
  "mcpServers": {
    "blender": {
      "command": "python",
      "args": ["-m", "blender_mcp"]
    }
  }
}
```

## Usage

### Basic Workflow

1. Start Blender with the addon enabled
2. The socket server starts automatically
3. Use Claude to interact with Blender

### Example Commands

```
"Create a red sphere at position (0, 0, 2)"
"Add a subdivision surface modifier with 2 levels"
"Render the scene to PNG"
"Export the selected objects to GLB format"
```

### Advanced: Execute Custom Code

The `execute_blender_code` tool allows running any Blender Python:

```python
# Create a custom procedural mesh
import bpy
import bmesh

mesh = bpy.data.meshes.new("CustomMesh")
obj = bpy.data.objects.new("CustomObject", mesh)
bpy.context.collection.objects.link(obj)

bm = bmesh.new()
bmesh.ops.create_icosphere(bm, subdivisions=3, radius=1.0)
bm.to_mesh(mesh)
bm.free()
```

## Architecture

```
┌─────────────────┐     Socket      ┌─────────────────┐
│  MCP Server     │ ←───────────────→│  Blender Addon  │
│  (server.py)    │    Port 9876    │  (addon.py)     │
└────────┬────────┘                 └────────┬────────┘
         │                                   │
         │ MCP Protocol                      │ bpy API
         │                                   │
    ┌────▼────┐                         ┌────▼────┐
    │ Claude  │                         │ Blender │
    └─────────┘                         └─────────┘
```

## Environment Variables

- `BLENDER_HOST`: Socket host (default: localhost)
- `BLENDER_PORT`: Socket port (default: 9876)

## API Keys for Integrations

Set in Blender addon preferences or environment:

- `POLYHAVEN_API_KEY`: PolyHaven access
- `SKETCHFAB_API_KEY`: Sketchfab downloads
- `CSM_API_KEY`: CSM.ai access
- `HYPER3D_API_KEY`: Hyper3D Rodin access
- `HUNYUAN3D_API_KEY`: Hunyuan3D access

## Compatibility

- Blender 4.0+
- Python 3.10+
- Tested with Blender 5.0

## License

MIT