Skip to main content
Glama

execute_blender_code

Execute Python code directly in Blender to automate 3D modeling, scene manipulation, and rendering tasks through AI-assisted control.

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 core handler function for the 'execute_blender_code' tool. It uses a socket connection to send the provided Python code to the Blender addon for execution and returns the result or error message.
    @telemetry_tool("execute_blender_code")
    @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)}"
  • The @mcp.tool() decorator registers the execute_blender_code function as an MCP tool.
    @mcp.tool()
  • Docstring defining the tool's input parameters and description, serving as the schema.
    """
    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
    """
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 advises step-by-step execution, but fails to disclose critical behavioral traits such as security implications, execution environment details, error handling, permissions required, or potential side effects (e.g., modifying Blender scenes). This leaves significant gaps for an agent to understand the tool's behavior.

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 and front-loaded: the first sentence states the core purpose, followed by a usage tip and parameter explanation. It avoids unnecessary details, but the parameter section could be more integrated. Overall, it's efficient with little waste.

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 complexity of executing arbitrary code in Blender, no annotations, 0% schema coverage, and no output schema, the description is incomplete. It lacks information on return values, error conditions, execution limits, or safety considerations, which are crucial for an agent to use this tool effectively. The description does not compensate for these gaps adequately.

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?

The description adds minimal meaning beyond the input schema: it defines the 'code' parameter as 'The Python code to execute,' which is straightforward but doesn't elaborate on format, constraints, or examples. With 0% schema description coverage and 1 parameter, the baseline is 4, but the description only partially compensates by stating the parameter's purpose without deeper context, resulting in a score of 3.

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 it distinct from sibling tools which focus on downloading, generating, importing, or querying assets rather than code execution. However, it doesn't explicitly differentiate from hypothetical similar code-execution tools, though none exist among the siblings.

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: 'Make sure to do it step-by-step by breaking it into smaller chunks.' This suggests a best practice for using the tool, but it doesn't explicitly state when to use this tool versus alternatives (e.g., for code execution vs. asset manipulation) or list any exclusions. No clear alternatives or context for tool selection are mentioned.

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/ahujasid/blender-mcp'

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