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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |