Skip to main content
Glama

ue5-gameplay-mcp

An MCP server that plays a running Unreal Engine 5 game. It accepts virtual gamepad, keyboard, and mouse input and returns screen capture, log lines, and UMG status.

This is not an engine plugin; it is a client. Two plugins already handle the in-engine work, and each holds its own port. This server dials into both and exposes them as a single tool interface.

Plugin

Port

Features

RemoteConsole2

10101

Gamepad/keyboard/mouse injection via IInputDevice, console commands, UMG dump/click/focus, live log stream, structured game state

RemoteCapturePlugin

10102

JPEG/PNG screen capture (works in PIE and packaged builds) ships with ue5_gamecapture_mcp

A small amount of C++ was added to both plugins specifically for this server. They remain independent and keep their own protocols. The additions are backward compatible, so even older clients can still communicate with a rebuilt game:

  • FImageMeta.SourceSize — the game's back-buffer size. It is packed into a previously reserved area to keep the struct at 24 bytes, so the client can map a specific point on a downscaled capture back to actual window pixels.

  • CMD_GET_GAME_STATE (520) and IRemoteGameStateProvider — more on this below.

Setup

cd ue5_gameplay_mcp
uv sync

MCP Python SDK v2 (mcp.server.MCPServer) is required.

Related MCP server: Unreal Engine MCP Server

How to run

Start the game first. In this project, a standalone game is run from the editor binary because the Game target exits immediately in a project that has not been cooked:

"C:/Program Files/Epic Games/UE_5.8/Engine/Binaries/Win64/UnrealEditor.exe" "<PATH>/MyProject.uproject" -game -windowed -resx=1280 -resy=720 -log -nosplash

Next, register the server. The .mcp.json in the project root already does this, so Claude Code will pick it up automatically. The manual command equivalent is:

claude mcp add ue5-gameplay -- uv run --directory <PATH>/ue5_gameplay_mcp -m ue5_gameplay_mcp

The server uses a lazy connection, so the actual startup order does not matter. If it starts before the game does, it will connect on the first tool call.

Options: --host, --console-port, --capture-port, --format, --quality, --max-size, --grid-step, --transport streamable-http --mcp-port 14102.

Tools

Session — game_connect, game_status, game_reset_input

Observation — game_observe, game_state, game_log, game_wait_for_log

Actions — game_pad, game_pad_sequence, game_key, game_mouse, game_console, game_time_scale

UMG — game_ui_dump, game_ui_click, game_ui_focus

API design and the reason for it

An agent round trip takes several seconds, but the game runs at 60 Hz. Since frame-by-frame actions are unrealistic, the design works as follows:

  • All action tools take a duration and perform a press / hold / release sequence locally, paced to the communication speed. One round trip carries one intent, not one frame.

  • Action tools observe by default. game_pad(ly=1.0, duration=0.5) moves forward and returns the resulting frame. This takes half as many round trips as doing the action and the observation separately.

  • game_pad_sequence packs an entire combo into one call when the timing of the inputs matters more than checking between them.

  • game_time_scale(0.2) buys in-game time when precision at a particular moment is required.

  • hold=True keeps the input applied between turns so the character keeps moving while the agent is thinking. game_reset_input clears it.

Numbers, not pixels

game_state returns the level, world time, pause/time dilation, player pawn transform, velocity, movement mode, camera, and the distance and normalized screen position of the nearest actor. These are the same 0–1 coordinates game_mouse receives, so you can immediately aim at a target you find in the status report. The cost is a fraction of image processing, and it will not misread HUD numbers.

