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") }

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