Skip to main content
Glama

ue_run_python

Execute Python scripts in the active Unreal Engine editor and return the script's serializable result variable to the caller, enabling editor automation and inspection.

Instructions

Execute Python in the active editor and return the script's result variable.

Use ue_capabilities() to check the binding. Assign a serializable value to result to return it to the caller. Native Python sends print output to LogPython and requires top-level imports. After execution_unknown, inspect the editor before repeating a script that changes assets.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "script": "<script>"
    },
    "name": "ue_run_python"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.1

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and does it well: it discloses the result-variable return convention, that print output is redirected to LogPython rather than returned, the top-level-import constraint of native Python, and the existence of an execution_unknown terminal state with follow-up advice for mutating scripts. These are non-obvious traits an agent cannot infer from the schema.

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?

Four short sentences, front-loaded with the core action, then the return convention, then execution caveats. No restatement of the name or filler; each sentence introduces a new constraint.

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?

An output schema exists, so return values need no further explanation, and the description still clarifies the result convention. For an arbitrary-code-execution tool with no annotations, it could say more about irreversibility, permissions, or what happens when no editor session is active.

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 and largely does: it explains what to do inside `script` (assign a serializable value to `result`, use top-level imports, prints are not returned). It still never states constraints on script size, allowed modules, or what 'serializable' excludes.

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 verb, resource, and scope: 'Execute Python in the active editor and return the script's result variable.' An agent can immediately tell this is arbitrary script execution against a connected editor rather than a structured API call like ue_call. The return mechanism is named, not implied.

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?

Gives two concrete usage conditions: call ue_capabilities() to check the binding first, and after an execution_unknown result inspect the editor before re-running a mutating script. It does not explain when to prefer this over ue_call or how to handle a not-connected editor, but the preconditions it does state are actionable.

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