game_observe(state=True) folds this into what an observation, and `game_pad(..., state=True)' folds it into an action, so movement and verification still take only one round trip.

On a real map, most nearest actors are background objects, so the report also includes class_counts (a survey of all objects within the radius). Read it once, and you can narrow it down with class_filter="Enemy".

Adding game-specific numbers

The built-in report needs no game-side query. For anything only that project knows — health, score, quest flags, etc. — implement IRemoteGameStateProvider (Plugins/RemoteConsole2/Source/RemoteConsole2/RemoteGameState.h) on any actor and return the string of a JSON object:

FString AMyGameMode::GetRemoteGameState_Implementation()
{
    return FString::Printf( TEXT("{\"score\":%d,\"wave\":%d}"), Score, Wave );
}

Since it's a BlueprintNativeEvent, it can be overridden even in Blueprint-only projects. All returned values are stored under custom, keyed by actor name. Providers are collected regardless of the distance filter, so even a scorekeeper handled at the origin will send a report. Text that is not valid JSON is not discarded; it is passed through as its raw string, so even simple Printf debugging while starting up is helpful.

  1. game_ui_dump + game_ui_click — exact and fast, but only knows widgets registered through UMG. Games with a custom Slate UI get nothing back, and the tool explicitly says so instead of hanging.

  2. Pad navigation — game_pad(buttons=["DOWN"]), game_pad(buttons=["A"]). Works with almost any game.

  3. Look & click — game_observe(grid=True) overlays a labeled 0–1 coordinate grid on the capture. Read the target from the image and pass the same numbers to game_mouse(x=..., y=...). It is independent of user resolution and works no matter how the UI is built.

Conventions

  • Sticks follow UE's specification: ly=+1 is forward. (The protocol flips the Y axis, but our code flips it back, so the tool API matches what the game's own axis mapping means.)

  • Mouse coordinates are normalized to 0–1 with the top-left as origin, and are translated to pixels using the game's actual back-buffer size. Since the capture reports its resized dimensions, this source size is probed separately.

  • game_observe returns only new log lines since the previous observation, so the same output is never resent, even during a long session.

Known issues and unfinished parts

  • When hosting the game from the editor binary, console commands are routed through Python. FGameAppInterface::ExecConsoleCommand dispatches to the implementation of IConsoleCommandExecutor [0]; if the editor's Python plugin is loaded, that slot is Python instead of Cmd. So a plain stat fpscomes back as aSyntaxError. On first use the server probes this, and if it detects the problem, it wraps the command with unreal.SystemLibrary.execute_console_command. Packaged builds have no Python executor, so this solution is not needed. You can also override it with game_console(via="cmd")`.

  • Screen clicks assume the capture fills the entire game window. This is true with -game -windowed. In a letterboxed fullscreen mode, the reported source size includes the black bars, so the mapping is off.

  • game_state traverses every actor in the level on each call. At normal map scale this is fine, but a streaming open world would probably need a spatial query instead of TActorIterator.

Tests

uv run test/smoke_test.py

Communicates directly with the game and outputs smoke_*.jpg, allowing you to check the capture and grid overlays visually.

uv run test/mcp_client_test.py

Starts the server via standard input/output (stdio) as a real MCP client, and runs and tests all tools, including error paths.

Available Tools

16 tools
game_connectA

Connect to the running game and report what is on the other end.

Call this first, or after the game has been restarted. reconnect=True drops the existing sockets and dials again.

Inputs: reconnect. Returns: result

game_consoleA

Run a console command and return the log lines it produced.

Useful beyond cheats: stat fps, showdebug ai, and especially getall <ClassName> <PropertyName> to read gameplay values out of the game until a structured state API exists.

via picks the executor and should stay on "auto": when the game is hosted by the editor binary the console routes through Python, which auto mode detects once and works around. Force it with "cmd" or "python" if needed.

Inputs: command (required), via, settle. Returns: result

game_keyB

Tap a keyboard key for duration seconds.

key is a single character ("w", "e") or a name: ENTER, ESC, SPACE, TAB, SHIFT, CTRL, ALT, UP/DOWN/LEFT/RIGHT, F1-F12, TILDE.

Inputs: key (required), observe, show_ui, duration, +1 more.

game_logC

New log lines since the last read. pattern is a regex filter.

Inputs: limit, since, pattern. Returns: result

game_mouseA

Move or click the mouse at normalized screen coordinates.

x/y are 0..1 with the origin at the top left -- exactly the numbers printed on a game_observe(grid=True) capture, so you can read a target off the image and pass it straight in. They are converted to pixels here using the game's real resolution.

action: click, down, up, double, move, setpos, wheel button: L, M, R, T1, T2

This is the fallback that works regardless of how the game builds its UI, when game_ui_click cannot see the widget tree.

Inputs: x, y, grid, wheel, +6 more.

game_observeA

Look at the game: a screenshot plus the log lines since the last look.

grid=True overlays a labelled 0..1 coordinate grid -- turn it on when you intend to click something with game_mouse. show_ui=False hides the HUD/UMG overlays. log_pattern is a regex filter over the new log lines. state=True folds in game_state, so one call answers what the world looks like and what it actually contains.

Inputs: log, grid, image, level, +6 more.

game_padA

Press pad buttons and push sticks for duration seconds, then observe.

buttons: any of A B X Y UP DOWN LEFT RIGHT L1 R1 L2 R2 L3 R3 SELECT START HOME TOUCHPAD (aliases: CROSS/CIRCLE/SQUARE/TRIANGLE, LB/RB/LT/RT, BACK/OPTIONS/MENU). sticks: lx/ly left stick, rx/ry right stick (camera), l2/r2 analog triggers. Range -1..1, UE convention -- ly=+1 is forward. hold: keep this input applied after the call returns, so the character keeps moving between your turns. Clear it with game_reset_input.

