execute_blender_code
Run Python code directly in Blender through the Tripo MCP Server, enabling 3D asset generation and manipulation from natural language prompts.
Instructions
Execute arbitrary Python code in Blender.
Parameters:
- code: The Python code to execute
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- src/server.py:448-465 (handler)The handler function decorated with @mcp.tool(), which sends the provided Python code to the Blender addon via socket connection for execution. This implements the core logic of the tool.@mcp.tool() def execute_blender_code(ctx: Context, code: str) -> str: """ Execute arbitrary Python code in Blender. Parameters: - code: The Python code to execute """ try: # Get the global connection blender = get_blender_connection() result = blender.send_command("execute_code", {"code": code}) return f"Code executed successfully: {result.get('result', '')}" except Exception as e: logger.error(f"Error executing code: {str(e)}") return f"Error executing code: {str(e)}"