game-loop-mcp
Provides a stdlib-only Python listener that games call once per frame to expose commands to the MCP server, plus a tkinter demo and end-to-end test.
Provides a Unity listener (GameLoopRpc.cs) for Editor and Development Builds, with built-in commands to inspect scenes and objects, find objects, adjust timescale, load scenes, quit, and capture game-view screenshots.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
game-loop-mcp
Let an AI coding agent run your game and look at it: launch a development build, ask it questions, drive it, wait for a state, screenshot it, read its log and close it. The agent can then check its own change in the real game before handing the work back, instead of editing code and hoping.
agent ──MCP──▶ game-loop-mcp (Node, zero dependencies) ──TCP 127.0.0.1──▶ listener inside your game
launch · exec · wait · screenshot · log · close runs commands on the main threadIt grew out of three games we develop with Claude Code, two online games and a Unity game. Each had a hand-written "drive the running client" MCP server, and they turned out to be the same tool. This is that tool, made generic, with the rules those games taught us built in.
The two halves
Inside the game, a listener. A few hundred lines, one file:
runs text commands on the game's own thread, so handlers can touch game state;
exists only in development builds, and listens only when started with
GAME_RPC=1;answers
help,ping(pid=,scene=,fps=...),arm, optionallyshot, plus whatever commands you register:hp,inventory,teleport 10 0 5,load Level2,spawn goblin,give gold 100...
Ready-made listeners:
file | notes | |
Unity | drop into | |
Python | stdlib only. Call | |
anything else | one command per line, replies end with a |
Outside, the MCP server server/game-loop-mcp.js. It's pure Node, configured by
one game.json, and gives the agent seven tools, prefixed with your game's name:
tool | what it does |
| is the game running, and what does |
| start the dev build with |
| run commands, get their output |
| poll a command until its output matches a regex ( |
| returns the image to the agent. Uses the game's |
| tail the game's log, optionally filtered |
| ask the game to close and wait. Never force-kills: a killed online client can stay logged in server-side |
Commands that change the game are write commands. They answer an error until the agent sends arm write,
and every one is logged. Looking around is free; changing things is a deliberate step you can see in the
transcript.
Related MCP server: Zeta Studio MCP
Set up
Add a listener to your game (Unity: copy
GameLoopRpc.csintoAssets/) and register a few commands worth asking about:#if UNITY_EDITOR || DEVELOPMENT_BUILD GameLoopRpc.Register("hp", args => $"{player.hp}/{player.maxHp}", "player hit points"); GameLoopRpc.Register("teleport", args => { player.Teleport(args); return "ok"; }, "teleport <x> <y> <z>", write: true); #endifMake a development build.
Write a
game.jsonnext to your project (paths are relative to it;%VAR%,${VAR}and~expand):{ "prefix": "mygame", "title": "My Game", "exe": "Builds/Dev/MyGame.exe", "args": ["-screen-fullscreen", "0", "-screen-width", "1280", "-screen-height", "720"], "processName": "MyGame", "port": 47817, "log": "%USERPROFILE%/AppData/LocalLow/MyCompany/MyGame/Player.log" }key
prefixtool name prefix (
mygame_launch...)exe,args,cwd,envhow to start the dev build.
envis merged in;GAME_RPC=1andGAME_RPC_PORTare always setprocessNameoptional: launch also refuses while a process of that name runs, even without a listener
portlistener port (default 47817). Give each game its own
logfile
<prefix>_logtailslaunchTimeoutSeconds,commandTimeoutMsdefaults 90 s and 15 s
Register the server with your MCP client. For Claude Code, in the project's
.mcp.json:{ "mcpServers": { "mygame": { "command": "node", "args": ["C:/tools/game-loop-mcp/server/game-loop-mcp.js", "C:/work/mygame/game.json"] } } }
Then ask: "launch the game, load Level2, teleport to the boss door and show me a screenshot".
Try it in one minute
The repo has a tiny tkinter demo game wired to the Python listener, and an end-to-end test that drives it through the MCP server exactly as an agent would:
node test/selftest.js # needs Node 16+ and Python 3 with tkintertest/unity-e2e.ps1 -Unity <path to Unity.exe> does the same for Unity. It creates a throwaway project,
adds the listener and a one-scene demo, makes a Development Build, and runs the self-test against it.
Lessons baked in
Drive the game from inside. Sending keys or clicks from outside fails in practice: background processes can't take focus, games read raw input, and you can't read game state through pixels. The listener runs inside the game, and the outside half only carries text.
Answer on the main thread or not at all. A command waits for the next frame. During a load or a modal dialog it times out with a clear message instead of hanging the agent.
Arm from the environment, never from a file. A flag file left behind changes the next normal run.
One instance, never killed. Shared accounts, shared save folders, other agents' sessions: refuse instead of guessing, and close politely.
Return pictures, not paths. The screenshot comes back as an image the agent can see. Downscaled to 1280 px by default, which is plenty to judge a scene and cheap on tokens.
Platforms
The server runs anywhere Node does. Window capture (the fallback when a listener has no shot) and the
polite close via CloseMainWindow are Windows features. On macOS and Linux, close sends SIGTERM, and
screenshots need the listener's shot (the Unity one has it).
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Launch and verify high-fidelity mobile simulations from an AI agent.
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
Run your Krtuworks apps from an AI agent: setup, remote config, stats, players, bug reports.
Run commands, code and file operations for AI agents in Cloud Hypervisor microVM sandboxes.
Related MCP Servers
- AlicenseAqualityBmaintenanceDrives a running tModLoader instance from an agent, allowing it to launch the game, issue commands, take screenshots, and read game state as structured data.2459 PyPI2MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI coding tools to connect and authorize local game projects, then drive source edits, validation, preview, version saving, and mode-based creation workflows.Apache 2.0
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to automate the PlayCanvas Editor, managing entities, scripts, assets, scenes, builds, and viewport state, and to launch and inspect running scenes with screenshots, logs, and input simulation.-
- AlicenseBqualityBmaintenanceEnables AI agents to interact with the Godot game engine by launching the editor, running projects, capturing debug output, inspecting and editing scenes, running tests, and observing runtime behavior for an iterative game-making loop.32MIT