Example -- run forward for half a second and look at the result: game_pad(ly=1.0, duration=0.5) Example -- jump while running: game_pad(buttons=["A"], ly=1.0, duration=0.3) Example -- move and get exact positions back, not just a picture: game_pad(ly=1.0, duration=0.5, state=True)

Inputs: l2, lx, ly, r2, +10 more.

game_pad_sequenceA

Run several pad states back to back in a single round trip.

Each step is {"buttons": [...], "sticks": {"ly": 1.0}, "duration": 0.2, "gap": 0.05}. Use this for combos and for anything where the timing between inputs matters more than looking in between.

Example -- a three hit combo: [{"buttons": ["X"], "duration": 0.1, "gap": 0.25}, {"buttons": ["X"], "duration": 0.1, "gap": 0.25}, {"buttons": ["Y"], "duration": 0.1}]

Inputs: steps (required), observe, show_ui, max_size.

game_reset_inputA

Release every held button, centre the sticks, lift the mouse buttons.

Use this after hold=True actions, or any time the character seems stuck walking into a wall.

Inputs: no named parameters. Returns: result

game_stateA

Structured world state -- no screenshot, cheap to call often.

Returns the level name, world time and pause/dilation, the player pawn's transform, velocity and movement mode, the camera, and the nearest actors with their distance and their normalized screen position (the same 0..1 coordinates game_mouse takes, so you can aim at what you find here).

class_filter keeps only actors whose class name contains that substring, e.g. "Enemy". radius is in centimetres. Games can add their own values -- health, score, quest flags -- by implementing IRemoteGameStateProvider on an actor; those show up under "custom".

Prefer this over reading numbers off the screen: it is exact, and it costs a fraction of the tokens an image does.

Inputs: actors, radius, max_actors, class_filter. Returns: result

game_statusB

Connection state, current level, and any input still being held.

Inputs: no named parameters. Returns: result

game_time_scaleA

Slow down or speed up the world (slomo). 1.0 is normal, 0.0 freezes it.

Drop to 0.1-0.3 when you need to place an action precisely; the game keeps running but each of your turns costs far less game time.

Inputs: scale. Returns: result

game_ui_clickB

Click a UMG widget by name. action: click, press, release, hover, unhover.

Fast and exact when it works; use game_ui_dump first to learn the names.

Inputs: widget (required), action. Returns: result

game_ui_dumpA

Dump the UMG widget tree. mode: all, button, debug.

Only sees widgets registered through UMG. A game with custom Slate UI will come back empty or error -- that is expected, fall back to the pad or to game_observe(grid=True) plus game_mouse.

Inputs: mode. Returns: result

game_ui_focusB

Set the game's input focus. mode: game, ui, game_and_ui, window.

Bring the window forward and hand focus back to the game with mode="game" if input seems to be going nowhere.

Inputs: mode, widget. Returns: result

game_wait_for_logA

Block until a log line matches pattern, or the timeout expires.

This is the assertion primitive for automated tests: fire an action, then wait for the line the game prints when the thing you expected happened.

Inputs: pattern (required), timeout. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 16 tools

    Disambiguation5/5

    Each tool targets a distinct interaction mode: connection, observation, state, input (pad/key/mouse/UI), logging, console, time scaling, and focus. Even overlapping actions like game_mouse vs game_ui_click are explicitly differentiated by target (screen coordinates vs widget tree) and fallback behavior.

    Naming Consistency5/5

    All tools follow the predictable 'game_' prefix with an action verb (connect, log, observe, state, pad, key, mouse, console). The sub-group 'game_ui_*' maintains consistency with a clear sub-domain. No mixed conventions or vague verbs.

    Tool Count4/5

    16 tools is slightly above the ideal 3-15 range but fully justified for a comprehensive UE5 gameplay API covering connection, observation, multiple input methods, UI interaction, and convenience utilities. Each tool serves a clear practical purpose.

    Completeness5/5

    The surface covers the full cycle: connect, observe (screenshot/state), act (pad/key/mouse/UI), read logs, wait for conditions, adjust time scale, and reset input. No obvious dead ends or missing operations for controlling a game; even edge cases like UI failure have explicit fallback guidance.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      A
      maintenance
      Enables AI assistants to control Unreal Engine via Remote Control API for game development automation, including asset management, actor control, level editing, animation, physics, visual effects, and cinematics creation through natural language.
      1
      1,055
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables an agent to drive a running Unreal Engine game via UE4SS by reading/writing UObject properties and calling UFunction, with verdicts that verify whether the requested state change actually happened.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents to work inside a live Unreal Editor for Fortnite session: write and compile Verse, place and wire Creative devices, edit Scene Graph entities, manipulate actors and assets, take screenshots, run playtests, and read editor logs via MCP.
      MIT