MCP server for executing Blender scripts
Project description
Blender MCP Server
A Model Context Protocol (MCP) server for managing and executing Blender scripts.
Features
- Add, edit, execute, and remove Blender Python scripts
- Execute scripts in a headless Blender environment
- View execution results and errors
- Track script metadata (creation date, last modified, execution count)
Requirements
- Python 3.7+
- Blender installed and accessible
- MCP library (
pip install mcp)
Usage
-
Start the server:
python server.py -
Connect to the server using an MCP client (like Claude Desktop)
-
Use the provided tools to manage scripts:
add_script(name, content)- Add a new scriptedit_script(name, content)- Edit an existing scriptexecute_script(name, blend_file=None)- Execute a script in Blender, optionally specifying a .blend fileremove_script(name)- Remove a script
-
Access resources to get information:
scripts://list- Get list of available scriptsscript://{name}- Get content of a specific scriptresult://{name}- Get execution result of a script
Examples
Basic Example
# Add a simple script
add_script("hello_cube", '''
import bpy
# Clear existing objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Create a cube
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
print("Cube created!")
''')
# Execute the script
execute_script("hello_cube")
# Get the result
# Access using: result://hello_cube
Working with Blend Files
# Add a script that works with a blend file
add_script("analyze_scene", '''
import bpy
# Print information about the current scene
print(f"Current Blender version: {bpy.app.version_string}")
print(f"Current file: {bpy.data.filepath}")
# List all objects in the scene
print("\\nObjects in the scene:")
for obj in bpy.data.objects:
print(f" - {obj.name} ({obj.type})")
''')
# Execute with a specific blend file
execute_script("analyze_scene", blend_file="/path/to/your/project.blend")
# Get the result
# Access using: result://analyze_scene
How It Works
- When a script is added, it's stored in the
script_files/scriptsdirectory - When executed, the script is run in a headless Blender instance
- If a blend file is specified, Blender will open that file before running the script
- Otherwise, a default empty Blender scene is used
- Output and errors are captured and stored in the
script_files/resultsdirectory - Metadata about scripts is tracked in
script_files/metadata.json
Installation
- Clone this repository
- Install the MCP library:
pip install mcp - Ensure Blender is installed and accessible from your PATH
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_cwahlfeldt_blender_mcp-0.1.3.tar.gz.
File metadata
- Download URL: iflow_mcp_cwahlfeldt_blender_mcp-0.1.3.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60fe671eb55ed6fcf8240e7e42a26bc755f6ec09a2af689aa5e9c2f497b43847
|
|
| MD5 |
dbe225543a9c74152608131f2da83886
|
|
| BLAKE2b-256 |
67a761b60bfb37a580c8f6a17504c9c2d8fbd97092f6b8a660be02b903fa6be6
|
File details
Details for the file iflow_mcp_cwahlfeldt_blender_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_cwahlfeldt_blender_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dd112ae335e11c5d643fd0c26f37e4668d62168ca9596090658c8e4500a4bf0
|
|
| MD5 |
8706b3aaf35d3fb60106b2c576c4f335
|
|
| BLAKE2b-256 |
ef179180875ffd8d7f03f951e87d4faf0d2bb150303ed7fbd5066c7b736cb592
|