Skip to main content
Glama

ue_exec_safe

Run Python code in Unreal Engine and receive a structured JSON result with errors, warnings, and logs. It wraps your snippet in automatic error handling to prevent parse failures.

Instructions

Run a Python snippet inside Unreal Engine with automatic structured error handling.

Unlike the raw exec_python, this tool:

  • Wraps code in a try/except that always produces valid JSON

  • Returns a normalised StructuredResult with success, stage, message, outputs, warnings, errors, and log_tail

  • Is safe to call from the AI without worrying about parse failures

Your code should populate these variables: _result : dict — key/value outputs to return to the caller _warnings : list — non-fatal warnings _errors : list — error messages (also raised via exception)

Example code: import unreal bp = unreal.load_asset('/Game/Blueprints/BP_Player') if bp: _result['class_name'] = bp.get_class().get_name() else: _errors.append('Blueprint not found')

Args: code: Python snippet to execute in Unreal Engine stage_name: Descriptive name for the operation (used in result.stage)

Returns: JSON string with StructuredResult: { "success": true, "stage": "script", "message": "Operation completed", "outputs": {...}, "warnings": [], "errors": [], "log_tail": [] }

KB: see knowledge_base/32_AGENT_PLAYABLE_SLICE_RECIPE.md#overview Example: ue_exec_safe(code="Example")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
stage_nameNoscript

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior4/5

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

Since no annotations are provided, the description carries the full behavioral burden, and it largely succeeds: it discloses the try/except wrapper, always-valid JSON guarantee, normalized StructuredResult fields, and the expected _result/_warnings/_errors variable contract. It does not discuss side effects or rollback risks of arbitrary Python execution, which is a notable omission, but the behavior is still well documented.

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

Conciseness5/5

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

The description is front-loaded with the core purpose and differentiation, then moves through behavior, code contract, args, return format, KB pointer, and example in a scannable structure. While longer than a simple tool description, every section earns its place for a Python-execution tool.

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

Completeness5/5

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

Given sparse schemas, no annotations, and a non-trivial code-authoring contract, the description covers inputs, output structure, error semantics, expected variables, and usage context. An agent has enough information to call the tool correctly and interpret its result.

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

Parameters5/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 define the parameters itself. It explains code as a Python snippet, documents the variables the snippet should populate, and defines stage_name as the operation name used in result.stage. The worked example further clarifies expected usage.

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?

States a specific action (“Run a Python snippet”) and resource (“inside Unreal Engine”), then immediately distinguishes itself from the sibling exec_python by describing its structured error-handling behavior. The tool's purpose is clear and unlikely to be confused with other siblings.

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

Usage Guidelines4/5

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

The description explicitly contrasts the tool with “raw exec_python” and highlights when this variant is preferable, i.e., when the AI needs structured results and protection from parse failures. It does not explicitly state when raw exec_python would be the better choice, but the guidance is otherwise clear.

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