AI Coding Agents (Specter MCP)
Specter MCP is an editor toolset for coding agents connected to Unreal's Model Context Protocol server. An agent can run your Specter tests, read what happened in each one, look at the game at any moment of a run, and probe the running game with Specter's commands. So it can build a feature, test it, read the failure and fix it, without anyone reloading the editor.
Setup
Specter MCP needs Unreal Engine 5.8 or later, which has the Model Context Protocol and ToolsetRegistry plugins, and the Specter plugin. It's a plugin of its own so Specter itself can keep supporting older engines.
- Put it in your project as
Plugins/SpecterMCP, next toPlugins/Specter. - Enable the Model Context Protocol plugin (and a toolset plugin such as All Toolsets for Epic's own tools), then build the editor.
- In Editor Preferences, turn on Model Context Protocol › Auto Start Server.
- Write your agent's client config from the console:
# In the editor's console, once the MCP server is running, naming your agent's client:
ModelContextProtocol.GenerateClientConfig GeminiThe Tools
| Tool | What it does |
|---|---|
| ListTests(Filter, Limit) | The project's Specter tests. |
| RunTests(Files, TitleFilter, WaitSeconds, TimeoutSeconds) | Runs tests through the Specter runner, starting Play-In-Editor when needed. Returns each test's status, error and output, or running after WaitSeconds (at most 50). |
| GetRunResult(WaitSeconds) / StopTests() | Waits for the run to finish, or stops it. |
| GetTestResult(TestName, MaxSteps) | One test's latest run: steps with timings and checks, console output, performance captures, screenshots, timeline span, recent runs and how flaky it is. |
| GetTimelineFrame(TestName, Seconds, Client) | The timeline preview image at a moment of the test. |
| GetTimelineState(TestName, Seconds, ToSeconds, Actor, MaxSamples) | Where the test's actors were and how they were doing: a summary per actor, the sample at a moment, or the samples in a span. Stuck AIs included. |
| RunCommands(Steps, Client, TimeoutSeconds, StopOnError) | Runs Specter's commands in the playing game, without writing a test. |
Pass every parameter, including the ones with defaults (TitleFilter: "").
The Test Loop
An MCP call has to answer within about a minute, so RunTests waits at most 50 seconds. A longer run comes back as running, and the agent waits for the rest with GetRunResult. When a test fails, GetTestResult gives the steps and the check that failed, and the timeline tools show what the game was doing at that moment.
RunTests(Files: "tests/scoring.spec.ts", TitleFilter: "", WaitSeconds: 50, TimeoutSeconds: 600)
→ { status: "running", ... } // still going after 50 s
GetRunResult(WaitSeconds: 50)
→ { status: "failed", tests: [{ title: "a stunt off-frame scores nothing", error: "..." }] }
GetTestResult(TestName: "a stunt off-frame scores nothing", MaxSteps: 40)
→ steps with timings, the failed check, console output, screenshots, timeline span
GetTimelineFrame(TestName: "a stunt off-frame scores nothing", Seconds: 3.2, Client: 0)
→ a JPEG of the game at 3.2 sProbing the Game: RunCommands
RunCommandssends the same commands a test's locators send, in the game that's playing, in the editor process: no Node or Playwright needed. It's for questions a test would take too long to write for. What does this function return? Can this AI see the player from here? Is there a path? Steps run in order, one per frame.
[
{ "command": "SpawnActor", "payload": { "assetPath": "BP_Guard", "location": { "x": 0, "y": 0, "z": 100 } }, "as": "guard" },
{ "wait": 0.5 },
{ "command": "CallFunction", "target": "$guard",
"payload": { "functionName": "ApplyBlast", "parameters": { "Location": { "x": 0, "y": 0, "z": 0 }, "Radius": 400 } } },
{ "command": "GetPropertyValue", "target": "$guard | component:HealthComponent", "payload": { "propertyName": "Health" } },
{ "command": "AIPerceives", "target": "$guard", "payload": { "targetLocatorPipeline": "@class:BP_Intruder | first" } },
{ "command": "GetPropertyValue", "target": "subsystem:ScoreSubsystem", "payload": { "propertyName": "TotalScore" } },
{ "repeat": 3, "every": 0.5, "do": [ { "command": "GetNavPath", "target": "$guard", "payload": { "goal": { "x": 2000, "y": 0, "z": 0 } } } ] },
{ "command": "ClearAllSpawned", "payload": {} }
]target:class:BP_X(or justBP_X),tag:T,name:BP_X_C_3,subsystem:Name, or$saved. Then|modifiers:first,last,index:N,ai(its controller),component:Class,player. Or a raw locator pipeline array.assaves a step's target and result. ForSpawnActor, the saved target is the spawned actor.- In
payload,"@target"becomes that target's pipeline, and"$name.path"a saved step's result. CallFunctiontakes its arguments inparameters. A misspelled key or an unknown parameter name is an error that lists the function's parameters, rather than a call with defaults.quiet: trueleaves a successful step's data out of the answer.- What it spawns stays until
ClearAllSpawned: a step, or the next test's cleanup.
The answer is { status: "ok" | "failed" | "timedOut", seconds, steps: [...], saved }.
Making a Game Easy for Agents to Test
A few choices make tests far easier to write, for an agent or a person. Put them in your agent's instructions (AGENTS.md, CLAUDE.md, GEMINI.md):
- Keep rules in callable functions (score a take, apply damage) so a test can call them and check the result.
- Seed random numbers, so a failure happens again when you rerun it.
- Mark the game's moments with Mark Timeline Event, so the timeline an agent reads says what happened.
- Give the game a way back to its start, and use it in a
resetGamefixture. - Mark the functions that matter for coverage, so you can see which ones the agent's tests reach.