Skip to main content
Glama

execute_blender_code

Run Python code within Blender to automate 3D modeling tasks, manipulate objects, control materials, and manage scenes through script execution.

Instructions

Execute arbitrary Python code in Blender. Make sure to do it step-by-step by breaking it into smaller chunks.

Parameters:
- code: The Python code to execute

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The main handler function for the 'execute_blender_code' tool. It connects to Blender via a persistent socket connection and sends the provided Python code to be executed in Blender using the 'execute_code' command. Returns success message or error.
    @mcp.tool()
    def execute_blender_code(ctx: Context, code: str) -> str:
        """
        Execute arbitrary Python code in Blender. Make sure to do it step-by-step by breaking it into smaller chunks.
        
        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)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions executing 'arbitrary Python code' and suggests a step-by-step approach, but fails to cover critical traits like safety (e.g., potential for destructive operations), permissions, error handling, or output format. This is a significant gap for a tool with such open-ended functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences: one stating the purpose and one offering usage advice. It's front-loaded with the core function, and the second sentence adds value without redundancy. There's minimal waste, though it could be slightly more structured (e.g., bullet points).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's high complexity (executing arbitrary code) and lack of annotations or output schema, the description is insufficient. It doesn't address risks, expected outputs, error conditions, or how results are returned, making it incomplete for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists the single parameter 'code' and explains it as 'The Python code to execute,' adding basic meaning beyond the schema's title 'Code.' However, it doesn't provide details on code format, constraints, or examples, leaving the parameter only partially documented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Execute arbitrary Python code in Blender.' It specifies the verb ('Execute') and resource ('Python code in Blender'), making the function unambiguous. However, it doesn't explicitly differentiate from siblings like 'get_object_info' or 'set_texture,' which are more specific operations rather than general code execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by suggesting to 'break it into smaller chunks' for step-by-step execution, which hints at best practices for this tool. However, it lacks explicit when-to-use rules, alternatives (e.g., vs. other Blender tools), or exclusions, leaving the agent to infer context from the sibling list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/drrodingo-del/BlenderMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server