PythonMCP-UEFN

PythonMCP-UEFN

Exposes the Unreal Editor for Fortnite to AI assistants via MCP, enabling actor manipulation, device property editing, Verse building, and more through a Python bridge.

Category
访问服务器

README

PythonMCP-UEFN

Drive Unreal Editor for Fortnite from any MCP client over a local Python bridge.

License Python Status

This is a Model Context Protocol server that exposes the UEFN editor to an AI assistant. With it, an assistant can spawn and move actors, browse and validate assets, read and write device options, run arbitrary editor Python, trigger a Verse build and read the compile result, all without anyone touching the mouse.

It ships 39 tools. The interesting part is the device bridge: it reads and writes the @editable Verse properties that the standard unreal Python API refuses to surface by name. More on that below.

How it works

There are two halves. A listener that runs inside UEFN, and an MCP server that runs on your machine and talks to it.

  MCP client  (Claude Code, or any MCP host)
       |
       |  stdio
       v
  mcp_server.py        host process, this repo
       |
       |  HTTP POST  ->  127.0.0.1:8765
       v
  uefn_listener.py     runs inside the UEFN editor
       |
       |  game thread  (slate post-tick callback)
       v
  unreal.*             editor scripting API

The listener is a ThreadingHTTPServer bound to 127.0.0.1:8765. The HTTP thread only enqueues work. A slate post tick callback drains that queue on the game thread, because the unreal API is not thread safe and will crash if you call it from anywhere else. A watchdog re-arms the tick and the accept loop after a world or map change, and on a full project reopen the init_unreal hook re-runs the module. The whole listener is one self-contained file so you can paste it straight into Execute Python Script.

On the host side, transport.py adds retry with backoff, per-tool timeouts, and error classification. When something goes wrong it tells you whether the listener is down (socket refused) or wedged (reachable but the game thread stopped draining), so the failure message points at the actual fix.

Requirements

Host:

  • Python 3.11
  • The mcp package (pip install -r requirements.txt)

Editor:

  • UEFN with Python editor scripting enabled (experimental, UEFN 40.40 or newer)

The listener itself has no third party dependencies. It uses only the standard library plus the unreal module that UEFN provides.

Setup

1. Install the host dependencies

pip install -r requirements.txt

2. Register the server with your MCP client

For Claude Code:

claude mcp add uefn --scope user -- python /absolute/path/to/PythonMCP-UEFN/mcp_server.py

For any other MCP host, point it at the same command. The server speaks stdio.

{
  "mcpServers": {
    "uefn": {
      "command": "python",
      "args": ["/absolute/path/to/PythonMCP-UEFN/mcp_server.py"]
    }
  }
}

3. Start the listener inside UEFN

Open your project, then Tools > Execute Python Script and pick uefn_listener.py. It binds the port and starts serving.

To confirm it is up, call the ping tool from your assistant (it returns {pong, uefn, tools}), or open http://127.0.0.1:8765/health in a browser.

4. Optional: start the listener automatically

Running the script by hand every session gets old. Install an autostart hook into your project:

python install_autostart.py "C:\path\to\YourProject"

That writes Content/Python/init_unreal.py into the project, so the listener comes up on its own whenever you open it.

Usage

Once the server is registered and the listener is running, ask your assistant to work in the level. A request like "spawn a cube at the origin and frame the camera on it" turns into:

spawn_static_mesh   mesh_path=/Engine/BasicShapes/Cube   location={x:0,y:0,z:0}
focus_on_actor      actor=<the new actor>

Reading and writing a device option works the same way:

device_list_options   label="My Trigger"
device_set_option     label="My Trigger"  option="EnabledAtGameStart"  value=false

When you need something no tool covers, execute_python runs arbitrary code in the editor with the unreal module already in scope. Assign your return value to _result.

Tools

Session and level

Tool Purpose
ping Health check. Returns pong, uefn flag, tool count.
get_current_level Current level name and asset path.
save_level Save the current level.
save_all Save every dirty level and asset under /Game.
load_level Load a level by path.
diagnostics Listener health snapshot: uptime, last tick age, accept loop, port, world, autostart.

Actors

Tool Purpose
spawn_actor Spawn an actor from a class path.
spawn_static_mesh Spawn a StaticMeshActor from a mesh asset.
list_actors List actors, optionally filtered by class or label.
delete_actors Delete actors by label or path.
set_actor_transform Set location, rotation, scale.
get_actor_transform Read a transform.
set_actor_label Rename an actor in the Outliner.
duplicate_actor Duplicate, with an optional offset and new label.
select_actors Replace the editor selection.
get_selected_actors Read the current selection.
focus_on_actor Frame the viewport on an actor.

Viewport

Tool Purpose
get_viewport_camera Read the viewport camera transform.
set_viewport_camera Set the viewport camera transform.

Assets

Tool Purpose
list_assets List asset paths under a folder.
find_asset Substring search for assets.
load_asset Load an asset and return its class and name.
asset_exists Check whether an asset exists.
create_folder Create a content folder.
validate_assets Run the editor validator. Catches publish time strips before you push.
describe_class Resolve a class by path and return its name and super.

Devices

Tool Purpose
list_editor_properties List the editor properties exposed on an actor.
set_device_property Set one editor property on a device.
set_device_properties_bulk Apply many updates in one undo group.
device_scan Scan a custom Verse device once to cache its mangled @editable names.
device_list_options List readable option names and values. Auto detects native versus Verse.
device_get_option Read one option by its author facing name.
device_set_option Write a scalar option. Returns the value read back.
device_wire Wire a Verse reference field to another actor.
device_set_prop_array Set a Verse array of reference fields to a set of actors.

Verse build

Tool Purpose
verse_build_trigger Trigger a Verse build without a manual key press.
verse_compile_status Read the latest compile verdict and errors from the editor log.

Python and autostart

Tool Purpose
execute_python Run arbitrary Python in the editor. Assign to _result to return a value.
install_autostart Write the autostart hook into a project.

The device bridge

A Fortnite device places its author written @editable Verse fields on a BlueprintGeneratedClass. The friendly name you wrote in Verse does not exist as a settable property. The fields live under mangled internal names of the form __verse_0x<hash>_<name>, and that hash changes on every recompile, so you cannot hardcode it.

The bridge recovers the mapping by dumping the placed device to T3D and matching the mangled names with a regex, then caches the result in _device_options_cache.json next to the listener. After that, the device_* tools let you read and write those fields by their real names. Native Epic devices expose clean properties and need no scan. Custom Verse devices need device_scan run once with the device configured, so the dump has values to recover.

The full background, including the editor Python limitations that made this necessary, is written up in docs/UEFN_Python_API_gaps.md.

Limitations

  • Editor only. Python here cannot run gameplay. Runtime logic stays in Verse.
  • One editor instance. The port 8765 is fixed.
  • Do not issue tool calls while a Launch Session is starting. A racing call can abort the socket and trip asset validation with a false failure.
  • The device introspection surface in the editor Python API is thin. The bridge works around it rather than relying on official support, so expect rough edges as UEFN changes.

Project layout

mcp_server.py             host MCP server, tool schemas, routing
transport.py              host HTTP client, retry, timeouts, error classification
uefn_listener.py          listener that runs inside UEFN, self-contained
install_autostart.py      writes the project autostart hook
init_unreal_template.py   template for Content/Python/init_unreal.py
tests/                    transport tests, no UEFN needed
docs/                     UEFN Python API gaps report

Development

The transport layer runs without UEFN, so its tests run anywhere:

python -m unittest discover tests

The listener and the server import unreal and mcp, so a full end to end run needs UEFN open with the listener started.

License

MIT. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选