Skip to main content

Automate Blender workflows with external Python control, background operation, and LLM integration

Project description

blender-remote

Control Blender remotely using Python API and LLM through MCP (Model Context Protocol).

Key Features

1. Dual Control Interface: Python API + LLM

Use both Python API and LLM simultaneously to control Blender. The MCP protocol enables LLMs to experiment with Blender operations and help you create new APIs based on their interactions.

# Python API
import blender_remote
client = blender_remote.connect_to_blender(port=6688)
scene_manager = blender_remote.create_scene_manager(client)
cube_name = scene_manager.add_cube(location=(2, 0, 0), size=1.5)
# LLM via MCP
uvx blender-remote  # Start MCP server for Claude, VSCode, Cursor, etc.

2. Background Mode Support

Run Blender completely headless for automation without GUI.

# GUI mode with auto-start service
export BLD_REMOTE_MCP_START_NOW=1
blender &

# Background mode for automation
blender --background --python start_service.py &

Installation

pip install blender-remote

Quick Start

1. Install Blender Addon

Option A: Automated (Recommended)

blender-remote-cli init /path/to/blender
blender-remote-cli install

Option B: Manual

cd blender-remote/blender_addon/
zip -r bld_remote_mcp.zip bld_remote_mcp/
# Install via Blender: Edit > Preferences > Add-ons > Install > Enable "BLD Remote MCP"

2. Start Blender with Service

# GUI mode
export BLD_REMOTE_MCP_START_NOW=1
blender &

# Background mode
echo 'import bld_remote; bld_remote.start_mcp_service()' > start_service.py
blender --background --python start_service.py &

3. Use Python API

import blender_remote

# Connect to Blender
client = blender_remote.connect_to_blender(port=6688)

# High-level scene operations
scene_manager = blender_remote.create_scene_manager(client)
cube_name = scene_manager.add_cube(location=(0, 0, 0), size=2.0)
scene_manager.set_camera_location(location=(7, -7, 5), target=(0, 0, 0))

# Direct code execution
result = client.execute_python("bpy.ops.mesh.primitive_sphere_add()")

4. Use with LLM

Configure LLM IDE (VSCode/Claude/Cursor):

{
  "mcpServers": {
    "blender-remote": {
      "command": "uvx",
      "args": ["blender-remote"]
    }
  }
}

Then ask your LLM:

  • "What objects are in the current Blender scene?"
  • "Create a blue metallic cube at position (2, 0, 0)"
  • "Show me the current viewport"
  • "Help me create a new API function for batch object creation"

Available MCP Tools

Tool Description
get_scene_info() List all objects, materials, and scene properties
get_object_info(name) Get detailed object properties
execute_blender_code(code) Run Python code in Blender context
get_viewport_screenshot() Capture viewport image (GUI mode only)
check_connection_status() Verify service health

How It Works

External Python ←─────┐
                      │
LLM (Claude/VSCode) ←─┼─→ MCP/JSON-TCP (port 6688) ←─ BLD_Remote_MCP (addon)
                      │                                      ↓
Python Control API ←──┘                               Blender Python API
                                                             ↓
                                                     Blender (GUI/background)

Example: LLM-Assisted API Development

  1. LLM experiments: "Try creating 10 cubes in a grid pattern"
  2. LLM observes: Uses execute_blender_code() to test different approaches
  3. LLM creates API: "Based on what worked, let me create a create_cube_grid() function"
  4. You integrate: Add the LLM-created function to your Python automation

CLI Configuration Tool

# Setup and management
blender-remote-cli init /path/to/blender
blender-remote-cli install
blender-remote-cli start --background
blender-remote-cli config set mcp_service.default_port=7777
blender-remote-cli status

Socket-Level Communication

import socket, json

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 6688))
command = {"type": "execute_code", "params": {"code": "bpy.ops.mesh.primitive_cube_add()"}}
sock.send(json.dumps(command).encode())
response = json.loads(sock.recv(4096).decode())
sock.close()

Documentation

License

MIT License

Credits

Inspired by ahujasid/blender-mcp with enhanced background mode support, thread-safe operations, and production-ready deployment.

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

blender_remote-1.2.0rc3.tar.gz (90.7 kB view details)

Uploaded Source

Built Distribution

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

blender_remote-1.2.0rc3-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file blender_remote-1.2.0rc3.tar.gz.

File metadata

  • Download URL: blender_remote-1.2.0rc3.tar.gz
  • Upload date:
  • Size: 90.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for blender_remote-1.2.0rc3.tar.gz
Algorithm Hash digest
SHA256 5be67b699a0922b641da4c411f4c35d7a36e00569d4e84f3e20eb5f10d1f58c1
MD5 b966571a996728be7e4d25c63c45744e
BLAKE2b-256 2ea314fea9a7917c5bf0c05ae268c8825ec2fd9e4e3af28e49dc1faf6a7ad6dd

See more details on using hashes here.

File details

Details for the file blender_remote-1.2.0rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for blender_remote-1.2.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 1dd8e3e4ff83da33e18fb5a631477459509313de4686794755af2d1119b8b6d9
MD5 3251ae007723439e51c173e080f556e1
BLAKE2b-256 24e7e5db08890ef293ae3e92f3fdb560d8742112fd4e9296f4951dd034d28b29

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