Made an UnrealEngineMCP Plugin for Unreal Engine

Words: 968

UE5.8 already ships official MCP support; this plugin is my own implementation that follows its design ideas, mainly for cases where the engine can’t be upgraded yet.

If you’re on UE5.8 or above, just use the official plugin — treat what follows as a record of the implementation approach.

Recently I gave the AI coding assistant in our project a new capability: letting it operate a UE project directly inside the editor. The motivation is simple. Large models are already good at editing code, but a lot of game development work isn’t in code — Blueprints, assets, UMG widgets, Level Actors, all these visual assets are out of reach for an AI that can only edit .cpp / .h. So I built an UnrealEngineMCP plugin that exposes these editor capabilities to AI assistants (opencode, Claude Code, and the like) via MCP (Model Context Protocol).

Architecture

Three layers in total:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
AI 助手 (opencode / Claude Code)
        │  MCP stdio(始终在线)
        ▼
unreal-mcp wrapper  (Node.js, Tools/mcp-wrapper/)
        │  • 编辑器未启动时自动拉起
        │  • 发现多个编辑器实例,可指定操作目标
        │  • 把 MCP 调用翻译成极简 HTTP JSON 后端
        ▼
UnrealEngineMCP 插件  (C++,运行在编辑器内)
        │  GET  /api/health
        │  GET  /api/tools
        │  POST /api/tools/call
        ▼
    引擎 Python / 蓝图 / 资产 API

While building it I split “protocol” from “tools”: the plugin acts only as a tool backend, and the MCP protocol layer is left to the Node wrapper. The reason is simple too: UE 5.7’s HTTPServer module doesn’t support SSE streaming, and MCP depends on streaming. Rather than wrestling with the protocol inside the plugin, put protocol parsing in the wrapper (Node + @modelcontextprotocol/sdk) and leave the plugin with a few pure-JSON HTTP endpoints that take “tool name + arguments” and return a result. Local HTTP overhead is on the order of microseconds, the tools themselves take far longer than the network, you can debug directly with curl, and the Node side has zero dependencies.

run_python: the Universal Entry Point

The most important piece in the plugin is actually run_python: it runs engine Python inside the editor, and after import unreal you can touch basically anything. Use it as the universal entry point to cover most editor operations, then add a few convenience read tools and that’s enough. The usage handed to the AI looks roughly like this:

python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import unreal

# 加载并查看蓝图
bp = unreal.load_asset('/Game/UI/WBP_TipsTileView')
print(bp)

# 列出某目录下的资产
print(unreal.EditorAssetLibrary.list_assets('/Game/UI'))

# 查询关卡 Actor
actors = unreal.EditorLevelLibrary.get_all_level_actors()
print([a.get_actor_label() for a in actors])

Smart Startup and Multiple Instances

Once the first version was done and actually in use, three problems showed up:

  1. Forgot to start the editor — the AI calls a tool, the editor isn’t running, and it simply can’t connect;
  2. Instances stepping on each other — sometimes two editors are open (usually two instances of the same project), the plugin hardcodes port 8000, the second one can’t bind, and the two instances may read and write different in-memory states, so changes clobber each other;
  3. Node fallback — the wrapper depends on Node.js; if it isn’t installed, we need a clear message rather than a silent failure.

So I refactored it (the design doc is in docs/), handing the first two problems to the wrapper:

  • When the client connects to unreal-mcp and no editor is running, the wrapper resolves the engine path from the project’s EngineAssociation registry key, launches the editor itself, and polls until it’s ready before handling calls (the first launch may take 1–3 minutes);
  • With multiple editors, the wrapper reads Saved/MCP/instances.json to discover instances, picks the first healthy one by default, and you can switch targets with list_instances / select_instance; all write operations go to the same instance;
  • The plugin side auto-increments on port conflicts (scanning upward from 8000 for a free one) and writes the actual port back to the registry file.

Tools at a Glance

Besides run_python, a few convenience tools are built in:

ToolDescription
list_blueprintsList Blueprint assets in the project (filterable by substring)
get_blueprintRead Blueprint structure: parent class, variables, functions
list_widget_treeRead the widget tree of a UMG WidgetBlueprint
get_widget_propertiesRead property values of a UMG widget instance
create_widget_blueprintCreate a UMG WidgetBlueprint
add_widget_to_treeAdd a widget to the widget tree
set_widget_propertiesWrite widget properties by type via Reflection
remove_widget_from_treeRemove a widget from the widget tree
exec_commandExecute shell commands on the editor machine
list_assetsList assets under a path
list_actorsList Actors in the current Level

There are also two instance-management tools provided by the wrapper: list_instances / select_instance.

Usage

Setup isn’t much trouble: copy the plugin directory into the project’s Plugins/ and enable it in the .uproject, run npm install for the wrapper dependencies, build the editor target, and finally point your MCP client at the wrapper’s index.js in .mcp.json.

Day to day it’s basically transparent: just call the tools, and if the editor isn’t open it starts it automatically; with multiple instances, run list_instances first and then lock onto one with select_instance. For manual control, type UnrealEngineMCP.StartServer 8000 / UnrealEngineMCP.StopServer in the editor console.

Open Source

The plugin is open source on GitHub: UnrealEngineMCP — take a look if you’re interested.

Additional Notes

A few small implementation points:

  • Adding a tool doesn’t require touching the wrapper: it discovers tools via GET /api/tools and converts JSON Schema → zod fully automatically, so a new tool only needs an IMCPTool class implemented and registered in C++, with not a single line changed in the wrapper;
  • The plugin is an Editor module, editor-only, so it doesn’t affect the packaged game builds;
  • run_python can run arbitrary code, so it only listens on localhost by default (bListenOnLocalhostOnly), and it should only ever run code you trust — the data sent to the LLM is the project content itself.
This post contains some AI-assisted content, reviewed and edited by the author before publishing.
This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...