Skip to main content
Glama

exec_python

Execute Python code inside Unreal Engine to create assets in custom folders, specialized Blueprints, and bulk editor operations not covered by standard tools.

Instructions

Execute arbitrary Python code inside Unreal Engine via the Python plugin.

Use this tool when you need to:

  • Create assets in custom project folders (create_blueprint always uses /Game/Blueprints/)

  • Query engine version: import unreal; print(unreal.SystemLibrary.get_engine_version())

  • Count or list assets: unreal.EditorAssetLibrary.list_assets('/Game', recursive=True)

  • Create Widget Blueprints, Behavior Trees, Blackboards, Animation Blueprints (use the appropriate factory class since they cannot be created with create_blueprint)

  • Perform bulk operations not covered by other MCP tools

Args: code: Valid Python code string to execute inside UE5. The 'unreal' module is available automatically. Example: "import unreal; print(unreal.SystemLibrary.get_engine_version())"

Returns: dict with 'output' (captured stdout) and 'success' flag.

IMPORTANT: Always use exec_python for:

  • Assets outside /Game/Blueprints/ (specify full path via AssetTools)

  • Widget Blueprints (WidgetBlueprintFactory)

  • Behavior Trees / Blackboards (BehaviorTreeFactory / BlackboardDataFactory)

  • Animation Blueprints (AnimBlueprintFactory)

  • Checking existing assets before creating duplicates

KB: see knowledge_base/10_WORLD_BUILDING.md#overview Example: exec_python(code="Example")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.5/5.0
Behavior4/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. It discloses that the 'unreal' module is available automatically, that output is captured stdout with a success flag, and that the code executes inside UE5. It does not mention potential side effects, permissions, or error behavior beyond the success flag, but for an arbitrary code execution tool the description gives a reasonable behavioral contract. A 4 is appropriate because it adds meaningful context (return dict shape, module availability) beyond the schema, though it could disclose more about execution environment constraints.

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 well-structured with clear sections: a one-line summary, a bulleted use-case list, an Args section, a Returns section, an IMPORTANT callout, and an example. It is longer than minimal but every section earns its place by providing actionable guidance. The front-loading is good, though the example at the end is slightly redundant with the Args example.

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

Completeness4/5

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

Given the tool's complexity (arbitrary code execution) and the presence of an output schema, the description covers the essential context: what the tool is for, when to use it, what the parameter means, and what the return value looks like. It also references a knowledge base file. It could be more complete by describing error handling or execution limits, but for an agent selecting and invoking the tool, the description is sufficient.

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

Parameters4/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 does: it explains the 'code' parameter is a valid Python code string, gives an example, and notes the 'unreal' module is pre-imported. This adds real semantic value beyond the bare schema property name 'Code'. A 4 is warranted because the description provides example usage and context, though it could be even more explicit about parameter format edge cases.

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

Purpose5/5

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

The description clearly states the tool executes arbitrary Python code inside Unreal Engine via the Python plugin, with a specific verb ('Execute') and resource ('Python code inside Unreal Engine'). It distinguishes itself from siblings by explicitly listing use cases that other tools (like create_blueprint) cannot handle, such as creating assets in custom folders, Widget Blueprints, Behavior Trees, and bulk operations.

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

Usage Guidelines5/5

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

The description provides explicit when-to-use guidance with a bulleted list of scenarios, and even names the alternative (create_blueprint) and explains why exec_python is needed instead. It also includes an 'IMPORTANT' section reinforcing the conditions for using this tool over others, which is strong usage guidance.

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

Deploy Server

Other Tools