Skip to main content
Glama

execute_blender_code

Execute Python code directly within Blender to automate 3D modeling tasks, manipulate IFC building models, and control Blender's functionality programmatically.

Instructions

Execute arbitrary Python code in Blender.

Parameters:
- code: The Python code to execute

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The primary handler implementation for the 'execute_blender_code' MCP tool. This function is decorated with @mcp.tool(), receives the code parameter, establishes a connection to Blender, sends an 'execute_code' command with the provided code, and returns the execution result or an error message.
    @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)}"
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('execute arbitrary Python code') but provides no information about security implications, execution environment, error handling, side effects, or what happens to Blender's state. For a code execution tool with zero annotation coverage, this is a significant gap in safety and behavior disclosure.

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 concise with two sentences that directly address purpose and parameters. The structure is clear with purpose first, then parameter documentation. There's no wasted text, though it could benefit from more context given the tool's complexity. Every sentence serves a functional purpose.

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?

For a code execution tool with no annotations, no output schema, and significant behavioral implications, the description is incomplete. It doesn't address critical context like execution safety, environment details, return values, error conditions, or how this integrates with Blender's state. The description provides only basic operational information without the necessary context for safe and effective use.

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 explicitly documents the single parameter ('code: The Python code to execute'), adding meaning beyond the schema which has 0% description coverage. However, it provides minimal semantic context - no examples, no constraints on what code is valid, no mention of Blender API availability, or execution scope. The description compensates for the schema gap but only at a basic level.

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 as 'Execute arbitrary Python code in Blender' - a specific verb ('execute') with resource ('Python code') and context ('in Blender'). It distinguishes itself from sibling tools which are all export/get/list operations focused on IFC data, making this the only code execution tool. However, it doesn't explicitly contrast with siblings beyond the inherent difference in function.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. While it's clearly different from all sibling tools (which handle IFC data export/query), there's no explicit when/when-not guidance, no mention of prerequisites, and no discussion of alternative approaches for similar functionality. The agent must infer usage context from the tool name alone.

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/JotaDeRodriguez/Bonsai_mcp'

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