gmod-mcp
gmod-mcp is an in-game Garry's Mod MCP server that lets an AI agent control and inspect a running GMod process through Lua, console, maps, entities, UI, sound, and diagnostics.
Run Lua in the menu, client, and server realms; execute or reload files, check syntax/globals, inspect values, and run long co-routine jobs.
Load/list maps, disconnect, wait for Lua conditions or frames, quit or terminate the game.
Execute console commands, read console output, wait for log lines, get/set convars, and list commands.
Read/clear Lua errors across realms and use report channels/events.
Find, spawn, remove, or fire entities; inspect and move players; add bots; trace lines and crossed surfaces.
Take screenshots, including from arbitrary cameras or the main menu, and draw debug primitives.
Click/type in the game UI on Windows test clients.
Emit and trace sounds; capture performance snapshots and hook costs.
List and trace hooks; search the live Lua API and read/search the GMod wiki.
Run GLuaTest-format Lua tests.
Manage multiple game instances: list, launch/close test clients, select a default instance, and mount a separate Lua folder for branch testing.
Provides tools to search and read the Facepunch Garry's Mod wiki (wiki.facepunch.com), with cached wiki page retrieval for looking up Garry's Mod documentation.
gmod-mcp
The GMod MCP server that runs inside the game: Lua in every realm, maps, console, errors, screenshots, hook tracing, test clients and long-running jobs, straight from inside the game.
Quick start (Claude Code, Windows)
1. In Claude Code, run:
/plugin marketplace add ExtReMLapin/gmod-mcp
/plugin install gmod-mcp@gmod-mcp2. Restart Claude Code.
3. Ask Claude: set up gmod-mcp
That's it. Claude installs the module in your game (it asks first) and starts Garry's Mod with -mcp.
4. Turn on updates (recommended): /plugin → Marketplaces → gmod-mcp → Enable auto-update. Claude Code
keeps auto-update off for marketplaces other than Anthropic's, and no claude plugin subcommand turns it on. See
Updates.
Other MCP clients, Linux or a dedicated server: see Install. Tested with Claude Code 2.1.325.
An MCP server that lives inside Garry's Mod. Drop one native module into your game and an AI coding agent (Claude Code or any MCP client) can run Lua in the menu, client and server realms, load maps, read the console and errors, inspect and edit the world, take screenshots, trace hooks and look up the documentation — on your own machine.
Self-contained: one DLL, one small Lua file and a small block in
menu.lua(see What gets modified). With Claude Code, the plugin brings the module and adds a small bridge that Claude Code starts by itself. No Python, no Node, nothing to run yourself.Local only: listens on
127.0.0.1with a bearer token, refuses pages from other sites, inactive unless the game is started with-mcp.Safe by default: never touches the client realm while you are connected to someone else's server.
Related MCP server: gmod-mcp
Contents
Install
You need Garry's Mod with the 64-bit binaries (the default on current Steam builds: bin\win64\gmod.exe, or
gmod_win64.exe at the root of the game folder on older installs). Two ways: the Claude Code plugin (the Quick start at
the top of this page), or by hand for any other MCP client.
Claude Code plugin
The repository is also a Claude Code plugin marketplace. In Claude Code:
/plugin marketplace add ExtReMLapin/gmod-mcp
/plugin install gmod-mcp@gmod-mcpFrom a shell: claude plugin marketplace add ExtReMLapin/gmod-mcp, then claude plugin install gmod-mcp@gmod-mcp.
Restart Claude Code, then ask Claude set up gmod-mcp: its skill copies the two files into the game (after asking
you) and starts the game with -mcp. Claude Code stays connected while the game is closed: the tools say so, Claude
starts the game again instead of giving up, and they work again as soon as it is up, no reconnection needed. Updates:
see Updates.
The plugin holds:
the
gmodMCP server:gmod-mcp-bridge, a small stdio program Claude Code starts by itself. It relays to the game, stays connected while the game is closed (tools then answergame_not_running), and tells Claude Code when the game is back. It reads the token from its file, so nothing secret lands in Claude Code's settings;the module of the same version, for the game (Windows and Linux binaries);
one skill: how to install or update the module, find the game folder, start the game with
-mcp, run several games, set up a dedicated server. It asks before touching the game folder and never restarts a game you just closed.
Each release publishes the plugin as one zip (gmod-mcp-plugin.zip, pinned by its SHA-256 in the marketplace), so the
repository holds no binaries.
If you added the server by hand earlier (claude mcp add ... gmod), the plugin does not replace that entry: both
stay and every tool is listed twice. Remove the old one with claude mcp remove gmod (add -s user if you added it
with --scope user; an entry added without a scope only exists in the folder where you ran the command).
Right after the install, Claude Code may say "1 userConfig option not yet set": that is the option that turns the feedback offers on or off, which is on by default. Nothing to do.
Remove the plugin with /plugin uninstall gmod-mcp@gmod-mcp.
By hand, 1. Garry's Mod side (drag and drop)
Download
gmod-mcp-win64.zip(Windows) orgmod-mcp-linux64.zip(a Linux dedicated server) from the latest release.Open it. Everything sits in a top folder,
gmod-mcp-win64/(orgmod-mcp-linux64/): drag thegarrysmodfolder from inside it onto your game folder (…\steamapps\common\GarrysMod, the one that already contains agarrysmodfolder). Accept the merge. That adds two files:garrysmod/lua/bin/gmsv_mcpagent_win64.dllandgarrysmod/lua/autorun/server/mcpagent_boot.lua.In Steam: Garry's Mod → Properties → Launch options, add:
-mcpRecommended, so the game keeps running at full speed in the background:
-mcp -windowed +engine_no_focus_sleep 0 +snd_mute_losefocus 0Start the game and load any map once (Start new game). The module installs its main-menu loader by itself; from then on it starts at the main menu every time. The console says
[mcpagent] main-menu loader installed ….
By hand, 2. MCP client side
Open the game console (~) and type:
mcpagent_setupIt prints the exact setup for your machine, token included. For Claude Code without the plugin, paste this in a
terminal (--scope user makes it available in every folder; without it the entry only exists in the folder where you
ran the command):
claude mcp add --scope user --transport http gmod http://127.0.0.1:27080/mcp --header "Authorization: Bearer <token>"Restart Claude Code. That's it. The same output also shows a .mcp.json snippet for other MCP clients (Streamable
HTTP + bearer token). The token is created once in %APPDATA%\gmod-mcp\token (Linux:
$XDG_CONFIG_HOME/gmod-mcp/token, ~/.config/gmod-mcp/token by default), never changes, and is only printed when you
ask for it — keep it private.
Without the plugin, Claude Code only connects if the game is already running when it starts; otherwise use /mcp,
Reconnect, once the game is up. The plugin avoids that. Other MCP clients can do the same with gmod-mcp-bridge from the
release zip, a stdio server that stays up while the game is closed.
Each release also attaches gmod-mcp.mcpb, the same bridge (Windows and Linux x86-64) as an
MCP Bundle, and is listed in the
official MCP Registry as io.github.ExtReMLapin/gmod-mcp: MCP clients that
install from the registry or open .mcpb files can use it. It is only the bridge: the game still needs the module from
step 1 above, and the game still has to run with -mcp.
Dedicated server
Same zip (gmod-mcp-linux64.zip for a Linux server), same drag and drop of its garrysmod folder into the server's
folder (the one that holds garrysmod and the server binary), and start the server with -mcp. Only the server realm
exists in that mode. The module is 64-bit: start srcds_win64.exe (Linux: srcds_run_x64). On Linux the default branch
of the dedicated server has no 64-bit binary: install it with +app_update 4020 -beta x86-64.
Linux server branches:
x86-64works on Ubuntu 22.04 (glibc 2.35, where it was tested) and newer.dev(64-bitsrcds_linux64) needs glibc 2.38 andGLIBCXX_3.4.32(Ubuntu 24.04 or newer): the server binary itself does not start on older systems, with or without the module.The public (default) branch is 32-bit only. The module is 64-bit and is not loaded there; the server starts normally, without gmod-mcp and without a crash.
game_quit on a dedicated server: the engine blocks the console quit from server Lua, so on Linux the module ends the
process itself with SIGTERM (the server's own clean shutdown) half a second after it answered. On a Windows dedicated server
there is no such path and game_quit answers the error blocked (stop the server from its console, or use
game_terminate, which kills it at once). game_terminate works the same on both systems.
mcpagent_setup works in the server console too. The plugin and the bridge reach a server running on your machine
like a game: a server alone takes port 27080; next to a client game, use instances_list and pass instance
(see Several games at once). The plugin's skill can also set a server up for you.
Updates
What updates by itself. With auto-update on (
/plugin→ Marketplaces →gmod-mcp→ Enable auto-update), Claude Code updates the plugin a few minutes after a session starts; the new version runs from the next start of Claude Code (or after/reload-plugins). Claude Code keeps it off for third-party marketplaces and noclaude pluginsubcommand turns it on: use that menu.By hand, in a shell:
claude plugin marketplace update gmod-mcp claude plugin update gmod-mcp@gmod-mcpthen restart Claude Code (or
/reload-plugins). The first command matters: Claude Code compares with its local copy of the marketplace, and without refreshing itplugin updateanswers "already at the latest version".What is in the plugin: the bridge Claude Code talks to, the skill, and a copy of the module for the game.
What does not update by itself: the module loaded by the game (
garrysmod/lua/bin/gmsv_mcpagent_*.dll). After a plugin update, quit Garry's Mod and ask Claudeupdate gmod-mcp: the skill copies the new module into the game. Until then, tool results carry a warning that names both versions: the bridge learns the module's version when the game first answers, so it shows from a moment after that, and the server instructions carry it too.Without the plugin: quit the game (it keeps the DLL locked), download the new zip from the releases and overwrite the two files. The version warning is a feature of the bridge, so only the plugin gives it.
What the commands download:
/plugin marketplace addclones this repository (to read its.claude-plugin/marketplace.json);/plugin installand updates download only the release zip of that version (gmod-mcp-plugin.zip, checked against its SHA-256), not the source code.
Feedback from agents
Agents using gmod-mcp are asked (server instructions, guide, skill) to note the frictions they meet with it and, at the
end of a task, to offer you to report the ones that cost real time or a feature. If you agree, they draft the issue in
English with no secrets, paths, project names or code, look for duplicates, and file it with gh when it is installed
and signed in (otherwise they give you a prefilled link: one click). Issues carry the agent-feedback label.
To turn the offers off, set the plugin option feedback_offers (on by default) to false: /plugin configure gmod-mcp@gmod-mcp in Claude Code, or in a shell:
echo '{"feedback_offers": "false"}' | claude plugin configure gmod-mcp@gmod-mcp --values-stdinThen restart Claude Code.
Comparison with other servers
As of 2026-11-14, gmod-mcp covers the most capabilities of the 22 Garry's Mod MCP servers we compared. Code read, nothing executed · method & full table
Repos: ExtReMLapin/gmod-mcp · AmyJeanes/GMod-MCP-Server · Sycatle/gmod-mcp · TomDotBat/gmcl_mcp · Pollux12/vscode-gmod-glua-ls · Celant/GmodMCP · Earu/GTerm · mathis1M/gmod-mcp · 14 more
Tools
Area | Tools |
Session |
|
Lua |
|
Hooks |
|
Console |
|
Errors |
|
World |
|
Rendering |
|
UI input |
|
Sound |
|
Performance |
|
Documentation |
|
Events |
|
Instances |
|
Besides tools, the server offers:
Prompts (slash commands in Claude Code):
write-lua-job,debug-errors,run-tests,check-map, with completion of map names, realms and test files.Resources: the agent guide (
mcpagent://guide),gmod://errorsandgmod://console(subscribable: the client is told when they change), and the templatesgmod://wiki/{page}andgmod://lua/{path}.Progress and cancellation: long tools report progress while they run, and stop when the client cancels. Long operations (
map_load, long waits, long jobs) run as background MCP Tasks for clients that support them.Confirmation: changing a convar saved in your
config.cfgasks you first (when the client supports it).
Long-running Lua jobs
lua_exec runs code in one go, and the game is frozen while it runs. For anything longer, lua_job runs the script
as a coroutine resumed once per frame. The script talks back through a job object, and its progress shows up in
Claude Code while it runs:
local props = 0
local all = ents.GetAll()
for i, ent in ipairs(all) do
if ent:GetClass() == "prop_physics" then props = props + 1 end
if i % 100 == 0 then job:progress(i, #all, props .. " props so far") end
job:step() -- hands control back to the game once this frame's time slice is used
end
return { props = props }Also available: job:sleep(seconds), job:frames(n), job:wait(fn, timeout), job:report(value) for intermediate
results, job:dt() (real seconds since the last resume; FrameTime() on the server is the tick step, not that interval), job:call(realm, code) (runs a chunk in the other realm of the instance and returns its values, so one job can move the player on the server and check what the client sees), and args (also job.args) for the call's arguments. async: true returns at once with a job id
(lua_job_status returns only the reports added since your previous call and, with wait_s of 15 or more, comes back by itself; lua_job_cancel), and fresh_env: true keeps the script's globals out of the game's _G. The agent learns this protocol from the tool description and the
write-lua-job prompt.
Testing a branch: the mounted Lua folder
Every game process loads the addons from the same garrysmod/addons/ folder, so an agent that works in a git worktree
of an addon cannot test its branch in one test client without changing the folder every other client (and your own
game) uses. The mounted folder solves this per process: lua_mount {path: "D:/dev/my-addon-wt"} (or
instances_launch {lua_mount: "D:/dev/my-addon-wt"} for a new test client) makes that one game look for Lua files in the
worktree before every addon. include(), autorun files and AddCSLuaFile then get the branch's files, at every map
load, and the other games keep the installed addon.
instances_launch {count: 1, owner: "fork-a", lua_mount: "D:/dev/my-addon-wt", map: "gm_construct"}
lua_function_source {realm: "server", expr: "MyAddon.Update"} -> source: the worktree's filepathis the addon's root (the folder that containslua/) or itslua/folder, absolute. Itsgamemodes/folder is overlaid too (materials, sounds and models are not: see the table below).The path must be ASCII-only: the game's file system lists a folder with non-ASCII characters but loads none of its files, so
lua_mountrefuses it. Use an ASCII junction instead (mklink /J C:\dev\my-addon "D:\Développement\my-addon").It applies to files loaded from then on. Code that already runs is not run again: after
lua_mount, callmap_load.instances_launch {lua_mount}sets it before the first map, so nothing more is needed there.lua_mount {}shows the current mounted folder and the engine's Lua search paths;lua_mount {path: null}removes it (from the next map load).The engine caches Lua files by name and file time;
lua_mountempties that cache when it changes (so an addon file and its worktree copy with the same name and time cannot be mixed up). Example: the worktreeD:/dev/my-addon-wtof the addon installed asgarrysmod/addons/my_addon, mounted withlua_mount {path: "D:/dev/my-addon-wt"}thenmap_load:
File on disk | What this game does with it |
| runs as |
| what |
| found by |
| still loaded from the installed addon |
| gamemode files |
| not mounted |
What sees the mounted folder (checked in game): autorun files,
include(),AddCSLuaFile(the client gets the folder's copy), the console'slua_openscript/lua_openscript_cl,file.Read/file.Findwith"LUA", and gmod-mcp'slua_exec_file,lua_job {path},lua_check,lua_reloadandlua_function_source, which look in the same order as the engine. Not affected: materials, sounds, models,data/.A file of the folder hides the installed addon's file with the same Lua path; files only in the game are still loaded, including a file your branch deleted.
The engine names the folder's files from the folder's root:
debug.getinfo(f).sourceis@lua/my_addon/x.lua, not@addons/my_addon/lua/my_addon/x.lua.No autorefresh:
status.lua_mount.stale_fileslists the folder's files that changed since each realm loaded them;lua_reload {mounted_changed: true}runs them again (orlua_reload {path}for one file, ormap_load), thenlua_function_sourceto check that the running function is the file's. A reload re-runs the file: it does not undo hooks or entities the old copy created.map_loadwarns when the folder changed during the load, and empties the engine's Lua file cache first.Which copy ran:
lua_function_sourceandlua_inspecton a function returnfrom_mountand the realdiskpath (@lua/x.luais the same name for the folder's copy and an installed one). It is recorded when the folder was put in front of the realm's Lua path, not guessed from the name.Windows game clients only for now: not on Linux (the engine's filesystem interface is not verified there) nor on a dedicated server (its filesystem interface is not reachable the same way).
How it works: the engine's own search paths (
IFileSystem::AddSearchPathat the head of the Lua path IDs), put back in front at every map start; see docs/REVERSE.md. Nothing is written to the game folder.
How it works
A Garry's Mod process runs up to three Lua states: menu (always there), client and server (created when a map loads, destroyed when it unloads). The module is loaded once per process, in the menu state, and drives the other two, re-injecting its small Lua runtime each time a map loads.
flowchart LR
agent["AI agent<br/>(Claude Code)"] -- "MCP over HTTP<br/>127.0.0.1:27080" --> http
subgraph game["the 64-bit game (one process)"]
direction TB
subgraph dll["gmsv_mcpagent (native module, loaded once)"]
http["HTTP / MCP server<br/>(network thread)"] -- "job queue" --> pump["pump<br/>(main thread, every frame)"]
end
pump --> menu["menu state<br/>always present"]
pump --> client["client state<br/>after a map loads"]
pump --> server["server state<br/>singleplayer / listen"]
endAll Lua runs on the game's main thread; the network thread only queues work, so a frozen game can still be inspected
(status) and killed (game_terminate).
With the plugin, Claude Code does not talk to the game directly: it starts gmod-mcp-bridge (stdio) and the bridge
relays every message to the game over that same HTTP connection. The bridge listens on nothing, answers while the game
is closed (every tool listed, calls saying the game is not running), tells Claude Code when the game is back, and holds
the tools that must work without a game: instances_launch, instances_close, instance_select.
Several games at once
Each game process (a client, a dedicated server…) has its own MCP server on its own port: 27080, then 27081, 27082… Nothing is shared between processes except a directory.
flowchart LR
agent["AI agent"] --> coord["client game<br/>:27080 (holds the base port)"]
coord -- "relay: instance=srcds-…" --> srcds["dedicated server<br/>:27081"]
srcds -. "heartbeat every 2 s" .-> coordThe process holding the base port also acts as a directory and relay:
instances_listshows every running game, and any tool accepts aninstanceargument to target another game. So Claude Code needs a single entry.With one game running, nothing changes: no
instanceneeded. With several, calls withoutinstanceare refused withambiguous_instance(listing the ids) instead of guessing, and every answer says which game produced it (answered_by).A game that crashes is told apart from one that quit: calls to it answer
client_crashed(server_crashedfor a dedicated server) with the name of the crash dump incrashes/(when one was written) and the exit code, andinstances_listshows it ascrashedfor an hour. The coordinator decides from the game's own goodbye at shutdown, agame_quit/game_terminatesent through it, a dump written just before the process ended, and its exit code. A process killed from outside with no dump looks like a crash with exit code 1. A call in flight to a game that dies is answered at once, and the answer carries the free memory of the machine (out of memory is a likely cause).A game that is hung is flagged:
instances_listgivesstalled_s(seconds its main thread has been blocked) andfps_low_s(seconds under 10 fps), and the state becomeshungafter 60 s (180 s during a map load) with the advice to close and relaunch; a call to a frozen process fails withinstance_hungafter 30 s without heartbeat.instances_launchchecks the free commit and RAM first and refuses withlow_memory(the figures, how many clients run) when they cannot hold the clients;ignore_low_memory: trueoverrides it.If the game holding the base port exits, the others keep running; within a few seconds one of them takes the base port over and the rest register with it.
A long call (an MCP task) lives in the game that runs it. A
lua_job,map_load, longwait_for... started as a task for another instance is created by that instance, and its task id starts with that instance's id (client-1234.<hex>). The coordinator only relaystasks/get,tasks/result,tasks/cancelandtasks/list, so whichever game holds the base port later finds the task again: closing or losing the coordinator no longer loses it, as long as the game that runs it lives. During the hand-over (about 3 s) a task request answers the retryablecoordinator_changing(the plugin retries it for you); if the owning game ended, it answersinstance_gone,client_crashedorinstance_hungwith the reason, never "task not found".async: trueis still the way to keep a job's result in the game for a poll of your own.
Several clients can run side by side too. With the Claude Code plugin, the instances_launch tool starts 1 to 8
test clients (small, frame-capped, on a private desktop, Windows for now), instances_close closes them (by id, pid or owner label),
and instance_select sets the default instance of a session. Its description gives the measured cost: about 1.5 GB of
RAM and a fifth of a CPU core per client. Sub-agents of one Claude Code session share that session: each one labels its
clients with owner and closes only those. The label travels with the game (command line and heartbeat), so
instances_list shows it on every instance and instances_close {owner} still finds clients started with keep: true
by an earlier session; it never closes a game that is not one of our test clients.
Starting a game makes every other running Garry's Mod release its GPU resources for 2-10 s, and a map load ending in
that window crashes that game (engine bug, Facepunch garrysmod-issues#7137).
The bridge therefore makes instances_launch and map_load wait for each other (every session of the user shares the
lock; every result carries waited_s / waited_reason (0 / null when nothing waited), duration_s and load_s (the games' own time), errors map_load_in_progress / launch_in_progress when the wait would
exceed timeout_s), and instances_launch {map} loads its maps after a 15 s settle delay; at most 2 maps load at a time across all sessions (a third map_load or launch load waits, map_load_in_progress at the timeout). It also sees map
loads it did not start (console map, Lua, a script talking to the game: every game reports loading in instances_list),
instances_launch waits for them too and map_load lists them (other_games_loading). It cannot hold back a game you
start by hand, nor a console or Lua map load started while a launch is creating its processes: do not do those while
other games load or launch.
Right after a game starts, the other games can be unreachable for 15-18 s (instance_unreachable): wait and retry. Best
order: launch all clients in one instances_launch, then work. GMOD_MCP_FP7137_WORKAROUND=0 turns the wait off.
The game that holds the base port is the coordinator (instances_list shows it): when it ends, another game takes the role over in about 3 s and calls with instance answer the retryable coordinator_changing meanwhile (the bridge retries for 10 s); instances_close says when it closed the coordinator.
The clients start on a private Windows desktop (desktop: "private", the default; Windows only). What makes your own game
freeze and glitch when a test client starts is the new game's broadcast, which only reaches the windows of its own
desktop: a client on another desktop of the same window station never finds your game, so your game is not disturbed
at all (measured: no video-memory drop, no blocked main thread). One desktop per bridge session, created at the first
launch and closed once its last client is gone. What it changes: the clients have no window and no taskbar button (close
them with instances_close, not by hand), they never take your focus (no -mcp_return_focus), and they are silent by
default (-nosound; pass sound: true for sound tests, as SoundDuration of ADPCM WAV files differs without sound).
ui_click, ui_key and screenshot still work (the module posts window messages inside the game's own process, and
the screenshot is the engine's own capture). desktop: "shared" starts them on your desktop as before (visible window,
the foreground handed back to you). The clients of one session share their desktop, so they still disturb each other:
the waits above still apply. Games started by hand are not on it: they are covered by the waits only.
The clients share the game folder with your own game, including data/, cfg/ and the cookies (sv.db/cl.db): a
test that writes there changes your game too, and nothing in the module redirects or hides those writes (it does not
replace any of the game's file.* functions, so an addon that checks them sees the real ones). An addon that caches into
data/ does it in the first seconds after the map loads (and an addon whose cache format changed may delete the old cache
there), before commands can switch it off: its convars do not exist yet. Switch its writes off with early_lua, and
clean up after the test.
early_lua runs your Lua in the client and server realms of each client before any addon's file, to set what an
addon reads before its first write (an addon's convars and globals do not exist when commands run): set its own
switch, hook a function, wrap a call. The module writes it into a small autorun file that it mounts in front of every
addon, so it replaces nothing in the game. A Lua error in it is printed to the console, not raised. status shows
early_lua (mounted, and error when the mount was refused: the code then does not run). The temporary folder of
that file is removed by instances_close and at the end of the session; a client killed together with its bridge leaves
it behind and the next launch removes folders nothing touched for three days.
Archived convars changed through commands, launch_args or fps_max are given back to your value from
cfg/config.cfg before a clean quit, like the options the tool sets itself (the module restores those that exist and
are archived at that moment; the list is fixed at launch, so a convar an addon creates later and that you set from
console_exec is not restored). instances_close kills the process: nothing is written then.
Before a launch the bridge compares the module in the game folder (lua/bin) with the one the plugin ships: an older one
refuses the launch with module_outdated and the update steps (ignore_outdated_module: true starts anyway), and
instances_list / the game_not_running error show module_outdated while no game runs.
Test clients leave your video settings alone. Garry's Mod normally saves the window size it was started with as its video setting (resolution, anti-aliasing, ... in the registry).
instances_launchstarts its clients with-dxlevel 95, the level the engine keeps on current hardware: with that option the engine neither reads nor writes those settings, so your own resolution is still there at your next start. (Clients that older versions of gmod-mcp started could overwrite it: if your game opens small, set the resolution again in the video options. Clients you start by hand with-w/-hstill save their size: add-dxlevel 95to avoid it.)
Test clients leave your frame cap and focus options alone.
instances_launchstarts its clients with+fps_max 20(30 for thenormalpreset),+fps_max_nofocusand+snd_mute_losefocus 0. Those convars are saved intocfg/config.cfgwhen a game quits cleanly, and your own game reads the same file: a test client that quit would have left yourfps_maxat 20. The clients now carry-mcp_test_client, and before one quits cleanly (game_quit, aquitsent throughconsole_exec, the main menu's Quit button, the window's close button) the module sets each of these convars back to the value yourconfig.cfghas at that moment, or to the convar's default when the file has no line for it. Not covered: aquittyped by hand in a test client's console.instances_closekills the process, which saves nothing. (A client that older versions started and then quit may have changedfps_maxin your config: check it in the options.)
Frame cap, extra options and startup commands for test clients. instances_launch takes a few options for what the
presets do not cover (they are checked before anything starts; a refused one is invalid_params naming it):
instances_launch {count: 1, fps_max: 300, fps_max_nofocus: 0,
commands: ["snd_mute_losefocus 0", "cl_showfps 1"],
launch_args: ["-noborder"], map: "gm_construct"}fps_maxandfps_max_nofocus(integers,0= no cap, otherwise 10 to 1000) replace the preset's frame cap (fps_max_nofocusfollowsfps_maxwhen only that one is given). The result says what the clients run at (fps_max,fps_max_nofocus,fps_note).commandsare console commands run on each client once it answers, before the map loads, in order;instances[].commandssays how each went.quit/exit,connect/retry/redirect/connect_lobby(gmod-mcp never connects to a server) and map changes (map,changelevel,load: usemap) are refused.launch_argsare extra engine command-line tokens, one per array element (["+cl_showfps", "1"], a word without spaces, quotes or;). Refused: what gmod-mcp sets itself (-multirun,-mcp*,-w,-h,-width,-height, the window-mode options,-dxlevel,-condebug,-game),+connectand+map. The options are listed on the Valve Developer Community, Command line options (and the Garry's Mod wiki for the GMod-specific ones); console commands and convars are listed byapi_searchandconcommand_list.
The archived convars these options change (fps_max, a +convar token, a command such as cl_showfps 1 or toggle snd_mute_losefocus) are given back to your value before a clean quit, exactly like the built-in ones above (the bridge
lists their names to the module with -mcp_restore_convars; this needs the module of the same release, an older one
restores only the four it knew). A convar changed by exec of a cfg file is not tracked.
Code Mode (Claude Code)
Claude Code's experimental Code Mode lets the model write JavaScript that calls the tools
(await tools["mcp__plugin_gmod-mcp_gmod__status"]({})). gmod-mcp works with it:
A result arrives as a string, the JSON of
structuredContent:JSON.parseit (and accept an object too, a later Claude Code version may pass one).An error throws, and
e.detailis the parsed error{"error": {code, message, details, next_call?}}: the text of every error is exactly that JSON object, also the ones the bridge answers itself (game_not_running,port_conflict...) and when the plugin and the module have different versions (the warning is a field of that object,version_warning).A long call (
map_load, a wait of 15 s or more) is answered synchronously when it comes from a script (Claude Code marks those calls), soawait map_load(...)returns the real result. Outside Code Mode, a client that supports MCP tasks getsmap_loadas a background task: setGMOD_MCP_TASKS=off(see Configuration) to turn that off for every client.At most 10 calls run in parallel in a script. Map loads and launches are still one at a time (the FP7137 lock), so parallel
map_loadcalls queue.
Configuration
Launch option | Effect |
| Required. Without it the module prints one line and does nothing (and never touches any file). |
| Base port, 1 to 65000 (default |
The bridge only talks to the base port. If you changed it with -mcpport, tell the bridge the same number: with the
plugin, set the GMOD_MCP_PORT environment variable for Claude Code (--port <n> is for running gmod-mcp-bridge
yourself, in another MCP client's configuration). It also matters when another program already holds port 27080: the
game then takes the next free port (its console line [mcpagent] active: ... http://127.0.0.1:<port>/mcp says which)
and the bridge does not look there. Free port 27080, or start the game with -mcpport <free port> and set
GMOD_MCP_PORT to that port. The bridge recognises the situation: gmod-mcp signs every answer with an X-Gmod-Mcp
header, so a port that answers without it is held by another program, and the tools then answer port_conflict (not
game_not_running), naming the port, how to find the program (Get-NetTCPConnection -LocalPort 27080 on Windows,
ss -ltnp on Linux) and, when it finds one on the next ports, the GMOD_MCP_PORT value to use.
Environment variable | Effect |
|
|
Scratch Lua files for the agent go to garrysmod/lua/mcpagent_tmp/ (status gives the absolute path); errors and
tracebacks then point at the real file.
Security
Binds to
127.0.0.1only. Every request needs the bearer token; a browserOriginother than a local one (localhost,127.0.0.1,[::1]) is refused, and theHostheader must be loopback with the right port (DNS rebinding). The bridge opens no port at all.The only outbound traffic is HTTPS GET requests to
wiki.facepunch.com, through the game's own HTTP client.Client realm lock. Running Lua in the client state bypasses
sv_allowcslua, like a cheat would. The module refuses to touch the client realm unless the server runs on your own machine: the game hosts it (singleplayer, listen server), or its address is loopback or exactly one of this machine's own network addresses (a local dedicated server). On any other server, even on your LAN, nothing is injected into the client, client calls fail withclient_lockedandstatussays why. This cannot be disabled.console_execrefusesconnect/redirectto servers that are not on this machine (including after a;). Aconnectmust also be alone on its line:echo x; connect ...is refused, because the engine crashes on it while a map is loaded.convar_setrefuses archived convars (they would end up in yourconfig.cfg) unless asked explicitly.
What gets modified in your game folder
The two files from the zip.
garrysmod/lua/menu/menu.lua: Garry's Mod has no plugin folder for the main menu, so the module appends a small block between-- MCPAGENT BEGINand-- MCPAGENT END(the original is saved once asmenu.lua.mcpagent.bak). The block is written to be harmless: everything runs insidepcall, an obviously broken or empty DLL is skipped instead of triggering a Windows error dialog, and if a load ever crashes the game, the next start skips the module and tells you why. The file is only written when the game runs with-mcp, and only if the result compiles.Steam "Verify integrity of game files" will report
menu.luaas modified and restore the original — that is expected. Game updates do the same. The block comes back by itself the next time you play with-mcpand load a map.garrysmod/data/mcpagent/(wiki cache) andgarrysmod/lua/mcpagent_tmp/(agent scratch files).With
instances_launch {early_lua}: a smallgmod-mcp-early/<token>folder in your temp folder, outside the game folder. It is removed when the client is closed, and the next launch removes the ones that are three days old.
Uninstall
Keep
-mcpin the launch options for now:mcpagent_uninstallonly exists while the module is loaded. Start the game, and at the main menu type in the console:mcpagent_uninstall. It removes the block frommenu.lua, which is then byte-identical to the original.Quit the game, then remove
-mcpfrom the Steam launch options.Delete
garrysmod/lua/bin/gmsv_mcpagent_win64.dll(Linux:gmsv_mcpagent_linux64.dll),garrysmod/lua/autorun/server/mcpagent_boot.luaand the backupgarrysmod/lua/menu/menu.lua.mcpagent.bak.Optionally delete
garrysmod/data/mcpagent,garrysmod/lua/mcpagent_tmpand the token folder (%APPDATA%\gmod-mcp, Linux:~/.config/gmod-mcp).With the plugin:
/plugin uninstall gmod-mcp@gmod-mcp, thenclaude plugin marketplace remove gmod-mcp. A server added by hand:claude mcp remove gmod.
Limitations
Tested on Windows x64 (game and dedicated server) and in a Linux x64 dedicated server. The Linux client game has not been tested.
instances_launchis Windows only.The very first start needs one map load (to install the main-menu loader).
Without a loaded map,
screenshotruns the engine's ownjpegcommand: the engine writes a file ingarrysmod/screenshots/, the module reads exactly the file the engine names in its console and deletes it (nothing else is touched). It works while other windows cover the game, but not while the game is minimized or frozen (capture_timeout). The image is the engine's JPEG at the game's screen size (shrunk to 960 px wide like the render capture unlessfull: true): no HUD choice, now/h, no PNG, nocrop/scale.screenshot_fromand therendersource need a loaded map.A
screenshotorscreenshot_fromwithoutw,h,crop,scaleorfull: trueis shrunk to at most 960 px wide and sent as a JPEG (quality 80); the result saysdownscaled_fromand how to get the full size (full: true). Acropstays at native pixels.An image is never returned above 8 MB encoded (a client drops the connection above 16 MB per message): a too big
pngcomes back as a JPEG (size_capped: true) or fails withresult_too_large.screenshot {crop, scale}crops and enlarges a small region (a HUD icon).hook_traceadds a temporary hook: if another hook returns a value first, that call is not seen.The Garry's Mod dedicated server ignores packets from
127.0.0.1: to join a local dedicated server, connect to this machine's LAN address (the client lock recognizes it as local).Lua errors raised by code run through
lua_execare returned to the caller, not reported byerrors_since.A
lua_jobdies with its realm: loading a map ends the jobs running in the client and server states.Progress and cancellation do not cross instances: a call relayed to another game reports neither.
MCP logging, sampling and roots (deprecated in the 2026-07-28 specification) are not implemented.
Building from source
Requirements: CMake 3.24+, a C++17 compiler (MSVC 2022 or GCC 11+), internet access at configure time (dependencies are fetched and verified by SHA-256).
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseThe output in build/ is the module, gmsv_mcpagent_win64.dll (or _linux64.dll), and the bridge,
gmod-mcp-bridge; loader/mcpagent_boot.lua is the autorun file. The build also runs gmod-mcp-snapshot, which writes
the module's tool descriptions into the bridge (served while the game has never answered).
Tests without a game: python tests/bridge/test_bridge.py <bridge> (a fake game server covers the protocol and the
odd cases) and python tests/protocol/check_constants.py (protocol constants against the official schema). CI runs
both on Windows and Linux.
The test matrix is in docs/TESTS.md; notes on the engine interfaces used are in
docs/REVERSE.md.
License
MIT — see LICENSE and THIRD_PARTY_NOTICES.md. Not affiliated with Facepunch Studios or Valve.
Available Tools
65 toolsapi_searchSearch the live Lua APIARead-only
api_search(pattern, realm?, limit?). Asks each running realm which functions really exist in this game build: globals, library functions (util.TraceLine) and metatable methods (Entity:EmitSound). Menu always answers (client mode); client and server only with a map loaded. The source of truth when the wiki disagrees. Pattern: a case-insensitive substring, or a glob with * matched against the whole name. Result: {results: [{name, kind, realms, wiki_page}], count, realms_searched}.
Inputs: pattern (required), limit, realm, instance. Returns: next, note, count, pattern, +9 more
bots_addAdd botsA
bots_add(n, name?). Adds n bots in the server realm (player.CreateNextBot), named _. They need free player slots: singleplayer (maxplayers 1) has none (error no_slots): map_load with maxplayers: 4 first. Bots do not survive a map load. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: n (required), name, instance. Returns: next, note, added, count, +6 more
concommand_listList commandsARead-only
concommand_list(realm?, engine?, filter?). Lists console commands: the Lua commands of realm (concommand.Add, name matching filter, a case-insensitive substring) and, with a filter and engine: true (default), the engine's commands and convars whose name or help matches. Result: {lua_commands, realm, engine_commands?, engine_convars?}.
Inputs: realm, engine, filter, instance. Returns: next, note, realm, warning, +8 more
console_bufferConsole buffer capacityAIdempotent
console_buffer(capacity?). Reads or sets how many console lines this game keeps for console_read, console_wait and console_exec (default 20000; lowering it drops the oldest lines at once). Without capacity: just reads. Result: {capacity, cursor}.
Inputs: capacity, instance. Returns: next, note, cursor, warning, +6 more
console_execRun a console commandADestructive
console_exec(cmd, realm?, connect_timeout_s?, regex?, wait_frames?). Runs a console command line from a realm (menu: RunConsoleCommand; server: game.ConsoleCommand; client: RunConsoleCommand, falling back to the engine if Lua blocks it). ';' and line breaks outside quotes separate commands. Waits a few frames, then returns the console lines printed meanwhile (the console is shared: filter with regex). An unknown command is an error (unknown_command). For every convar it set or named, convars gives the value read back (value, number, and a warning for FCVAR_ARCHIVE convars: they land in the user's config shared by every instance; convar_set refuses them unless persist: true). killserver on a game that hosts a map first leaves it like disconnect.
Inputs: cmd (required), realm, regex, instance, +2 more. Returns: cmd, via, next, note, +15 more
console_readRead the consoleARead-only
console_read(cursor?, limit?, regex?). Reads this game's console output: everything the engine and Lua print in every realm, one entry per line, in a ring buffer (20000 lines by default, see console_buffer) that survives map changes. Without cursor: the last limit lines (matching regex). With cursor: the lines from there on; pass next_cursor to the next call to read only new lines. Result: {lines: [{seq, t, level, text}], next_cursor, lost (lines dropped before you read them), capture}. To block until a line appears, use console_wait.
Inputs: limit, regex, cursor, instance. Returns: lost, next, note, lines, +9 more
console_waitWait for console linesARead-only
console_wait(regex, timeout_s?, count?, cursor?). Blocks until count console lines matching regex are printed (from cursor, default: now), e.g. the end line of a test batch: {regex: "^BATCH DONE", count: 4, timeout_s: 900}. Returns the matching lines and next_cursor (pass it to the next wait so nothing in between is missed). Lines come from every realm and the engine. Error timeout (with the lines found so far). Can run as an MCP task.
Inputs: regex (required), count, cursor, instance, +1 more. Returns: lost, next, note, lines, +9 more
convar_getRead a convarARead-only
convar_get(name, realm?). Reads a convar: value (string), number (compare this: the same value can read "0.0" or "0.000000"), default, help, flags, min/max, and archived: true when changing it is saved into cfg/config.cfg (shared with the user's game and every instance; archived_from says flags or config.cfg). Do not use ConVar:IsFlagSet(FCVAR_ARCHIVE) from Lua for this: it can be false for an archived convar (CreateClientConVar with save). A convar created this session and not saved yet shows archived: false. FCVAR_PROTECTED convars have their value masked.
Inputs: name (required), realm, instance. Returns: max, min, via, help, +19 more
convar_setSet a convarAIdempotent
convar_set(name, value, realm?, persist?). Sets a convar from a realm (RunConsoleCommand; server: game.ConsoleCommand), waits 3 frames and reads it back; when Lua cannot set it (volume_sfx...) it retries through the engine console. FCVAR_ARCHIVE convars are saved into the user's cfg/config.cfg when the game quits and shared by every game of this folder: refused unless persist: true. Result: the convar as convar_get reads it, plus previous and via. Errors: not_found, protected, archived, set_refused (cheat without sv_cheats, wrong realm, blocked command).
Inputs: name (required), value (required), realm, persist, +1 more. Returns: max, min, via, help, +19 more
debug_clearClear debug primitivesAIdempotent
debug_clear(). Client only (unsupported on srcds). Removes every primitive drawn by debug_draw (client realm). Result: {cleared: count}.
Inputs: instance. Returns: next, note, cleared, warning, +5 more
debug_drawDraw debug primitivesA
debug_draw(primitives, duration?). Client only (unsupported on srcds). Draws 3D lines, arrows, wireframe boxes and spheres, and text in the game world (a map must be loaded), visible on screen and in screenshot / screenshot_from. They add up across calls and expire after duration seconds of game time (0 = until debug_clear or the next map). Example: {"primitives": [{"type": "line", "from": [0, 0, 64], "to": [500, 0, 64]}, {"type": "text", "pos": [0, 0, 100], "text": "spawn"}], "duration": 30}.
Inputs: primitives (required), duration, instance. Returns: next, note, added, active, +7 more
disconnectReturn to main menuADestructiveIdempotent
disconnect(timeout_s?). Leaves the current map for the main menu (console disconnect) and waits until the client and server realms are gone. Client only (unsupported on srcds). Errors: busy (a map_load runs), timeout.
Inputs: instance, timeout_s. Returns: next, note, realms, warning, +8 more
ent_fireFire an entity inputADestructive
ent_fire(id, input, delay?, param?). Sends a map I/O input to an entity in the server realm (Entity:Fire(input, param, delay)), e.g. Open, Close, Toggle, Lock, Kill. Returns at once: the effect happens on a later frame, so check it with ent_info or wait_for. An input the entity does not know is ignored silently (no error). Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: id (required), input (required), delay, param, +1 more. Returns: id, next, note, delay, +8 more
ent_infoEntity detailsARead-only
ent_info(id, realm?, depth?, limit?). Details of one entity by index (id 0 = the world): class, model, name, nick, pos, ang, valid, velocity, health, solid, movetype, obb, parent and owner (ids or null), nw_vars, table (the entity's Lua table, cut at depth/limit), and in the server realm keyvalues and, for doors, door {state: closed|opening|open|closing|ajar}. transmit tells what reaches the client. An entity that is not on the client answers not_found there: ask both realms. Error not_found for an invalid id. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: id (required), depth, limit, realm, +1 more. Returns: id, ang, obb, pos, +26 more
ent_removeRemove an entityADestructive
ent_remove(id). Removes an entity by index in the server realm (Entity:Remove, effective at once). Players and the world are refused (forbidden); an invalid id gives not_found. Result: {removed: id}. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: id (required), instance. Returns: next, note, removed, warning, +5 more
ents_findFind entitiesARead-only
ents_find(realm?, class?, limit?, model?, near?, radius?). Lists entities, filtered by class, model and/or distance (filters combine; none = every entity). class and model are case-insensitive globs ("prop_*", "door"). near + radius keep entities within radius of near, nearest first, each with distance. Result: {entities: [{id, class, model, name (targetname), nick, pos, ang, distance?}], count (all matches), truncated}. id is the entity index for ent_info, ent_fire, ent_remove (a clientside-only entity has id -1: no tool can address it; use lua_exec in the client realm). Server realm by default; the client sees only networked entities (no targetnames). Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: near, class, limit, model, +3 more. Returns: next, note, count, warning, +7 more
ent_spawnSpawn an entityA
ent_spawn(class, ang?, freeze?, keyvalues?, model?, pos?). Creates an entity in the server realm: ents.Create(class), SetModel, SetPos, SetAngles, SetKeyValue for each keyvalue (strings), Spawn, Activate, then freeze. It stays until removed or the map changes. Result: the entity summary {id, class, model, name, pos, ang}. Error invalid_class. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: class (required), ang, pos, model, +3 more. Returns: id, ang, pos, name, +12 more
errors_clearClear errorsADestructiveIdempotent
errors_clear(). Forgets the errors kept so far (errors_since then starts empty); cursors keep growing, so an old cursor stays valid. Result: {cleared, next_cursor}.
Inputs: instance. Returns: next, note, cleared, warning, +6 more
errors_sinceRead Lua errorsARead-only
errors_since(realm?, cursor?, exclude_pattern?, exclude_source?, group_by?, limit?, pattern?, since_map_load?, ...). Lua errors of every realm of this game (client mode: the menu's OnLuaError hook; srcds: parsed from the console); the last 2000 are kept and survive map loads. Cursor: 0 = from the oldest; pass next_cursor to read only new ones (lua_exec, lua_job, tests_run, map_load... already carry new_errors with such a cursor). Grouped by default (a stuck loop repeats one error thousands of times): {groups: [{message, source, count, first_time, last_time, stack}], groups_total, next_cursor, lost}, most frequent first, 20 groups unless limit. group_by: "none" gives the raw list {errors: [{seq, realm, message, stack, addon, time, map}], ...}. Filters: since_map_load, source / exclude_source (a file prefix such as "lua/my_addon/client/"), pattern / exclude_pattern (a regex on the message).
Details: guide, Tool details, errors_since.
Inputs: limit, realm, cursor, source, +6 more. Returns: map, hint, lost, next, +14 more
events_waitWait for eventsARead-only
events_wait(timeout_s?, cursor?, limit?, types?). Waits for events of this game instance and returns AS SOON AS one of the wanted types arrives (all that arrived, up to limit), or after timeout_s with timed_out: true. Types: menu_ready, runtime_injected, realm_up, realm_down, realm_ready, map_loaded, disconnected, disconnect_reason, connection_failed, main_thread_stalled, main_thread_resumed, lua_error, runtime_error, report, focus_released, user: (from game code: mcpagent.event(type, data)). Without cursor it waits for events from now on; pass next_cursor to the next call so nothing is missed (the last 5000 are kept). Result: {events: [{seq, time, type, data}], next_cursor, lost, timed_out}.
Inputs: limit, types, cursor, instance, +1 more. Returns: lost, next, note, events, +8 more
game_quitQuit the game cleanlyADestructive
game_quit(). Asks the game to quit cleanly (console quit): it saves its config (cfg/config.cfg) and exits, and this instance's MCP server goes with it. For test clients started by instances_launch prefer instances_close (kills at once, saves nothing); game_quit is safe on them too: the module first gives the archived convars their command line changed (fps_max, fps_max_nofocus, snd_mute_losefocus...) the user's values from cfg/config.cfg. On a dedicated server the console quit is blocked from server Lua: on Linux the module ends the process itself (SIGTERM); on Windows srcds the error is blocked and nothing quits.
Details: guide, Tool details, game_quit.
Inputs: instance. Returns: next, note, warning, quitting, +5 more
game_terminateKill the game immediatelyADestructive
game_terminate(delay_ms?). Kills this game process at once (no config saved) from the network thread, so it works even when the game is frozen (status main_thread_stalled). The answer {terminating, pid} is sent first, then the process ends after delay_ms. With instance the coordinator relays it to that game. Never on the user's own game unless they ask.
Inputs: delay_ms, instance. Returns: pid, next, note, warning, +8 more
hook_listList hooksARead-only
hook_list(realm?, name?, added_by?, event?). Hooks registered with hook.Add in a realm (hook.GetTable), with where each function was defined. Without event: every event (large; name keeps the hooks whose identifier contains it). Result: {hooks: {: [{id, source, line, what, added_by?, chunk?, added_at?}]}, count, now}; with event also known (false: no such hook or gamemode function, probably a typo). A hook that lua_exec, lua_exec_file, lua_reload or lua_job added carries added_by (that tool), chunk and added_at (SysTime() of the realm; now - added_at is its age); added_by: "mcp" keeps only those, to see what the tools left on the game. A hook the addon replaced since is not reported; the list is bounded (500 hooks) and empty at every map load.
Inputs: name, event, realm, added_by, +1 more. Returns: now, next, note, count, +10 more
hook_traceTrace a hookARead-only
hook_trace(event, realm?, depth?, duration_s?, max_calls?). Records the calls of a hook event for duration_s (or until max_calls) with each call's arguments serialized, through a temporary hook.Add that returns nothing (behaviour unchanged), removed at the end. Waits the whole duration (can run as an MCP task). Result: {event, calls: [{t, args}], recorded, total_calls, capped, duration_s}. Not seen: calls that a hook running before it stopped by returning a value. Error realm_lost if the map changes meanwhile.
Inputs: event (required), depth, realm, instance, +2 more. Returns: next, note, calls, event, +11 more
instances_closeClose test clientsADestructive
instances_close(all?, instances?, owner?, pids?). Closes test clients this session started with instances_launch, at once, without writing their config: by instances ids, pids (also a client that never answered) or owner label (also keep: true clients of an earlier session); the selectors add up. Other games (the user's own, another session's) are refused: game_terminate, only if the user asks. Sub-agents share the session: close yours with {owner}, never {all: true}. Result: {closed: [{pid, instance?, owner?}], already_gone?, refused?}; closing the coordinator moves its role (calls answer coordinator_changing for a few seconds).
Details: guide, Tool details, instances_close.
Inputs: all, pids, owner, instances.
instance_selectSet the default instanceAIdempotent
instance_select(instance). Makes instance this session's default for calls without an instance argument (null clears it; lasts until the session ends). Not for sub-agents: they share the session, so pass instance on every call instead. Result: {default_instance, previous}; an id that instances_list does not show is refused (unknown_instance).
Inputs: instance (required).
instances_launchLaunch test clientsA
instances_launch(timeout_s?, allow_shadow?, commands?, count?, desktop?, early_lua?, fps_max?, fps_max_nofocus?, ...). Starts 1 to 8 test clients of Garry's Mod (also when no game runs: the first becomes the main instance), each with -multirun, gmod-mcp on, a small window and a frame cap, on a private Windows desktop, then loads map through map_load. Returns instance ids and pids: pass an id as instance on every later call. Windows only.
Defaults that change what your test sees: private desktop (no window, never takes the focus; close with instances_close); silent (-nosound: pass sound: true for sound tests); the clients share the user's real data/, cfg and cookies (switch an addon's writes off with early_lua, clean up after the test); preset light (default, 640x360, 20 fps: hides per-frame cost) or normal (30 fps: rendering checks, screenshots).
Clients end with this bridge session unless keep: true. Sub-agents share it: give each an owner label, close with instances_close {owner}, never {all: true}.
Options: fps_max, fps_max_nofocus, commands (console commands before map), launch_args (engine options: developer.valvesoftware.com/wiki/Command_line_options; commands and convars: concommand_list and api_search on a running client), early_lua (Lua before any addon file: commands run too late to switch an addon's data/ writes off), lua_mount (your worktree's Lua).
Errors: low_memory (1.6 GB commit and 1.2 GB RAM per client: close clients, or ignore_low_memory), module_outdated, peer_unhealthy (a frozen client: instances_close {pids}), map_load_in_progress (launches and map loads are serialised, FP7137), port_conflict, client_crashed (relaunch), timeout (silent_pids: close them), launch_incomplete (isError with the whole result).
Launch every client in ONE call, then work; do not interleave launches with map loads. Other games can be unreachable for 15-18 s after a start: wait and retry.
Details: guide, Tool details, instances_launch.
Inputs: map, keep, count, owner, +16 more.
instances_listList instancesARead-only
instances_list(include_crashed?, owner?). Known gmod-mcp instances (this one and, on the coordinator, every registered member): id, mode (client/srcds), port, pid, map, realms, role, state, fps, stalled_s, loading, lua_errors. Any tool accepts instance to be relayed to that instance. States: running; unresponsive (no heartbeat for 10 s); hung (main thread blocked for 60 s, 180 s while a map loads: it will not recover: instances_close {pids} or game_terminate {instance}, then relaunch); crashed (listed for an hour, crash {dump, exit_code}: relaunch with instances_launch). A call to a game that dies answers client_crashed / server_crashed at once, one to a frozen process instance_hung. loading: a map load is in progress, whatever started it; loading_stuck: true marks a loading screen with nothing behind it, and map_load clears it (disconnect does not). During a coordinator hand-over, calls with instance answer coordinator_changing (retry). Through the bridge entries also carry owner (a filter), test_client, desktop, launched_by_this_session; include_crashed: false hides crashed ones.
Details: guide, Tool details, instances_list.
Inputs: owner, include_crashed. Returns: next, note, warning, warnings, +7 more
lua_checkCheck Lua without running itARead-only
lua_check(realm?, code?, path?, globals?, limit?). Compiles Lua with the game's own parser (GLua: !=, &&, continue, /* */) and runs nothing. code, or path: a file or a whole folder (every .lua under it, e.g. an addon). Result: {ok, realm, checked, errors: [{file, line, message}] (one per file: the parser stops at the first), unknown_globals (read but neither defined in the checked files nor present in the realm: typos, missing includes, wrong realm: pick the realm the code runs in), globals_written (a forgotten local)}. ENT, SWEP, GM, EFFECT, TOOL are never reported; expect is known in test files. Errors: realm_unavailable, not_found.
Inputs: code, path, limit, realm, +2 more. Returns: ok, next, note, path, +13 more
lua_execExecute LuaADestructive
lua_exec(code, realm?, timeout_s?, budget?, chunkname?, depth?, fields?, hook_guard?, limit?, ...). Runs Lua code in a realm under xpcall + debug.traceback at full speed (no time limit unless budget, which makes LuaJIT interpret: never time code under it). Result: values, output (print/Msg), generation (changes on every map load); non-JSON types are {__type: Vector|Entity|...}. Errors: lua_syntax_error, lua_error (with traceback), budget_exceeded, main_thread_timeout, result_too_large, realm_unavailable, client_locked.
Pitfalls: include() only resolves paths under lua/ (else include_failed and a warning): use lua_exec_file for other files, and for code already in a file lua_exec_file or lua_job {path}, not its content pasted here. RunConsoleCommand silently refuses protected convars (blocked_console_commands: use convar_set). Hooks added with hook.Add are wrapped by the hook guard (hook_guard; mcpagent.unwrap(fn) gives yours back) and listed by hook_list with added_by "lua_exec": only lua_exec {code} and lua_job wrap, lua_exec_file and lua_reload register hooks exactly as the game would.
Details: guide, Tool details, lua_exec.
Inputs: code (required), depth, limit, realm, +7 more. Returns: n, file, next, note, +24 more
lua_exec_fileExecute a Lua fileADestructive
lua_exec_file(path, realm?, timeout_s?, assign_to?, budget?, chunkname?, depth?, fields?, hook_guard?, ...). Like lua_exec but runs a file from the game's disk (relative: the mounted Lua folder first, see lua_mount): saves the file's tokens on every call; the chunk is named after the real path. Result as lua_exec plus file, from_mount (true: the lua_mount copy), other_matches (other files it fits: they did NOT run), compile_ms. A data file outside lua/ (file.Read cannot reach it): absolute path + assign_to, e.g. {"path": "D:/dev/my-addon-wt/tests/fixtures/walls.lua", "assign_to": "WALLS"}. include() of a file outside lua/ loads nothing: use this tool. Its hooks are registered unwrapped, as the game would (hook_list: added_by "lua_exec_file"), unless hook_guard is above 0. With fields only the verdict comes back.
Details: guide, Tool details, lua_exec_file.
Inputs: path (required), depth, limit, realm, +8 more. Returns: n, file, next, note, +24 more
lua_file_deleteDelete a temporary Lua fileADestructive
lua_file_delete(name). Deletes one file of the game's lua/mcpagent_tmp/ folder (code it defined keeps running). Result: {deleted}. Error not_found.
Inputs: name (required), instance. Returns: next, note, deleted, warning, +5 more
lua_file_listList temporary Lua filesARead-only
lua_file_list(). Lists every file under the game's lua/mcpagent_tmp/ folder, subfolders included. Result: {dir (absolute), files: [paths relative to dir, sorted]}.
Inputs: instance. Returns: dir, next, note, files, +6 more
lua_file_readRead a temporary Lua fileARead-only
lua_file_read(name). Reads a file of the game's lua/mcpagent_tmp/ folder. Result: {path, content}. Error not_found.
Inputs: name (required), instance. Returns: next, note, path, content, +6 more
lua_file_writeWrite a temporary Lua fileADestructiveIdempotent
lua_file_write(name, content). Writes (or overwrites) a file in lua/mcpagent_tmp/, creating subfolders (when you do not share the game's disk; if you do, write there directly). Run it with lua_exec_file {path: name}. Result: {path, bytes, exec_path}.
Inputs: name (required), content (required), instance. Returns: next, note, path, bytes, +7 more
lua_function_sourceIs this function the code on disk?ADestructive
lua_function_source(expr, realm?). Tells where a function was defined and whether the game runs the current code of that file (its bytecode is compared with the file compiled again from disk, in the same realm; mounted folder first). Use it before trusting a test result after an edit. Result: source, linedefined, file/disk (the copy this realm ran), from_mount, provenance, matches_disk: true (same code) | false (edited since it loaded, or another copy) | null (no file: lua_exec/RunString code, or inside a .gma), line_on_disk, note.
Inputs: expr (required), realm, instance. Returns: disk, file, next, note, +17 more
lua_inspectInspect a Lua valueADestructive
lua_inspect(expr, realm?, depth?, limit?). Evaluates an expression in a realm (it runs: keep it side-effect free; 2 s limit) and describes the value: type, value (to depth; 0 = summary only), for a table count and keys up to limit, metatable, for a function source, linedefined, from_mount, disk, provenance (see lua_function_source). To discover an API or a structure; use lua_exec to compute.
Inputs: expr (required), depth, limit, realm, +1 more. Returns: disk, keys, next, note, +19 more
lua_jobRun a long Lua jobADestructive
lua_job(realm?, code?, path?, timeout_s?, args?, async?, chunkname?, depth?, ...). Runs a Lua script as a coroutine resumed once per frame, for long work (scans, batches of traces, multi-second tests): never loop inside lua_exec. The script must cooperate through the job object (a global): job:step() in loops, job:progress(done, total, msg), job:yield() / job:frames(n) / job:sleep(s) / job:wait(fn), job:report(value), job:elapsed(), job:dt() (real seconds since the last resume: not FrameTime()), job:call(realm, code) (runs code in ANOTHER realm right now and returns its values), job.args; return value ends it. Realm server by default; code or path. timeout_s (default 300) cancels a job still running. Errors: lua_syntax_error, lua_error, realm_reset (map change), cancelled, timeout. With timeout_s >= 15 it runs as a background task and the result is delivered ONCE (a later lua_job_status answers not_found with details.delivered_at); async: true returns the job id at once: follow with lua_job_status (wait_s >= 15 comes back by itself), stop with lua_job_cancel. include() only resolves paths under lua/ (use lua_exec_file for other files).
Details: guide, Tool details, lua_job.
Inputs: args, code, path, async, +12 more. Returns: n, next, note, realm, +25 more
lua_job_cancelCancel a Lua jobADestructive
lua_job_cancel(id). Asks a running job (lua_job, e.g. async: true) to stop at its next frame. Result: {job_id, cancelled (false if the id is unknown), note}; its final state (cancelled) stays readable once with lua_job_status.
Inputs: id (required), instance. Returns: next, note, job_id, warning, +6 more
lua_job_statusState of a Lua jobA
lua_job_status(fields?, id?, since?, wait_s?). State of a job started by lua_job (frames, elapsed_s, progress) plus only the reports added since your previous call: reports, reports_from (index of the first), reports_total, reports_already_delivered; since: N asks from index N (0 = all). Finished: its result like lua_job's, and the job is forgotten. wait_s waits up to that long for the end; wait_s >= 15 runs in the background (when the client supports tasks) and comes back by itself: do not poll. A wait that ends with the job running says stopped "wait_elapsed". A result is delivered once: afterwards the id answers not_found with details.delivered_at; an id of an old Lua state answers realm_reset. Without id: every job running or not yet collected.
Details: guide, Tool details, lua_job_status.
Inputs: id, since, fields, wait_s, +1 more. Returns: n, jobs, next, note, +29 more
lua_mountLoad Lua from another folder firstAIdempotent
lua_mount(path?, allow_shadow?, empty_cache?). Plugs a folder (e.g. the git worktree of an addon: the folder that contains lua/) into THIS game process only: every Lua lookup of this game then looks there first (autorun, include(), AddCSLuaFile, file.Read/Find "LUA", lua_exec_file, lua_job {path}, lua_check, lua_reload). A file in the folder hides the installed addon's file of the same Lua path. Only Lua (not materials, sounds, data/): a data file outside lua/ loads with lua_exec_file {path: absolute, assign_to: "NAME"}. IT TAKES EFFECT AT THE NEXT MAP LOAD: call map_load right after. No autorefresh: status.lua_mount.stale_files lists the changed files; lua_reload {mounted_changed: true} runs them again. path: the addon's root or its lua/ folder; null removes it; omitted reads the state. Check the result: base_lua_mounted false = remove the folder at once; engine_serves_folder false = the engine finds none of its files (a path it cannot read): the game runs the installed code. Windows game clients only (unsupported on srcds).
Details: guide, section "Mounted Lua folder" and Tool details, lua_mount.
Inputs: path, instance, empty_cache, allow_shadow. Returns: next, note, removed, warning, +17 more
lua_reloadReload a Lua file from diskADestructive
lua_reload(path?, timeout_s?, budget?, chunkname?, depth?, fields?, limit?, max_string?, ...). Runs an edited addon or gamemode file again from disk, in every realm it belongs to (mounted folder, lua/, gamemodes/, addons in the engine's order), to test an edit without reloading the map. Result per realm: a lua_exec result or {error}, with file, from_mount, other_matches (they did NOT run, the first match wins), compile_ms, note?. Pitfalls (the note says them too): MyAddon.Config = {...} is reset on every reload; a local Class = {} with methods makes a new table, so objects created before keep the old table and old methods; clients get new or changed files only at the next map load or reconnect, even with AddCSLuaFile; a NEW shared file needs realms set, server first then client; nothing the old copy built is undone. The hook guard never wraps a reload (hook_list: added_by "lua_reload"). Several agents on one game: call once per file with path. mounted_changed: true instead of path re-runs every changed file of the lua_mount folder (errors no_mount, reload_failed).
Details: guide, Tool details, lua_reload.
Inputs: path, depth, limit, budget, +7 more. Returns: ok, file, mode, next, +16 more
map_listList mapsARead-only
map_list(filter?, limit?). Installed maps: every maps/*.bsp on the game's GAME path (garrysmod, addons, workshop, mounted games), names without .bsp, sorted, filtered by a case-insensitive substring. The same on every instance of this game folder (no instance needed). Result: {maps, count (all matches), truncated, filter}.
Inputs: limit, filter, instance. Returns: maps, next, note, count, +8 more
map_loadLoad a mapADestructive
map_load(map, timeout_s?, gamemode?, maxplayers?, then?). Loads a map and WAITS until it is playable (client mode: console map, singleplayer when maxplayers is 1; srcds: changelevel): NEW server and client realms ready, loading screen gone. Every Lua state of the previous map is destroyed and the addons' files load again. InitPostEntity and Initialize have ALREADY run when it returns: a hook added afterwards with lua_exec never fires; to test code that reacts to them, put it in a file loaded at map load (an addon autorun, or a lua_mount folder). then {tool, args} runs one follow-up (tests_run, lua_job, lua_exec, lua_exec_file or lua_reload) on the new map in the same call, saving a turn. Result: {map, gamemode, maxplayers, duration_s, server_generation, client_generation, waited_s, warning?, then?, new_errors?}; with a lua_mount folder it empties the Lua cache first and warns if its files changed during the load. Errors: not_found, busy, timeout, cancelled, launch_in_progress, client_crashed. Run as a background task: wait for its result before any realm tool (an earlier call reaches the OLD map: compare generation). The bridge makes it wait while a game starts (FP7137): change no map by hand meanwhile.
Details: guide, Tool details, map_load.
Inputs: map (required), then, gamemode, instance, +2 more. Returns: map, next, note, then, +18 more
perf_hook_costCost of a hook's functionsARead-only
perf_hook_cost(event, realm?, duration_s?). Measures over duration_s the time spent in each function of a hook event (every hook.Add function registered when it starts, and GAMEMODE:), each wrapped with a timer and put back afterwards. Waits the whole duration. Result: {event, duration_s, functions: [{id, calls, total_ms, avg_ms, max_ms, src}] most expensive first, restored}. The game runs at its real frame rate (a 20 fps test client makes fewer calls). event is required.
Inputs: event (required), realm, instance, duration_s. Returns: next, note, event, warning, +8 more
perf_snapshotPerformance snapshotARead-only
perf_snapshot(). Quick performance numbers of this game process. Result: {frame: {fps, frametime_avg_ms, frametime_max_ms} over the last 256 frames, last_tick_age_s (large = frozen), realms: {menu|client|server: {lua_memory_kb, entity_count, frametime}}}. Mind the frame cap (status fps_max: 20 on a light test client). Per-hook costs: perf_hook_cost.
Inputs: instance. Returns: next, note, frame, realms, +7 more
player_setMove/configure a playerAIdempotent
player_set(ang?, god?, id?, noclip?, pos?). Changes a player in the server realm: pos teleports it, ang sets its eye angles, noclip switches noclip/walk, god toggles god mode. Only the given fields change. Default player: the first one. Result: {id, nick, pos, ang, eye_ang, noclip, god} read right after; the client sees it on a later frame. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: id, ang, god, pos, +2 more. Returns: id, ang, bot, god, +19 more
players_listList playersARead-only
players_list(realm?). Every player (bots included). Result: {players: [{id (entity index, for player_set), class, model, nick, pos, ang, userid, steamid, bot, alive, health, eye_pos, eye_ang, noclip, god (server realm only)}], count, maxplayers}. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: realm, instance. Returns: next, note, count, players, +7 more
reports_channelsList report channelsBRead-only
reports_channels(). Report channels of this instance: {channels: [{channel, buffered (values kept), total (ever published), next_cursor}]}.
Inputs: instance. Returns: next, note, warning, channels, +5 more
reports_clearClear report channelsADestructiveIdempotent
reports_clear(channel?). Deletes a report channel and its values (all channels if channel is absent). Result: {cleared}.
Inputs: channel, instance. Returns: next, note, cleared, warning, +5 more
reports_readRead a report channelARead-only
reports_read(channel, cursor?, limit?, wait_s?). Reads the values that game code published with mcpagent.report(channel, value) (a Lua function gmod-mcp adds in every realm; job:report(value) of a lua_job publishes on "job:"), whole, as JSON. Read incrementally: cursor 0 = the oldest kept value, then pass next_cursor; wait_s > 0 waits until a new value arrives. Each channel keeps its last 10000 values; channels survive map changes until reports_clear. Result: {channel, items: [{seq, time, realm, value}], next_cursor, lost, timed_out}.
Inputs: channel (required), limit, cursor, wait_s, +1 more. Returns: lost, next, note, items, +9 more
screenshotTake a screenshotARead-only
screenshot(crop?, format?, full?, h?, quality?, scale?, scale_filter?, source?, ...). Client only (unsupported on srcds). Captures what the game shows and returns an MCP image plus {source, format, w, h, method, bytes}. Default: shrunk to at most 960 px wide, JPEG quality 80 (result downscaled_from); full: true gives the full window; wait_frames waits before capturing (a lua_exec's effect, a spawn). An image over 8 MB once encoded is never sent: retaken at lower quality (size_capped: true) or result_too_large. crop {x, y, w, h} captures only that rectangle; scale 1-16 enlarges it as a png: to read a small HUD element, crop it and scale 8 (w/h render the view again without the HUD). source: auto (default), render (what the local player sees; needs a map and the client realm; debug_draw is visible) or engine_jpeg (the engine's own jpeg command: the only way to see the main menu, a VGUI2 dialog or a loading screen; it works while other windows cover the game; the module reads the file the engine wrote and deletes it; format, w, h, quality, crop and scale are not applied and are listed in ignored). Errors: realm_unavailable (render without a map), unsupported (srcds), client_locked, capture_timeout (game minimized or frozen), capture_failed (the file could not be taken; it stays and is named). Example: {"source": "engine_jpeg"} at the main menu.
Inputs: h, w, crop, full, +7 more. Returns: h, w, crop, file, +26 more
screenshot_fromScreenshot from a viewpointARead-only
screenshot_from(pos, ang, format?, fov?, full?, h?, quality?, w?, wait_frames?). Captures the scene from an arbitrary camera (pos, ang, fov) as an MCP image; the player does not move. Client only (unsupported on srcds), with a loaded map. Without w/h a temporary CalcView hook moves the view for 3 frames (shrunk to 960 px like screenshot; full: true for the full size); with w/h it renders off-screen at that size. The local player's body is drawn; debug_draw primitives are visible.
Inputs: ang (required), pos (required), h, w, +6 more. Returns: h, w, crop, file, +26 more
sound_emitEmit a soundA
sound_emit(name, realm?, dsp?, ent?, level?, pitch?, pos?, volume?). Plays a sound once, from a position (EmitSound) or from an entity (Entity:EmitSound, it follows the entity). Pass pos or ent. name is a soundscript name or a path under sound/ (error not_found if neither exists). Server realm by default (networked); realm client plays it locally. Returns at once. To see what the engine and the hooks received, run sound_trace meanwhile. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: name (required), dsp, ent, pos, +5 more. Returns: dsp, ent, pos, next, +11 more
sound_traceTrace emitted soundsARead-only
sound_trace(realm?, duration_s?, max_calls?). Records the sounds the game emits through the EntityEmitSound hook during duration_s (or until max_calls), then removes its recorder (behaviour unchanged). Waits the whole duration (can run as an MCP task). Result: {event, calls: [{t, sound: {name, level, pitch, volume, dsp, channel, pos, entity}}], recorded, total_calls, capped}. Not seen: surface.PlaySound (UI sounds), and sounds a hook running before the recorder suppressed. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: realm, instance, max_calls, duration_s. Returns: next, note, calls, event, +11 more
statusInstance statusARead-only
status(timeout_s?, fields?). Instance status: call it first (it works even if the game is frozen). Summary fields at the top (instance, mode, version, map, gamemode, maxplayers, fps, fps_max (the frame cap: 20 on a light test client), loading, uptime, main_thread_stalled, tmp_dir) and one object per realm (menu, server, client). With a mounted Lua folder lua_mount {stale_files...}; on a client started with early_lua early_lua {mounted, error?}. fields keeps only some top-level keys.
Inputs: fields, instance, timeout_s. Returns: map, pid, menu, mode, +37 more
tests_runRun Lua testsADestructive
tests_run(path, realm?, timeout_s?, budget?, case?, detail?, exclude?, fields?, frames_between_files?, ...). Runs test files in GLuaTest format in one realm. A file returns {groupName, beforeAll, beforeEach, afterEach, afterAll, cases = {{name, func, skip?, when?, timeout?, timing?}}}; inside, expect(x).to.equal(y) etc. (format and assertions: resource mcpagent://tests-format). state is ONE table per file, shared by all steps and NOT reset between cases. path: a file, a glob (*.lua, **/*.lua) or an array, absolute or relative to lua/mcpagent_tmp/ (then the mounted folder, the game folder); exclude: globs to skip; case: only cases whose name contains it (there is no filter). Result, compact by default: only the files with a fail, error or skip, each with its non-green cases, plus files_ok, totals, ok, new_errors; detail: "all" lists everything, fields: ["totals", "ok"] just the verdict. It is one call on the main thread (the game is frozen meanwhile; multi-frame tests: lua_job): Entity:Remove() takes effect next frame (frames_between_files). realm: "both" runs server then client (sh_ files). budget (default 10 s per step) makes LuaJIT interpret: give a timing case timing = true, or pass budget 0.
Details: guide, Tool details, tests_run.
Inputs: path (required), case, realm, budget, +8 more. Returns: ok, next, note, files, +12 more
traceTrace a lineARead-only
trace(start, end, realm?, filter?, mask?). One util.TraceLine from start to end. Result: hit, hit_world, hit_sky, pos (hit position, or end), normal, fraction (0..1), distance, mat_name, surfaceprop, texture, entity (summary, {id: 0, class: worldspawn} for the world, or null), start_solid, all_solid, hitgroup. For everything a segment crosses (walls, doors, thickness), use trace_through. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: end (required), start (required), mask, realm, +2 more. Returns: hit, pos, next, note, +23 more
trace_throughSurfaces crossed by a segmentARead-only
trace_through(start, end, realm?, filter?, mask?, max_surfaces?). Lists every solid the segment start->end goes through, in order, by repeated traces. Result: {surfaces: [{entry, entry_surface, distance_from_start, exit, exit_surface, thickness}], count, total_thickness, distance, truncated}. A start point inside a solid gives a first entry with entry_surface null. Made for sound propagation through walls and doors. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.
Inputs: end (required), start (required), mask, realm, +3 more. Returns: next, note, count, warning, +9 more
ui_clickClick in the game UIADestructive
ui_click(x, y, allow_user_game?, button?, coords?, double?, screenshot_after?, screenshot_size?, wait_frames?, wheel?). Clicks (or scrolls the wheel) at a point of the game window: for what has no console command (VGUI2 dialogs such as "Disconnected by the server" > Close, Derma panels, the menu's HTML). Coordinates come from a screenshot (coords "screenshot", the default: pixels of that image; if your image is not the window's size, e.g. a default screenshot shrunk to 960 px or one with w/h, pass screenshot_size [w, h]) or coords "window" (client-area pixels). Result: {sent, at, coords, frames_waited, window, screen, cursor_via, screenshot?}; screenshot_after adds the image. Windows game client only (unsupported on srcds). Errors: unsupported, not_a_test_client (not started by instances_launch: allow_user_game: true), client_locked, loading (events_wait map_loaded), window_unavailable (minimized), cursor_hidden (no menu, dialog or popup is open: open one, e.g. console_exec gameui_activate), out_of_bounds (ui_click: point outside the image or window). Input is posted to the game's window (PostMessage): the user's cursor does not move and no window takes the focus. Example: {"x": 640, "y": 400, "screenshot_after": true}.
Inputs: x (required), y (required), wheel, button, +7 more. Returns: at, next, note, sent, +17 more
ui_keyPress a key or type text in the game UIADestructive
ui_key(allow_lossy?, allow_user_game?, key?, screenshot_after?, text?, wait_frames?). Presses a key and/or types text into the focused part of the game UI (a dialog's text entry, a Derma TextEntry, an HTML input). key: a named key (enter, escape, tab, backspace, space, arrows, home, end, pageup, pagedown, insert, delete, f1..f12) or a letter / digit (typed as a character, like text). text: typed character by character (up to 256, no control characters: use key); with both, the text goes first, then the key. Click the field first with ui_click. The engine narrows characters through the machine's ANSI code page (western accents arrive, others become ?): such a text is refused with text_not_representable unless allow_lossy: true; to set it exactly use lua_exec in the realm that owns the panel: entry:SetText("...") on a DTextEntry. Result: {sent, key?, text_units?, frames_waited, window, screen, screenshot?}. Windows game client only (unsupported on srcds). Errors: unsupported, not_a_test_client (not started by instances_launch: allow_user_game: true), client_locked, loading (events_wait map_loaded), window_unavailable (minimized), cursor_hidden (no menu, dialog or popup is open: open one, e.g. console_exec gameui_activate), out_of_bounds (ui_click: point outside the image or window). Input is posted to the game's window (PostMessage): the user's cursor does not move and no window takes the focus. Example: {"text": "my name", "key": "enter"}.
Inputs: key, text, instance, allow_lossy, +3 more. Returns: key, next, note, sent, +16 more
wait_forWait for a Lua conditionADestructive
wait_for(condition, realm?, timeout_s?, interval_s?). Waits until a Lua condition is true. condition is an expression ("IsValid(Entity(57))") or a block with return ("local d = Entity(57) return IsValid(d) and d:GetInternalVariable('m_eDoorState') == 2"), compiled once and evaluated in realm every frame (or every interval_s; 1 s at most per evaluation). Result: {satisfied: true, elapsed_s, polls, value}. Errors: timeout (details: polls, last_value), realm_lost (a map change), realm_unavailable, lua_syntax_error, lua_error. Can run as an MCP task.
Inputs: condition (required), realm, instance, timeout_s, +1 more. Returns: next, note, polls, value, +8 more
wait_framesWait N framesARead-only
wait_frames(n, timeout_s?). Waits until the game's main loop has run n more frames, e.g. to let a console command, a spawn or a SetPos take effect. Result: {frames, elapsed_s}. Error timeout if fewer frames render in timeout_s (frozen, or minimized with a low fps_max_nofocus). A light test client runs at 20 fps: 20 frames = 1 s.
Inputs: n (required), instance, timeout_s. Returns: next, note, frames, warning, +6 more
wiki_pageRead a GMod wiki pageARead-only
wiki_page(name, format?, refresh?). Reads one wiki page by its exact name (as wiki_search returns it): format text = the raw wiki markup, json = the wiki's JSON form. Cached 7 days (refresh: true re-downloads). Result: {name, format, url, cache, content | page}. A name that is not a page is looked up: CurTime reads Global.CurTime (resolved_from says so) when only one page can mean it, otherwise not_found lists the close pages in details.candidates.
Inputs: name (required), format, refresh, instance. Returns: url, name, next, note, +11 more
wiki_searchSearch the GMod wikiARead-only
wiki_search(query, limit?, refresh?). Finds pages of the official wiki (https://wiki.facepunch.com/gmod/) by NAME, not by content: exact, then prefix, substring and approximate matches, best first (Entity:EmitSound, util.TraceLine, GM:PlayerSpawn, Global.EmitSound). The page list is downloaded once and cached 24 h. Result: {query, results: [{page, score, url}], total_matches}. Then read one with wiki_page.
Inputs: query (required), limit, refresh, instance. Returns: next, note, cache, query, +8 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 65 tools
Given 65 tools, the boundaries are remarkably well-drawn: lua_exec/lua_exec_file/lua_reload/lua_job, console_exec/console_read/console_wait, and ent_* each have a distinct role spelled out in the descriptions. The few soft spots are the stop/leave trio (disconnect vs game_quit vs game_terminate), the overview trio (status vs perf_snapshot vs instances_list), and the trace vs trace_through pair, all of which still read distinctly once the descriptions are consulted.
A consistent domain-prefix + verb_noun scheme dominates (map_load, ent_spawn, console_read, reports_clear, instances_launch, hook_trace), making the whole set scannable. Minor deviations exist: bare nouns like status, trace, screenshot, disconnect, and the singular/plural split between ents_find and ent_info/ent_spawn/ent_remove.
65 tools is far past the practical ceiling for an agent to navigate comfortably, and some obvious clusters (lua_file_read/write/list/delete, the four console_* tools, the three reports_* tools) could reasonably be consolidated. The breadth of the domain (Lua execution, entities, console, maps, instances, screenshots, sounds, hooks, tests, wiki) justifies a large surface, but not this large.
The surface covers the whole debugging/testing lifecycle: instance launch/close/select, map load/list, Lua exec/exec_file/reload/check/inspect/job, entity CRUD plus I/O, players/bots, console and convars, traces, screenshots, debug draw, sounds, hooks, errors, reports, and even tests_run and wiki lookup. There are almost no dead ends for an agent working inside a Garry's Mod session.
Maintenance
Related MCP Connectors
Every app you build or share, and the tools to build more, over one MCP server.
MCP Apps that show UI in your chat. Every tool in one server.
One MCP server exposing every tool in the Gumball portfolio.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceThe most complete open-source MCP server for Discord — 80+ tools, dual-mode: integrated (plugin) or standalone58 npm16MIT
- AlicenseAqualityDmaintenanceMCP server for Garry's Mod enabling RCON command execution, Lua scripting, window control, screenshots, and SFTP file management.1618 npm2MIT
- FlicenseNot gradedqualityFmaintenanceMCP server suite for the s&box game engine, enabling AI assistants to manipulate scenes, create objects, compile code, manage assets, and more via editor, API, and docs servers.3-
- AlicenseNot gradedqualityBmaintenanceOpen-source, engine-agnostic MCP server shared by Unity-MCP, Godot-MCP, and Unreal-MCP. Additionally you can use AI Game Dev app (https://ai-game.dev) to generate images, video, audio, 3D, rig, animation and much more.23Apache 2.0