unity-inspector-mcp
Provides tools to inspect and modify a running Unity game (Broforce), including GameObjects, components, player state, enemies, spawning entities, and executing C# code/scripts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@unity-inspector-mcp List all active enemies and their positions in the current level."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
unity-inspector-mcp
This lets an MCP client inspect and change things in Broforce while the game is running. It's mainly for modding and debugging. It works with the Unity Inspector Mod, a C# mod loaded by Unity Mod Manager, and the two talk over TCP on localhost, port 9999 by default. The server runs on Linux, Windows and macOS.
Requirements
Node.js 18 or newer. I've tested on 22, and the MCP SDK is the only npm dependency.
Broforce with Unity Mod Manager and the Unity Inspector Mod.
An MCP client. There are configs below for Claude Code, Claude Desktop, Codex CLI, Cursor, VS Code and Windsurf.
Related MCP server: Unity MCP Server
Installing the mod
Install the mod first. There's no prebuilt download, so clone the BroforceMods repo and build the Unity Inspector Mod project yourself, then put the built folder in Broforce's Mods directory like any other Unity Mod Manager mod. On r2modman it goes in UMM/Mods inside the profile folder instead. Here's a guide for installing Unity Mod Manager and mods if you haven't done that before.
Open the Unity Mod Manager overlay in game (Ctrl+F10 by default) and click on the mod. Its panel shows whether the TCP server is running, the port, the address it's bound to and how many clients are connected, and there's a Start Server button if it's stopped. If you change the port from 9999, set UNITY_INSPECTOR_PORT on the server side to match.
Installing the server
git clone https://github.com/alexneargarder/unity-inspector-mcp
cd unity-inspector-mcp
./setup.shsetup.sh checks for Node, installs the dependencies and prints the client config with the absolute path already filled in. A plain npm install works too, you just don't get the printed config.
Client configuration
The config has to point at wrapper.js, not index.js. The wrapper provides the restart_server tool and respawns the server if it crashes.
{
"mcpServers": {
"unity-inspector": {
"command": "node",
"args": ["/absolute/path/to/unity-inspector-mcp/wrapper.js"],
"env": {
"BROFORCE_LAUNCH_CMD": "/home/you/bin/launch-broforce --modded",
"UNITY_INSPECTOR_PORT": "9999",
"UNITY_INSPECTOR_LOG": "/path/to/UMM/Core/Log.txt"
}
}
}
}The env block is optional and so is each variable in it. On Windows the backslashes have to be escaped: "C:\\path\\to\\unity-inspector-mcp\\wrapper.js". That config works as is in Claude Desktop, Cursor, Windsurf and Cline:
Claude Desktop:
claude_desktop_config.json, at~/.config/Claude/on Linux,~/Library/Application Support/Claude/on macOS,%APPDATA%\Claude\on Windows.Cursor:
~/.cursor/mcp.jsonfor every project, or.cursor/mcp.jsonfor one.Windsurf:
~/.codeium/windsurf/mcp_config.json. It doesn't interpolate environment variables, so use literal values, no${VAR}. None of these settings are secrets so nothing is lost by inlining them.
Claude Code takes a command instead:
claude mcp add unity-inspector -- node /absolute/path/to/unity-inspector-mcp/wrapper.jsEnvironment variables go in as --env KEY=value arguments before the --. You can also put a .mcp.json in the project root with the standard config plus "type": "stdio" next to "command".
Codex CLI uses ~/.codex/config.toml:
[mcp_servers.unity-inspector]
command = "node"
args = ["/absolute/path/to/unity-inspector-mcp/wrapper.js"]
[mcp_servers.unity-inspector.env]
BROFORCE_LAUNCH_CMD = "/home/you/bin/launch-broforce --modded"Or codex mcp add unity-inspector -- node /absolute/path/to/unity-inspector-mcp/wrapper.js.
VS Code uses .vscode/mcp.json, where the top level key is servers, not mcpServers, and each server also needs "type": "stdio".
WSL
If the game is on Windows and your MCP client is in WSL, the server runs in WSL and connects to the Windows host IP it gets from ip route show default:
{
"mcpServers": {
"unity-inspector": {
"command": "wsl",
"args": ["node", "/home/you/unity-inspector-mcp/wrapper.js"]
}
}
}Launching and stopping the game don't work from there, since pgrep can't see Windows processes. You'd start the game on Windows yourself. This setup also needs the mod's "Allow remote connections (LAN)" setting turned on. The mod compiles and runs whatever C# gets sent to its port and there's no authentication on it, so any process that can reach the port can run code as whoever is running the game. It binds to 127.0.0.1 by default, and remote connections rebind it to 0.0.0.0, so while that's on, anyone on your network can run code on the game machine.
Environment variables
All three are optional and go in the env block (the [mcp_servers.unity-inspector.env] table in Codex, literal values only in Windsurf).
Variable | Effect |
| Command line |
| TCP port the mod listens on, if you changed it from 9999. |
| Path to the Unity Mod Manager log, if it is somewhere unusual. |
launch_game goes through Steam by default. BROFORCE_LAUNCH_CMD replaces that with a full command line, for cases like a Proton launcher script. It gets parsed into a command plus arguments, with shell style quoting.
Tools
There are 34, 33 from the server and restart_server from the wrapper.
Tool | Description |
| Test the connection to the mod. |
| Scene, game mode, level, player status and bro type in one call. |
| List GameObjects in the scene. |
| Search GameObjects by name pattern and/or component type. |
| Inspect one GameObject by path, with optional component details. |
| Inspect a single component. |
| Capture the game window and return the path. |
| Detailed state for the active player(s). |
| Move a player (or all players) to a coordinate. |
| Set a player's health. |
| List usable bros and which one each player has. |
| Choose the bro a player spawns as next. Does not change the current one. |
| Swap a player's bro immediately, in place, mid-level. |
| List enemies currently in the scene. |
| Spawn an entity at a coordinate (limited entity coverage). |
| Write properties on a component. |
| Set the time scale (1.0 is normal). |
| Press or hold a game action for a player, with an optional hold duration or repeat count. |
| List campaigns with their indices. |
| Go directly to a campaign/level pair. |
| Restart the current level, clearing checkpoints and trigger state. |
| Evaluate a C# expression in the Unity context (expressions only, no |
| Compile and run a full C# script in the game, Harmony patches and private members included. |
| Compile a script without running it, to check for compiler errors. |
| List the C# script library with descriptions, tags and arguments. |
| Unload a running script, unpatching it and destroying its GameObjects. |
| List the JSON test scripts. |
| Run a JSON command sequence and report each step. |
| Read the last N lines of the mod manager log, with an optional filter. |
| Return only the log lines written since the previous call. |
| Launch Broforce and wait until it answers, with |
| Kill the running Broforce process. |
| Poll until the game responds, or time out. |
| Restart |
Under Proton and WSL the game returns Windows paths for screenshots, and the server translates those into paths you can open locally.
C# scripts
scripts/csharp/ has a library of scripts committed to the repo: find-by-type, inspect-private-fields, watch-field, trace-method-calls and dump-harmony-patches, which work on any modded install, plus menu-tweaker (needs the RocketLib mod) and rogueforce-runner (needs the Rogueforce mod). Each one has a header of // #name, // #description, // #tags and // #args comments. list_scripts and the execute_script tool description both report that metadata, so the agent can pick a script and fill in its arguments on its own.
A script gets its own Harmony instance, a logger and a dictionary of its arguments, and its patches and GameObjects are cleaned up when it unloads. The format, the lifecycle, the ScriptContext API and the .NET 3.5 constraints are in scripts/csharp/README.md. You can run a script that isn't in the library by passing an absolute path to it, it just won't show up in the catalog.
Test scripts
Test scripts are JSON files with a sequence of game commands and optional waits between the steps, for reproducing the same scenario identically every run. There are three examples in scripts/examples/ and the format is covered in scripts/README.md. Steps go straight to the game, so server side tools like read_log and launch_game get rejected before the run starts.
Troubleshooting
"Game is not running. Use launch_game to start it." means the server couldn't open the TCP connection. Most likely causes, in order:
The game isn't running, or the mod didn't load. Check that the Unity Mod Manager overlay lists the mod and that it's enabled.
The mod's TCP server is stopped. Its settings panel shows the status and has a Start Server button.
The mod is on a port other than the default one. Set
UNITY_INSPECTOR_PORTto match, or set the mod back to 9999.You're on WSL with "Allow remote connections (LAN)" turned off. The mod is bound to the Windows loopback and WSL can't reach it.
If the game process is there but doesn't answer, launch_game reports that instead of starting a second copy. That's almost always the mod failing to load, and the log will have the reason.
Most commands get 6 seconds. The level and bro changing ones, plus take_screenshot, execute_code and unload_script, get 10, and execute_script and compile_script get 30 since compiling is slow. A timeout usually just means the game is busy with a long level load or a script that's overloading the main thread, and if the game dies partway through a command the server notices within half a second and reports a likely crash.
read_log and watch_log look for the Unity Mod Manager log at ~/.config/r2modmanPlus-local/Broforce/profiles/<profile>/UMM/Core/Log.txt on Linux and %APPDATA%\r2modmanPlus-local\Broforce\profiles\<profile>\UMM\Core\Log.txt on Windows, checking every r2modman profile and taking the most recently written one. A direct Unity Mod Manager install gets checked too, at <game>/Mods/UnityModManager/Log.txt. UNITY_INSPECTOR_LOG overrides the search entirely, and if no log turns up the error lists every path that was tried.
If the MCP server itself crashes, the wrapper restarts index.js and any in-flight requests get an error back, though it gives up after three crashes inside 30 seconds. /tmp/mcp-wrapper-<pid>.log has the wrapper's log plus everything the server wrote to stderr, and restart_server starts it back up once you've fixed the problem.
Development
After editing index.js or anything in lib/, the restart_server tool restarts the server in place and replays the MCP initialize handshake, so the client keeps its session. Editing wrapper.js itself needs a reconnect on the client side (/mcp in Claude Code).
Adding a tool takes two edits. In index.js it needs a definition in the ListToolsRequestSchema handler and a case in the switch, where game tools call unityClient.sendCommand("method_name", params). Then it needs a matching handler in Unity Inspector Mod/MessageHandler.cs over in the BroforceMods repo. If it takes longer than the 6 second budget, add a timeout for it in commandTimeout() in lib/unity-client.js.
The tests are npm test with Node's built in runner and no test dependencies, and none of them need the game running. Watch out for stdout, since it carries the MCP protocol and one stray console.log corrupts it.
Available Tools
33 toolscompile_scriptA
Compile a C# script without running it. Returns compilation success/failure and any compiler errors. Useful for validating scripts before execution.
Inputs: path (required).
execute_codeB
Execute C# expressions in the Unity context. Uses Mono.CSharp.Evaluator - expects expressions, not statements
Inputs: code (required).
execute_scriptA
Compile and run a C# script file in the Unity runtime. Supports full class definitions, MonoBehaviours, Harmony patches, and private member access. Scripts can define Main() for execution and Unload() for cleanup. Use ScriptContext for Harmony instances, logging, and arguments.
Available library scripts:
Dump Harmony Patches: List all Harmony patches on a specified method, showing patch owner, type, and priority [args: typeName, methodName]
Find Objects By Type: Find all active instances of a type in the scene with key state info [args: typeName, maxResults]
Inspect Private Fields: Dump all field values (including private) of a component on a named GameObject [args: gameObjectName, componentType]
Menu Tweaker: Live-edit FlexMenu element properties without rebuilding. Target by name, type, or wildcard pattern. [args: elementName]
Rogueforce Runner: Test harness for the Rogueforce mod. Start a run, skip levels, log state, auto-run a full campaign, or trigger game over. [args: action]
Trace Method Calls: Harmony-patch a method to log every call with arguments for a specified number of frames [args: typeName, methodName, maxCalls]
Watch Field: Monitor a field on a component and log whenever its value changes. Runs until unloaded. [args: gameObjectName, componentType, fieldName]
Inputs: path (required), args.
game_stateA
Get a high-level summary of the current game state: scene, game mode, level info, player status, and bro type. Single call to orient yourself.
Inputs: no named parameters.
go_to_levelB
Go directly to a specific campaign level
Inputs: levelIndex (required), campaignIndex (required).
inspect_componentB
Inspect a specific component on a GameObject
Inputs: path (required), componentType (required).
inspect_gameobjectA
Inspect a specific GameObject by path
Inputs: path (required), detailed.
inspect_playerB
Get detailed information about the player(s)
Inputs: no named parameters.
launch_gameA
Launch Broforce and wait for it to become responsive. Uses the BROFORCE_LAUNCH_CMD environment variable when set, otherwise launches Steam app 274190. Returns a warning if the game is already running unless restart is true.
Inputs: restart, vanilla.
list_brosA
List all available bros that can be used with swap_bro and set_bro. Reports the selected bro for the given player (currentBro) and for all active players (currentBros array).
Inputs: playerNum.
list_campaignsA
List all available campaigns with their indices
Inputs: no named parameters.
list_enemiesA
List all enemies in the scene
Inputs: no named parameters.
list_gameobjectsC
List all GameObjects in the scene
Inputs: maxResults, includeInactive.
list_scriptsA
List available C# scripts in the script library with their metadata (name, description, tags, arguments).
Inputs: no named parameters.
list_test_scriptsA
List all available test scripts in scripts/ and scripts/examples/
Inputs: no named parameters.
modify_componentB
Modify properties of a component on a GameObject
Inputs: path (required), component (required), properties (required).
pingB
Test connection to Unity Inspector
Inputs: no named parameters.
query_gameobjectsB
Search for GameObjects by name or component
Inputs: maxResults, namePattern, componentType, includeInactive.
read_logB
Read the UMM mod manager log file. Returns the last N lines by default, or filter by pattern.
Inputs: lines, filter.
restart_levelA
Restart the current level from the beginning. Clears checkpoints and trigger state for a full reset.
Inputs: no named parameters.
run_test_scriptA
Execute a test script containing a sequence of commands. Scripts are JSON files with command sequences that can include wait delays. Steps run directly against the game, so only game-side commands work — server-side tools (read_log, watch_log, list_scripts, launch_game, stop_game, wait_for_game, ...) cannot be used as steps.
Inputs: script (required).
set_broA
Set which bro the player will spawn as next (on death/respawn/next level). Does NOT change the current bro mid-level.
Inputs: broName (required), playerNum.
set_game_speedA
Set the game speed (time scale)
Inputs: speed (required).
set_player_healthC
Set a player's health
Inputs: health (required), playerNum.
simulate_inputC
Simulate keyboard/controller input
Inputs: action (required), count, player, duration, +1 more.
spawn_entityC
Spawn an entity at a specific position (limited implementation)
Inputs: x (required), y (required), type (required).
stop_gameA
Stop the running Broforce process.
Inputs: no named parameters.
swap_broA
Swap the current player's bro mid-level. Kills the current bro and spawns the new one at the same position. Integrates with Swap Bros Mod when available, falls back to direct game manipulation.
Inputs: broName (required), playerNum.
take_screenshotA
Take a screenshot of the game. Returns the path to the saved screenshot.
Inputs: no named parameters.
teleport_playerB
Teleport a player to a specific position
Inputs: x (required), y (required), z, playerNum.
unload_scriptA
Unload an active C# script, cleaning up its Harmony patches, GameObjects, and calling its Unload() method if defined.
Inputs: name (required).
wait_for_gameA
Wait for the game to start up and the Unity Inspector TCP server to become responsive. Polls the connection until a ping succeeds or timeout is reached.
Inputs: timeout, interval.
watch_logA
Return log entries that appeared since the last call to watch_log. First call returns the last 20 lines as a baseline. Use this for iterative debug loops.
Inputs: reset.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 33 tools
Tools generally target distinct resources/actions: scene inspection, component editing, player manipulation, and script execution. The main confusion risk is among execute_code, execute_script, and run_test_script, but their descriptions clearly distinguish C# expressions, C# script files, and JSON command sequences.
Names consistently use snake_case and mostly follow a verb_noun pattern like list_gameobjects, set_player_health, and restart_level. Minor deviations such as game_state being noun-only, the bare ping, and mixing execute/run verbs prevent a perfect score.
33 tools is well beyond the 25+ threshold and feels over-scoped for a single server. Many specialized tools like list_bros, swap_bro, set_bro, list_campaigns, and go_to_level could be grouped into broader commands or consolidated.
The surface covers scene inspection, component modification, player and level manipulation, input simulation, logging, screenshots, and script lifecycle management. Minor gaps like adding/removing components or destroying GameObjects exist, but execute_script can largely cover those cases.
Maintenance
Related MCP Connectors
Drive a live Cinevva game session: edit game files, import CC0 assets, preview changes.
Make games with AI: one MCP server that connects your agent to Unity, Unreal and Godot editors.
Build, edit and preview browser games and web apps in your Amplify account from your AI agent.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query and control the Unity Editor, supporting scene management, GameObject manipulation, asset browsing, play mode control, and real-time editor operations through 52+ tools.1MIT
- AlicenseNot gradedqualityNot gradedmaintenanceExposes Unity Editor project context and manipulation tools to AI coding agents, enabling automated scene hierarchy analysis, script inspection, and asset management. It supports both read and write operations including GameObject editing, component configuration, and animation authoring within the Unity environment.2-
- AlicenseNot gradedqualityBmaintenanceEnables AI models to interact with Unity games at runtime by providing tools to list UI actions, inspect GameObjects, capture screenshots, and manage scenes.9MIT
- AlicenseNot gradedqualityAmaintenanceUnity Editor automation bridge for AI agents and MCP clients, enabling inspection, control, and diagnostics of the Editor.MIT