Pervaiz106/Blender-Mcp-Server
If you are the rightful owner of Blender-Mcp-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Blender-MCP-Server is a comprehensive Model Context Protocol (MCP) server designed to facilitate AI systems in programmatically interacting with Blender's 3D creation capabilities.
Blender MCP Comprehensive Server
A production-ready Model Context Protocol (MCP) server providing comprehensive Blender integration with 47+ tools covering the complete 3D creation workflow from scene management to final rendering.
🌟 Overview
This comprehensive MCP server enables AI systems to programmatically interact with Blender's 3D creation capabilities through a secure, well-documented interface. It provides complete access to Blender's Python API (bpy) through categorized tools for different aspects of 3D modeling, animation, and rendering.
🚀 Features
Comprehensive Tool Set (47+ Tools)
🎬 Scene Management (8 tools)
create_scene- Create new Blender scenesset_scene_properties- Configure frame range and unitsget_scene_info- Get detailed scene informationduplicate_scene- Clone existing scenesdelete_scene- Remove scenes (with confirmation)set_world_properties- Configure world/environment settingsget_world_properties- Get current world settingsclear_scene- Remove all objects (with confirmation)
📦 Object Operations (9 tools)
create_object- Create geometric primitives and objectstransform_object- Move, rotate, and scale objectsdelete_object- Remove objects (with confirmation)duplicate_object- Clone objectsjoin_objects- Combine multiple objectsseparate_objects- Split mesh objectsparent_object- Create parent-child relationshipsunparent_object- Remove parent relationshipsget_object_info- Get detailed object information
🎨 Material Management (7 tools)
create_material- Create PBR materials with custom propertiesassign_material- Apply materials to objectsupdate_material_properties- Modify material settingsdelete_material- Remove materials (with confirmation)duplicate_material- Clone materialsget_material_info- Get material detailslist_materials- List all scene materials
🔧 Mesh Operations (6 tools)
edit_mesh- Perform mesh editing operations (subdivide, bevel, etc.)apply_modifier- Apply modifiers to objectsadd_modifier- Add modifiers without applyingremove_modifier- Remove modifiers (with confirmation)get_mesh_info- Get detailed mesh data (vertices, faces, etc.)remesh_object- Apply remeshing algorithms
🎬 Animation System (6 tools)
create_animation- Create complex animations with keyframesset_keyframes- Set individual transformation keyframesplay_animation- Start animation playbackstop_animation- Stop animation playbackclear_animation- Remove animation data (with confirmation)get_animation_info- Get animation details
🎨 Rendering Pipeline (5 tools)
render_scene- Render the current sceneset_render_settings- Configure render engine and qualityget_render_settings- Get current render configurationpreview_render- Create quick preview rendersget_render_preview- Get render preview as image
📁 File I/O Operations (4 tools)
import_file- Import 3D models (OBJ, FBX, GLTF, STL, etc.)export_file- Export objects to various formatssave_scene- Save .blend filesload_scene- Load .blend files (with confirmation)
📷 Camera & Lighting (4 tools)
create_camera- Create cameras with custom settingsset_active_camera- Set active camera for renderingsetup_lighting- Apply predefined lighting setupscreate_light- Create individual lights (sun, spot, point, area)
🔧 Utility Tools (Additional)
get_viewport_screenshot- Capture viewport screenshotsexecute_blender_code- Execute custom Python code in Blenderget_server_status- Get server and connection status
🏗️ Architecture
Core Components
- FastMCP Server - Built on the FastMCP 2.0 framework for production-ready MCP implementation
- Blender Connection - Socket-based communication with Blender addon
- Tool Categories - Organized tool sets for different 3D workflow stages
- Error Handling - Robust error handling with three-tier model
- Security - Input validation and confirmation mechanisms for destructive operations
Technology Stack
- FastMCP 2.0 - High-performance MCP framework
- Python 3.10+ - Modern Python with type hints
- Pydantic - Data validation and serialization
- Socket Communication - Real-time Blender integration
- Blender Python API (bpy) - Direct access to Blender functionality
📦 Installation
Prerequisites
- Blender 3.0+ with the MCP addon installed
- Python 3.10+
- uv package manager
Quick Start
- Clone or download the project:
# The server is ready to run from the project directory
cd blender-mcp-comprehensive
- Install dependencies:
# Dependencies will be installed automatically on first run
# or manually with:
uv sync
-
Start Blender with the MCP addon:
- Open Blender
- Install and enable the Blender MCP addon
- Click "Connect to Claude" in the addon panel
-
Run the MCP server:
# Using the startup script
sh run.sh
# Or directly with uv
uv run python -m src.blender_mcp_server.server
🔧 Configuration
Environment Variables
The server can be configured using environment variables:
# Blender connection settings
export BLENDER_HOST="localhost" # Default: localhost
export BLENDER_PORT="9876" # Default: 9876
MCP Client Configuration
For Claude Desktop integration, add to your claude_desktop_config.json:
{
"mcpServers": {
"blender-comprehensive": {
"command": "sh",
"args": ["/path/to/blender-mcp-comprehensive/run.sh"]
}
}
}
🚀 Usage
Basic Usage Examples
Create a Simple Scene
# Create a new scene
await client.call_tool("create_scene", {"name": "My Scene"})
# Add some objects
await client.call_tool("create_object", {
"object_type": "CUBE",
"name": "Building",
"location": [0, 0, 0]
})
await client.call_tool("create_object", {
"object_type": "SPHERE",
"name": "Planet",
"location": [5, 0, 2]
})
# Create and assign materials
await client.call_tool("create_material", {
"name": "Brick",
"base_color": [0.8, 0.3, 0.2],
"roughness": 0.8
})
await client.call_tool("assign_material", {
"object_name": "Building",
"material_name": "Brick"
})
Create an Animation
# Create orbital animation
keyframes = [
{"frame": 1, "location": [5, 0, 2], "interpolation": "BEZIER"},
{"frame": 100, "location": [0, 5, 2], "interpolation": "BEZIER"},
{"frame": 200, "location": [-5, 0, 2], "interpolation": "BEZIER"},
{"frame": 300, "location": [0, -5, 2], "interpolation": "BEZIER"},
{"frame": 400, "location": [5, 0, 2], "interpolation": "BEZIER"}
]
await client.call_tool("create_animation", {
"object_name": "Planet",
"animation_type": "LOCATION",
"keyframes": keyframes
})
Render a Scene
# Configure render settings
await client.call_tool("set_render_settings", {
"settings": {
"engine": "CYCLES",
"resolution_x": 1920,
"resolution_y": 1080,
"samples": 128
}
})
# Create preview render
await client.call_tool("preview_render", {"resolution": 800})
Advanced Usage
See the comprehensive examples in /examples/usage_examples.py which demonstrates:
- Complete workflow from scene creation to final render
- Advanced material creation and assignment
- Complex mesh operations and modifiers
- Sophisticated animation systems
- File I/O operations
- Camera and lighting setups
🧪 Testing
The server includes comprehensive test coverage:
Run Validation Tests
# Run all tests
cd blender-mcp-comprehensive
python -m pytest tests/ -v
# Run specific test categories
python -m pytest tests/test_blender_mcp_server.py::TestBlenderMCPServer::test_scene_management_tools -v
python -m pytest tests/test_blender_mcp_server.py::TestBlenderMCPServer::test_object_operations_tools -v
Test Categories
- Tool Validation - Ensures all 47+ tools are properly exposed
- Parameter Validation - Tests parameter handling and error cases
- Connection Testing - Validates Blender connectivity
- Integration Testing - Tests complete workflow scenarios
- Error Handling - Tests failure modes and recovery
🔒 Security
Safety Features
- Confirmation Requirements - Destructive operations require explicit confirmation
- Input Validation - All parameters are validated before processing
- Error Boundaries - Comprehensive error handling prevents crashes
- Sandboxed Execution - Operations run in controlled environment
- Connection Validation - Verifies Blender connectivity before operations
Safe Operations Example
# Destructive operations require confirmation
await client.call_tool("delete_object", {
"object_name": "ImportantObject",
"confirm": True # Required for deletion
})
await client.call_tool("clear_scene", {
"confirm": True # Required for clearing entire scene
})
🔧 Troubleshooting
Common Issues
Connection Problems
Error: "Failed to connect to Blender"
Solution: Ensure Blender is running with the MCP addon enabled and "Connect to Claude" is clicked.
Timeout Errors
Error: "Timeout waiting for Blender response"
Solution:
- Simplify requests by breaking complex operations into smaller steps
- Check Blender responsiveness
- Verify network connectivity
Permission Errors
Error: "Permission denied" during file operations
Solution:
- Check file paths and permissions
- Ensure output directories exist
- Run with appropriate user permissions
Debug Mode
Enable detailed logging:
export BLENDER_MCP_DEBUG=1
sh run.sh
📚 API Reference
Tool Categories
Scene Management
- create_scene(name) - Create new scene
- set_scene_properties(frame_start, frame_end, frame_current, units) - Configure scene
- get_scene_info() - Get scene information
- duplicate_scene(source_name, new_name) - Clone scene
- delete_scene(scene_name, confirm=True) - Delete scene
- set_world_properties(color, background_type) - Configure environment
- get_world_properties() - Get world settings
- clear_scene(confirm=True) - Clear all objects
Object Operations
- create_object(object_type, name, location) - Create objects
- transform_object(object_name, location, rotation, scale) - Transform objects
- delete_object(object_name, confirm=True) - Delete objects
- duplicate_object(source_name, new_name) - Clone objects
- join_objects(object_names, joined_name) - Combine objects
- separate_objects(object_name, mode) - Split objects
- parent_object(child_name, parent_name, keep_transform) - Set hierarchy
- unparent_object(child_name, keep_transform) - Remove hierarchy
- get_object_info(object_name) - Get object details
[Additional tool documentation available in source code]
🤝 Contributing
Development Setup
- Clone the repository
- Install development dependencies:
uv sync --dev
- Run tests:
python -m pytest tests/ -v
- Code formatting:
black src/ tests/
ruff check src/ tests/
Adding New Tools
- Add tool function with
@mcp.tooldecorator - Include comprehensive docstring with parameters
- Add parameter validation and error handling
- Write tests for the new tool
- Update documentation
Code Style
- Follow PEP 8 style guidelines
- Use type hints for all parameters and returns
- Include comprehensive docstrings
- Write unit tests for new functionality
- Maintain backward compatibility
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
- FastMCP Team - For the excellent MCP framework
- Blender Foundation - For the powerful 3D creation suite
- MCP Community - For protocol standardization
- Python Ecosystem - For robust development tools
📞 Support
- Documentation: Comprehensive examples and API reference included
- Testing: Full test suite for validation
- Issues: Report bugs and feature requests through GitHub issues
- Community: Join discussions in the MCP community channels
Built with ❤️ by MiniMax Agent
Enabling AI-powered 3D creation through comprehensive Blender integration.