Skip to main content

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

  1. Start the server:

    python server.py
    
  2. Connect to the server using an MCP client (like Claude Desktop)

  3. Use the provided tools to manage scripts:

    • add_script(name, content) - Add a new script
    • edit_script(name, content) - Edit an existing script
    • execute_script(name, blend_file=None) - Execute a script in Blender, optionally specifying a .blend file
    • remove_script(name) - Remove a script
  4. Access resources to get information:

    • scripts://list - Get list of available scripts
    • script://{name} - Get content of a specific script
    • result://{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

  1. When a script is added, it's stored in the script_files/scripts directory
  2. 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
  3. Output and errors are captured and stored in the script_files/results directory
  4. Metadata about scripts is tracked in script_files/metadata.json

Installation

  1. Clone this repository
  2. Install the MCP library: pip install mcp
  3. 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

iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 26.5 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

Hashes for iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe927b74c3f728dd2afbe82da26ae7f73bf6e6c669e82dda0c38846976de47e0
MD5 31eb12ebc351df997c65060f562f25d1
BLAKE2b-256 f13c7660ae3d1243312ec7b823aa0325496746878ea94aa4791d56cd0893556c

See more details on using hashes here.

File details

Details for the file iflow_mcp_cwahlfeldt_blender_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_cwahlfeldt_blender_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.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

Hashes for iflow_mcp_cwahlfeldt_blender_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebc8900b61528d7c3f6ec0489cef7e12716df1263f41db3e991b649e329fe626
MD5 9c3054e23b07ec3135988c895b7bbc5e
BLAKE2b-256 239d13bd36a5bc3eebb03f1f3b17b38e254841adcee507b4b7539815f97704eb

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