| .DS_Store | ||
| .gitignore | ||
| .python-version | ||
| blender_mcp_addon.py | ||
| blender_mcp_server.py | ||
| main.py | ||
| MCP.md | ||
| pyproject.toml | ||
| README.md | ||
| test_ping.py | ||
| test_scene_info.py | ||
| test_simple_info.py | ||
| test_socket_connection.py | ||
| uv.lock | ||
BlenderMCP Setup Guide
This guide will walk you through setting up BlenderMCP, which allows Claude to communicate with Blender through the Model Context Protocol (MCP).
Prerequisites
- Blender 3.0 or newer
- Python 3.9 or newer
- Claude Desktop or Cursor
- Basic familiarity with Blender and Python
Installation Steps
1. Install the BlenderMCP Addon in Blender
- Save the
blender_addon.pyfile to your computer - Open Blender
- Go to Edit > Preferences > Add-ons
- Click "Install..." and select the
blender_addon.pyfile - Enable the addon by checking the box next to "Interface: Blender MCP"
2. Set Up the MCP Server
-
Install the MCP Python package:
pip install "mcp[cli]" -
Save the
blender_mcp_server.pyfile to your computer -
Install the server in Claude Desktop:
mcp install blender_mcp_server.pyAlternatively, you can run the server in development mode:
mcp dev blender_mcp_server.py
3. Start the Blender Server
- In Blender, go to the 3D View
- Open the sidebar (press N if it's not visible)
- Select the "BlenderMCP" tab
- Click "Start MCP Server" (default port is 9876)
4. Connect Claude to Blender
- Open Claude Desktop
- The BlenderMCP server should now be available in Claude's MCP connections
- Start a conversation with Claude and you can now control Blender using natural language!
Usage Examples
Here are some examples of commands you can give Claude to control Blender:
Basic Scene Creation
Create a simple scene with a cube, sphere, and a ground plane.
Manipulating Objects
Move the cube 2 units up along the Z-axis.
Scale the sphere to be twice its current size.
Rotate the cylinder 45 degrees around the Y-axis.
Material Operations
Create a red glossy material and apply it to the cube.
Make the sphere blue with some metallic properties.
Rendering
Render the current scene and save it to my desktop.
Change the render resolution to 1920x1080 and render the scene.
Troubleshooting
MCP Server Connection Issues
If Claude can't connect to the MCP server:
- Make sure the Blender addon is running (check the BlenderMCP panel in Blender)
- Verify the port number in Blender matches what the MCP server is expecting (default: 9876)
- Restart the MCP server in Claude Desktop
- Restart Blender and try again
Addon Issues
If the Blender addon isn't working:
- Check the Blender system console for error messages
- Verify that the addon is enabled in Blender's preferences
- Try reinstalling the addon
Advanced Configuration
Customizing the Port
You can change the default port (9876) in the BlenderMCP panel in Blender. If you change this port, you'll need to update the BlenderConnection in the MCP server code accordingly.
Adding New Commands
The system is designed to be extensible. You can add new commands by:
- Adding new methods to the
BlenderMCPServerclass in the Blender addon - Adding corresponding tools or resources to the MCP server
Security Considerations
- The
execute_blender_codetool allows arbitrary code execution within Blender. Use with caution! - The socket connection between the MCP server and Blender is not encrypted or authenticated.
- Always review the commands Claude suggests before allowing them to execute in Blender.
BlenderMCP Usage Examples
These examples demonstrate the natural language capabilities and show how Claude can understand scene context and provide intelligent assistance.
Basic Scene Creation
Example 1: Creating a Simple Scene
User: "Create a basic scene with a cube sitting on a plane."
Claude's Understanding and Actions:
- Recognizes need for a ground plane and a cube object
- Creates a plane at origin with appropriate scale
- Creates a cube positioned above the plane
- Sets basic materials for visibility
- Ensures camera and lighting are properly positioned
MCP Tools Used:
create_objecttool for the plane and cubeset_materialtool for materialsmodify_objecttool for positioning
Example 2: Building a Table
User: "I want to create a simple table with four legs."
Claude's Understanding and Actions:
- Creates a flattened cube for the tabletop
- Creates four cylinders for table legs
- Positions legs at the corners of the tabletop
- Applies appropriate materials
- Reports back the created objects and their relationships
Implementation via BlenderMCP:
# Create tabletop
tabletop = blender.send_command("create_object", {
"type": "CUBE",
"name": "Tabletop",
"location": [0, 0, 1],
"scale": [2, 1, 0.1]
})
# Create and position legs
leg_positions = [
[1.8, 0.8, 0.5], # front-right
[1.8, -0.8, 0.5], # back-right
[-1.8, 0.8, 0.5], # front-left
[-1.8, -0.8, 0.5] # back-left
]
for i, pos in enumerate(leg_positions):
leg = blender.send_command("create_object", {
"type": "CYLINDER",
"name": f"Leg_{i+1}",
"location": pos,
"scale": [0.1, 0.1, 0.5]
})
Object Manipulation
Example 3: Moving and Scaling Objects
User: "Make the cube twice as big and move it 3 units higher."
Claude's Understanding and Actions:
- Identifies the cube in the scene
- Uses
modify_objecttool to scale it by a factor of 2 - Adjusts the z-coordinate to move it upward
- Reports the new position and scale
Example 4: Complex Transformation
User: "Arrange five spheres in a circular pattern around the origin."
Claude's Understanding and Actions:
- Calculates positions in a circular pattern using trigonometry
- Creates five spheres with appropriate positioning
- Possibly applies different materials for visibility
Implementation via BlenderMCP:
import math
# Calculate positions in a circle
radius = 3
num_spheres = 5
for i in range(num_spheres):
angle = 2 * math.pi * i / num_spheres
x = radius * math.cos(angle)
y = radius * math.sin(angle)
# Create sphere at calculated position
sphere = blender.send_command("create_object", {
"type": "SPHERE",
"name": f"Sphere_{i+1}",
"location": [x, y, 1],
"scale": [0.5, 0.5, 0.5]
})
# Apply different colors
hue = i / num_spheres
r, g, b = hsv_to_rgb(hue, 0.8, 0.8)
blender.send_command("set_material", {
"object_name": sphere["name"],
"color": [r, g, b]
})
Material and Appearance
Example 5: Creating and Applying Materials
User: "Create a glossy red material and apply it to the cube."
Claude's Understanding and Actions:
- Uses
set_materialtool with appropriate color values - May use
execute_blender_codefor more advanced material settings - Reports back the material creation and assignment
Example 6: Scene Lighting
User: "Make the scene brighter with a three-point lighting setup."
Claude's Understanding and Actions:
- Creates three lights (key, fill, and back)
- Positions them appropriately for three-point lighting
- Sets different intensities for each light
- May adjust the existing environment lighting
Implementation via BlenderMCP:
# Create key light (main light)
key_light = blender.send_command("create_object", {
"type": "LIGHT",
"name": "Key_Light",
"location": [4, -4, 5]
})
# Create fill light (softer, fills shadows)
fill_light = blender.send_command("create_object", {
"type": "LIGHT",
"name": "Fill_Light",
"location": [-4, -2, 3]
})
# Create back light (rim light)
back_light = blender.send_command("create_object", {
"type": "LIGHT",
"name": "Back_Light",
"location": [0, 5, 4]
})
# Set light properties using execute_code
blender.send_command("execute_code", {
"code": """
import bpy
# Set key light properties
key = bpy.data.objects['Key_Light']
key.data.energy = 1000
key.data.type = 'AREA'
# Set fill light properties
fill = bpy.data.objects['Fill_Light']
fill.data.energy = 400
fill.data.type = 'AREA'
# Set back light properties
back = bpy.data.objects['Back_Light']
back.data.energy = 600
back.data.type = 'AREA'
"""
})
Advanced Scene Creation
Example 7: Architectural Elements
User: "Create a simple house with walls, a roof, and windows."
Claude's Understanding and Actions:
- Creates multiple objects to form the structure
- Positions them according to architectural understanding
- Uses appropriate materials for different elements
- Reports the structure creation with a breakdown of elements
Example 8: Terrain Generation
User: "Can you create a simple mountain landscape?"
Claude's Understanding and Actions:
- Creates a plane as the base terrain
- Uses
execute_blender_codeto add displacement or sculpting - Applies appropriate textures and materials
- Sets up environment lighting for landscape visualization
Implementation via BlenderMCP:
# Create a plane for the terrain
terrain = blender.send_command("create_object", {
"type": "PLANE",
"name": "Terrain",
"location": [0, 0, 0],
"scale": [10, 10, 1]
})
# Use Python code to add subdivisions and displacement
blender.send_command("execute_code", {
"code": """
import bpy
import random
# Get the terrain object
terrain = bpy.data.objects['Terrain']
# Add subdivision modifier
subsurf = terrain.modifiers.new(name="Subdivision", type='SUBSURF')
subsurf.levels = 5
subsurf.render_levels = 5
# Add displacement modifier
displace = terrain.modifiers.new(name="Displace", type='DISPLACE')
# Create a new texture for displacement
tex = bpy.data.textures.new('Mountain', type='CLOUDS')
tex.noise_scale = 1.5
displace.texture = tex
displace.strength = 2.0
# Apply modifiers
bpy.context.view_layer.objects.active = terrain
bpy.ops.object.modifier_apply(modifier="Subdivision")
bpy.ops.object.modifier_apply(modifier="Displace")
# Set material
if 'Terrain_Mat' not in bpy.data.materials:
mat = bpy.data.materials.new(name="Terrain_Mat")
mat.use_nodes = True
bsdf = mat.node_tree.nodes.get('Principled BSDF')
bsdf.inputs[0].default_value = (0.08, 0.258, 0.12, 1.0) # Green color
terrain.data.materials.append(mat)
"""
})
Animation and Rendering
Example 9: Simple Animation
User: "Create a 30-frame animation of the cube rotating around the Y-axis."
Claude's Understanding and Actions:
- Sets up keyframes for the cube's rotation
- Configures animation settings
- Reports back the animation setup and how to play it
Implementation via BlenderMCP:
# Use execute_code to set up animation
blender.send_command("execute_code", {
"code": """
import bpy
import math
# Get the cube
cube = bpy.data.objects.get('Cube')
if not cube:
# Create a cube if it doesn't exist
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 1))
cube = bpy.context.active_object
cube.name = 'Cube'
# Set animation length
scene = bpy.context.scene
scene.frame_start = 1
scene.frame_end = 30
# Set first keyframe at frame 1
scene.frame_set(1)
cube.rotation_euler = (0, 0, 0)
cube.keyframe_insert(data_path="rotation_euler")
# Set final keyframe at frame 30
scene.frame_set(30)
cube.rotation_euler = (0, 2*math.pi, 0) # Full 360-degree rotation
cube.keyframe_insert(data_path="rotation_euler")
"""
})
Example 10: Rendering and Output
User: "Render the scene with a resolution of 1920x1080 and save it to my desktop."
Claude's Understanding and Actions:
- Uses
render_scenetool with appropriate parameters - Sets resolution and output path
- Initiates rendering process
- Reports back when rendering is complete
Debugging and Scene Analysis
Example 11: Scene Inspection
User: "What objects are currently in my scene?"
Claude's Understanding and Actions:
- Uses
get_scene_inforesource to fetch scene data - Analyzes the object list
- Provides a formatted summary of all objects, their types, and positions
Example 12: Troubleshooting
User: "Why can't I see the sphere in the render?"
Claude's Understanding and Actions:
- Uses resources to check scene and object information
- Checks visibility settings, materials, and camera position
- Provides diagnostic information and suggested fixes
Potential Fixes via BlenderMCP:
# Check sphere visibility and material
sphere_info = blender.send_command("get_object_info", {"name": "Sphere"})
# Make sure it's visible
if not sphere_info.get("visible", True):
blender.send_command("modify_object", {
"name": "Sphere",
"visible": True
})
# Check if it has a material, add one if missing
if not sphere_info.get("materials"):
blender.send_command("set_material", {
"object_name": "Sphere",
"color": [0.2, 0.4, 0.8]
})
# Check if it's in camera view
blender.send_command("execute_code", {
"code": """
import bpy
# Select sphere
sphere = bpy.data.objects.get('Sphere')
if sphere:
bpy.ops.object.select_all(action='DESELECT')
sphere.select_set(True)
# Frame selected in camera view
bpy.ops.view3d.camera_to_view_selected()
"""
})
Real-Time Collaboration
Example 13: Iterative Design
User: "I don't like how the table looks. Make the legs thicker and the tabletop wider."
Claude's Understanding and Actions:
- Identifies existing objects (tabletop and legs)
- Modifies their properties based on the feedback
- Shows before/after comparison and asks for further feedback
Example 14: Guided Tutorial
User: "I'm new to Blender. Can you help me create a simple character?"
Claude's Understanding and Actions:
- Breaks down the process into manageable steps
- Creates basic shapes for the character parts
- Guides through joining and posing
- Provides educational context along with actions
These examples showcase how Claude can interact with Blender through natural language using the BlenderMCP integration, providing an intuitive way to create and modify 3D content without needing to know the details of Blender's interface or Python API.