Skip to main content
Glama

editor_run_python

Execute Python code directly within Unreal Editor to automate tasks, manipulate assets, or extend functionality using the Unreal Python API.

Instructions

Execute any python within the Unreal Editor. All python must have import unreal at the top. CHECK THE UNREAL PYTHON DOCUMENTATION BEFORE USING THIS TOOL. NEVER EVER ADD COMMENTS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • Registration of the 'editor_run_python' tool using McpServer.tool, including inline handler and schema.
    	"editor_run_python",
    	"Execute any python within the Unreal Editor. All python must have `import unreal` at the top. CHECK THE UNREAL PYTHON DOCUMENTATION BEFORE USING THIS TOOL. NEVER EVER ADD COMMENTS",
    	{ code: z.string() },
    	async ({ code }) => {
    		const result = await tryRunCommand(code)
    
    		return {
    			content: [{ type: "text", text: result }],
    		}
    	},
    )
  • Handler function that takes Python code input and executes it via tryRunCommand, returning the output as text.
    async ({ code }) => {
    	const result = await tryRunCommand(code)
    
    	return {
    		content: [{ type: "text", text: result }],
    	}
    },
  • Input schema defining 'code' as a string (the Python code to execute).
    { code: z.string() },
  • Helper function used by the tool (and others) to execute commands on the remote Unreal Engine node via RemoteExecution.
    const tryRunCommand = async (command: string): Promise<string> => {
    	if (!remoteNode) {
    		throw new Error("Remote node is not available")
    	}
    
    	const result = await remoteNode.runCommand(command)
    	if (!result.success) {
    		throw new Error(`Command failed with: ${result.result}`)
    	}
    
    	return result.output.map((line) => line.output).join("\n")
    }
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 mentions the requirement for `import unreal` and the no-comments rule, which adds some context beyond basic execution. However, it fails to disclose critical traits like whether this is read-only or destructive (Python code could modify the editor state), error handling, performance impacts, or authentication needs. For a tool that executes arbitrary code, this is a significant gap.

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

Conciseness3/5

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

The description is brief but front-loaded with the core purpose. However, the second sentence about `import unreal` and the third about documentation/comment rules are somewhat redundant or could be integrated more smoothly. The all-caps 'NEVER EVER ADD COMMENTS' is attention-grabbing but disrupts flow. It's concise but not optimally structured.

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?

Given the complexity (executing arbitrary Python in Unreal Editor), no annotations, no output schema, and low schema coverage, the description is incomplete. It misses key details: what the tool returns (e.g., output, errors), safety warnings (destructive potential), prerequisites, or examples. The documentation reference helps but doesn't substitute for basic completeness in the description itself.

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 input schema has 1 parameter with 0% description coverage, so the description must compensate. It implies the 'code' parameter is Python code and specifies the `import unreal` requirement, adding some meaning. However, it doesn't detail the code format, length limits, or expected outputs, leaving the parameter partially documented. This meets the baseline for low schema coverage but doesn't fully compensate.

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 action ('Execute any python') and target environment ('within the Unreal Editor'), which is specific and actionable. It distinguishes from siblings like editor_console_command (console commands) and editor_create_object (specific object creation), though not explicitly. However, it doesn't fully differentiate from potential Python-based siblings (none listed), keeping it at 4 rather than 5.

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

Usage Guidelines3/5

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

The description provides implied usage guidelines: it mentions 'All python must have `import unreal` at the top' and references documentation, suggesting when to use it (for Python execution in Unreal). However, it lacks explicit alternatives (e.g., vs. editor_console_command for non-Python tasks) or clear exclusions, leaving some ambiguity. The 'NEVER EVER ADD COMMENTS' is a constraint but not a usage guideline per se.

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/runreal/unreal-mcp'

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