Use when a task involves Garry's Mod (GMod, gmod, GLua, a GMod dedicated server / srcds) and the `gmod` tools answer `game_not_running`, are missing, or the game is not running; when the user wants to install, update, start or connect gmod-mcp; or before telling the user that the game or its MCP server is unavailable. The MCP server lives inside the game, so it only answers while Garry's Mod runs with -mcp: starting the game is your job, not a dead end.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Gmod Mcp?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/extremlapin-gmod-mcp)
---
name: gmod-mcp
description: Use when a task involves Garry's Mod (GMod, gmod, GLua, a GMod dedicated server / srcds) and the `gmod` tools answer `game_not_running`, are missing, or the game is not running; when the user wants to install, update, start or connect gmod-mcp; or before telling the user that the game or its MCP server is unavailable. The MCP server lives inside the game, so it only answers while Garry's Mod runs with -mcp: starting the game is your job, not a dead end.
---
# gmod-mcp: install, start and connect
gmod-mcp is an MCP server **inside** Garry's Mod (a native module, https://github.com/ExtReMLapin/gmod-mcp). It only
answers while the game runs with the `-mcp` launch option. This plugin starts a small bridge as the `gmod` MCP server:
it stays connected while the game is closed (its tools then answer `game_not_running`) and relays to the game as soon as
it answers, so the tools come back by themselves, with no reconnection. When the tools say `game_not_running`, start
the game yourself (section 2) instead of reporting a dead end.
Once the server is connected, its own instructions (sent by the server) take over: follow them for everything else.
## Rules
- **Local only.** The server listens on `127.0.0.1` (base port 27080, then 27081... for more games). Never connect the
game to a remote server, never expose the port.
- **Ask before installing or updating**: it adds two files to the user's game folder.
- **Do not restart a game the user closed** in this conversation, or one they said to leave closed: ask first.
- Never kill Steam, never change the game's beta branch, never edit the user's addons, `cfg` or saves.
- Never print the token in the conversation. Read it straight from the file into the command that needs it.
## 1. Find out where things stand
1. **One `gmod` server only.** The plugin provides it. An older install may also have a manual entry: if
`claude mcp get gmod` shows an `http://127.0.0.1:27080/mcp` server, tell the user it duplicates the plugin's (the
plugin does not replace it: both stay and every tool is listed twice) and remove it with their agreement
(`claude mcp remove gmod`, adding `-s user` if it lives in the user scope; a local-scope entry only from the folder
it was added in).
2. **Is a game listening?** Look at the answer, not only at whether there is one. gmod-mcp answers a request without the
token with **401** and the header `X-Gmod-Mcp`; another program on the port answers something else (404, 403, a
page...):
```bash
curl -s -i -X POST http://127.0.0.1:27080/mcp | head -5 # 401 + X-Gmod-Mcp = up, connection refused = nothing listening
```
- 401 with `X-Gmod-Mcp` (a module older than the header sends 401 with a JSON body `{"error":{"code":"unauthorized"...`):
the game is up.
- Any other status, or a 401 without that header or body: possibly **another program on the port**, not the game
(`port_conflict` in the bridge's answers means the same). See "When it still does not answer".
- Nothing listening (`000`, connection refused): no game.
On Windows PowerShell, call `curl.exe`, not `curl`.
3. **Is the module installed?** In the game folder (see below):
`garrysmod/lua/bin/gmsv_mcpagent_win64.dll` (Linux: `gmsv_mcpagent_linux64.dll`) and
`garrysmod/lua/autorun/server/mcpagent_boot.lua`.
**Finding the game folder.** Garry's Mod is Steam app 4000, in one of Steam's libraries:
- Windows: Steam's folder is `SteamPath` in `HKCU\Software\Valve\Steam`
(`reg query "HKCU\Software\Valve\Steam" /v SteamPath`), usually `C:\Program Files (x86)\Steam`.
- Linux: `~/.local/share/Steam` or `~/.steam/steam`.
- Every library is listed in `<Steam>/steamapps/libraryfolders.vdf` (`"path"` entries). The game is the library whose
`steamapps/appmanifest_4000.acf` exists, in `<library>/steamapps/common/GarrysMod`.
## 2. Start the game (server down, module installed)
Steam must be running and logged in. If it is not, start it (`steam.exe` / `steam`) and wait until it is ready; never
kill it.
**Windows** (64-bit game). The 64-bit executable is `<game folder>\bin\win64\gmod.exe` on current x86-64 installs, or
`<game folder>\gmod_win64.exe` on older ones: use whichever exists. Start it directly with the game folder as working
directory; the two variables are required, otherwise the game stops with "No appID found":
```powershell
$env:SteamAppId = "4000"; $env:SteamGameId = "4000"
$exe = "<game folder>\gmod_win64.exe"
if (-not (Test-Path $exe)) { $exe = "<game folder>\bin\win64\gmod.exe" }
Start-Process -FilePath $exe -WorkingDirectory "<game folder>" `
-ArgumentList "-mcp -windowed -w 1280 -h 720 -novid -condebug +engine_no_focus_sleep 0 +snd_mute_losefocus 0"
```
The `gmod.exe` at the root of the game folder is the 32-bit game on the x86-64 branch: do not start it. To tell the
two apart, read the PE header: the 2 bytes at offset `e_lfanew + 4` (the 4-byte value at offset 0x3C) are `64 86`
for 64-bit (machine 0x8664) and `4C 01` for 32-bit (0x014C). If neither a 64-bit `gmod_win64.exe` nor a 64-bit
`bin\win64\gmod.exe` exists, the game is on 32-bit binaries: tell the user (the module is 64-bit only) and stop.
**Linux**, or as a fallback on Windows: `steam -applaunch 4000 -mcp -windowed -novid +engine_no_focus_sleep 0
+snd_mute_losefocus 0` (on Windows, `"<Steam>\steam.exe" -applaunch 4000 ...`). Steam adds the user's own launch options.
- `-mcp` is the one that matters: without it the module does nothing.
- `+engine_no_focus_sleep 0 +snd_mute_losefocus 0` keep the game at full speed while it is not in focus.
- **Very first start after an install**: add `+map gm_construct`. The module installs its main-menu loader during that
first map load; later starts need no map (the server is up at the main menu).
Then wait for the server: check the URL from section 1 every 2 seconds (a 401 with `X-Gmod-Mcp` means up; another answer is not that), for up to 2 minutes (the first start and a map
load take longer). Run the wait in the background or in one bounded loop, not as many separate calls.
**When it answers**: call the `gmod` tools again. The bridge notices the game within 2 seconds and Claude Code
fetches the live tool list by itself; the guide is the resource `mcpagent://guide`.
**Version warning**: when a tool result starts with `WARNING: version mismatch` (or the server instructions say so), the
module running in the game and this plugin differ: Claude Code updated the plugin, not the module in the game. Tell the
user at once and offer section 3 (update the module; the game must be quit first). Until then, tools may lack features
their descriptions mention.
**Several clients side by side** (for example to split a long test suite): use the `instances_launch` tool (Windows),
which works even while no game runs. It starts 1 to 8 clients with the right options (`-multirun`, a small window on a private desktop, a
frame cap, no `+map`), waits until each answers, loads the map with `map_load`, and returns their ids and pids. Then
pass `instance` to every tool, or `instance_select` to make one the session's default (with several games running,
calls without `instance` are refused with `ambiguous_instance`). Close them with `instances_close`; they also close
when the session ends. Its description lists the measured cost per client and the limits (memory is what runs out
first). It also takes `fps_max` / `fps_max_nofocus` (0 = no cap, or 10 to 1000: timing-sensitive tests and perf
measurements need more than the preset's 20/30 fps), `commands` (console commands run on each client once it answers,
before the map loads, e.g. `["fps_max 300", "snd_mute_losefocus 0"]`) and `launch_args` (extra engine options, one token
per element: `["-noborder", "+cl_showfps", "1"]`). Refused with `invalid_params` naming the option: `quit`/`exit`, anything
that connects, map changes (use `map`) and what gmod-mcp sets itself (`-multirun`, `-mcp*`, `-w`/`-h`, window mode,
`-dxlevel`, `-condebug`, `-game`). Archived convars these change are given back to the user's value before a clean quit
(module of the same release). Launch options are listed on the Valve Developer Community,
[Command line options](https://developer.valvesoftware.com/wiki/Command_line_options), and the Garry's Mod wiki
(`wiki_search`); console commands and convars with `api_search` and `concommand_list`.
- **Private desktop (default on Windows).** `instances_launch` starts the clients on a Windows desktop of its own, so the
user's own game does not freeze or glitch when a client starts. They have no window and no taskbar button: close them
with `instances_close` only; they never take the user's focus; they are silent (`-nosound`) unless you pass
`sound: true` (needed for sound tests: `SoundDuration` of ADPCM WAV files differs without sound). `ui_click`, `ui_key`
and `screenshot` work as usual. `desktop: "shared"` gives the old visible-window behaviour. The clients of a session
share their desktop and still disturb each other (see the next point). Before launching, the bridge refuses an
installed module older than the shipped one (`module_outdated`, with the update steps; `ignore_outdated_module: true`
overrides); `instances_list` shows `module_outdated` while no game runs.
<!-- FP7137: agent-facing text A1-A3, see docs/FP7137.md -->
- **Launches and map loads.** Starting a game makes every other running GMod 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
serialises `instances_launch` and `map_load` for every session using it: `map_load` waits while a game is being started
and for 15 s after the last start, `instances_launch` waits while any game loads a map, and `instances_launch {map}`
loads its maps after that delay, and at most 2 maps load at a time across every session (`instances_launch {map}` and `map_load` alike: a third waits). Every result carries `waited_s` (0 when nothing waited), `waited_reason` (null then), `duration_s` and `load_s` (the games' own time; per instance with `map`); a wait also reports progress. If the
wait would exceed `timeout_s`, it fails with `launch_in_progress` (map_load) or `map_load_in_progress` (launch) and
nothing was started: retry later or with a larger `timeout_s`. `instances_launch` also waits for a map load the bridge did
not start (console `map` / `changelevel`, Lua, a script talking to the game: every game reports `loading` in
`instances_list`; `waited_reason` starts with `map_load_outside_bridge`), and `map_load` lists such games as
`other_games_loading`. The bridge cannot hold back a game started by hand, or a console/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`,
timeouts): expected, wait and retry (`client_crashed` is the signal for a dead one). Order: launch all the clients you
need in ONE `instances_launch`, then work; do not interleave launches with map loads across sessions.
The game on the base port is the coordinator (`instances_list`: `role`, `coordinator_id`): closing it (`instances_close`, `game_quit`) moves
the role to another game within about 3 s; calls then answer the retryable `coordinator_changing` (the bridge already retries for 10 s).
Do not close a game you did not start, and close the coordinator last.
- **With sub-agents**: they all share one bridge, so one session. Never use `instance_select` (its default would apply
to every sub-agent's calls) and never `instances_close {all: true}` (it would close the others' clients). Tell each
sub-agent in its brief to launch with an `owner` label of its own, pass `instance` on every call, and close with
`instances_close {owner}`.
- **Testing a branch of an addon** (a git worktree): launch the client with `instances_launch {lua_mount: "<worktree>"}`
(or call `lua_mount {path}` then `map_load` on a running one). That game then loads the worktree's Lua before the
installed addon, at every map load; other games are not affected. Do not re-inject files with `lua_exec` after each
map load, and check with `lua_function_source` that the function under test comes from the worktree. Windows only.
- A client that never answers (gmod-mcp did not load in it): `instances_launch` returns its pid in `silent_pids`;
close it with `instances_close {pids}`.
- The clients share the game folder with the user's own game: addons, cfg, `data/` and cookies (`sv.db`/`cl.db`). A
test that writes cookies, data files or archived convars changes the user's game too: clean up after it. Archived
convars (FCVAR_ARCHIVE) are saved to `cfg/config.cfg` and seen by every instance: one agent's `pba_x 0` left behind
pollutes another's runs (`console_exec` warns when it sets one; `convar_set` refuses them unless `persist: true`).
An addon that caches into `data/` (or deletes its cache when its format changes) does it right after the map loads, before
`commands` can switch it off: its convars do not exist yet. Test clients share the user's real `data/`, cfg and cookies (nothing
isolates them): switch the addon's writes off with `instances_launch {early_lua: "..."}` (Lua run in the client and server
realms before any addon's file) and clean up after the test.
- A background test client may believe it has the focus (`system.HasFocus()` true): `fps_max_nofocus` is not
exercised there.
- Engine facts that cost agents runs: entity names (targetname) are server-side (`ents.FindByName` does nothing on the
client; `Entity:GetName`/`SetName` are server-only); `EyePos()`/`EyeAngles()` are only reliable inside rendering
hooks (use `LocalPlayer():EyePos()` in a `lua_job`).
- The launched clients carry `-dxlevel 95`, so they neither read nor write the user's video settings (resolution,
anti-aliasing). Without that option, a client started with `-w`/`-h` overwrites them: if you start a client yourself
(Linux, or by hand), add `-dxlevel 95` and tell the user.
- If the tool cannot find the game, pass `game_dir` (see "Finding the game folder" above).
- On Linux, start extra clients by hand with `-multirun` and load maps with `map_load` and the client's `instance`
(not `+map`: a game that loads a map while another window has the focus can grab the mouse).
- An unfocused game is capped at 20 fps by default (`fps_max_nofocus`); the launched clients set their own cap.
## 3. Install (or update) the module
The plugin ships the module of its own version. Ask the user first; say that it adds two files to the game folder, and
that on the first start with `-mcp` the module also appends a small loader block to `garrysmod/lua/menu/menu.lua` (the
original is saved as `menu.lua.mcpagent.bak`; the game console command `mcpagent_uninstall` removes it).
1. Quit the game first if it is running (an update cannot replace a loaded DLL): ask the user to quit it, or use the
`game_quit` tool.
2. Find the module shipped with the plugin. The plugin's `bin/` folder is on the PATH of the Bash tool:
```bash
# Windows: name the .exe (the bin/ folder also holds the Linux binary, which Git Bash would pick first and fail on)
src=$(gmod-mcp-bridge.exe --module-dir | tr -d '\r') # Linux: src=$(gmod-mcp-bridge --module-dir)
ls "$src/garrysmod/lua/bin" "$src/garrysmod/lua/autorun/server"
```
3. Copy these two files into the game folder at the same relative paths, creating `lua/bin` if needed, and nothing
else:
- `garrysmod/lua/bin/gmsv_mcpagent_win64.dll` (Linux: `gmsv_mcpagent_linux64.dll`)
- `garrysmod/lua/autorun/server/mcpagent_boot.lua`
4. Start the game as in section 2, **with `+map gm_construct`** this first time. The game console says
`main-menu loader installed in lua/menu/menu.lua`. The `gmod` tools come back by themselves.
5. Optionally, suggest Steam launch options (Garry's Mod → Properties → Launch options), so the server is also up, at
full speed, when the user starts the game themselves:
`-mcp -windowed +engine_no_focus_sleep 0 +snd_mute_losefocus 0`. `-mcp` starts the server; without
`+engine_no_focus_sleep 0` the game throttles itself while another window has the focus (the usual case while
the user is in the terminal), so every call that waits on frames gets slower; `+snd_mute_losefocus 0` keeps
sounds playing for sound tests. `-windowed` is a preference, so the terminal stays reachable. Do not edit Steam's
files to set them: tell the user.
If `gmod-mcp-bridge` is not found, the plugin is an old version without the bridge: ask the user to update it and
restart Claude Code. Updating by hand takes both commands, in this order, in a shell:
`claude plugin marketplace update gmod-mcp`, then `claude plugin update gmod-mcp@gmod-mcp` (the second one alone says
"already at the latest version" while Claude Code's copy of the marketplace is stale). Then restart Claude Code, or
`/reload-plugins`. Auto-update is off for third-party marketplaces, and no `claude plugin` subcommand turns it on: the
user does it in `/plugin`, Marketplaces, gmod-mcp, Enable auto-update.
**Other MCP clients** (not Claude Code): in the game console, `mcpagent_setup` prints an HTTP configuration with the
token. The bridge also works for them as a stdio server: the command `gmod-mcp-bridge` (from the plugin, or from the
release), with `--port <n>` or the `GMOD_MCP_PORT` variable for another base port.
## Dedicated server (srcds)
The same module works in a Garry's Mod dedicated server (Steam app **4020**, a separate install from the game). Use it
when the user works on a server-side addon or gamemode, or asks for a dedicated server. Only the server realm exists
there (no menu, no client, no screenshots).
**Install the server** (ask first: it is a download of several GB, and the user picks the folder). With SteamCMD
(https://developer.valvesoftware.com/wiki/SteamCMD), in a folder of its own:
```bash
steamcmd +force_install_dir "<server folder>" +login anonymous +app_update 4020 -beta x86-64 validate +quit
```
`-beta x86-64` matters: the module is 64-bit, and on Linux the default branch of the dedicated server only has the
32-bit `srcds_linux` (no `srcds_run_x64`). This is a separate install, not the user's game.
If the user already has a server, use theirs: it is the folder holding `srcds_win64.exe` (Linux: `srcds_run_x64`) and a
`garrysmod` folder. If that 64-bit binary is missing, the server is on the 32-bit branch: ask the user before switching
it to `-beta x86-64`.
**Install the module**: as in section 3, the same two files, into `<server folder>/garrysmod/...`.
A server has no main menu: it needs no `+map gm_construct` "first start", but it needs a map on every start.
**Start it** with the **64-bit** binary (`srcds.exe` and `srcds_run` are 32-bit: the module does not load there):
```powershell
Start-Process -FilePath "<server folder>\srcds_win64.exe" -WorkingDirectory "<server folder>" `
-ArgumentList "-console -mcp -condebug -port 27015 +maxplayers 2 +sv_lan 1 +map gm_construct"
```
Linux: `./srcds_run_x64 -console -mcp -condebug -port 27015 +maxplayers 2 +sv_lan 1 +map gm_construct`. Keep its standard
input open when starting it from a script (for example `sleep infinity | ./srcds_run_x64 ...`): with `-console`, an
end-of-file on standard input can stop it.
- `+sv_lan 1` keeps the server off the public server list. Never open or forward its ports. If Windows asks about the
firewall, the MCP port needs nothing (it is loopback); allowing private networks is enough to join from this machine.
- Wait for it as in section 2 (`curl` on 27080, or 27081 when a client game already holds 27080).
- The token is the same file as the game's (same user), and `mcpagent_setup` works in the server console.
**Reaching it from the agent.** A server alone takes port 27080, so the usual `gmod` server works. With the client
game also running, each has its own port and the one holding 27080 relays to the other: keep the single `gmod` entry,
call `instances_list`, then pass `instance` (`srcds-<pid>`) to any tool. Calls without `instance` are refused with
`ambiguous_instance` while several games run.
**A game crashed.** A call to an instance whose process died answers `client_crashed` (`server_crashed` for srcds) with
`details.dump` (the minidump file name under `crashes/` in the game folder, or null) and `details.exit_code`; `instances_list`
shows it as `state: "crashed"` for an hour. Relaunch a client with `instances_launch` and rerun what it was doing; the dump
is for a human, not for you. `instance_gone` means a normal exit (quit, `game_terminate`), `instance_unreachable` a game that
runs but does not answer. A call in flight to a client that dies is answered at once (not at its own timeout), and the answer
carries `details.memory` (free commit and RAM) with a warning when memory is low: out of memory is a likely cause.
**A game is hung, or the machine is out of memory.** `instances_list` gives every instance `stalled_s` (main thread blocked for
that many seconds) and `fps_low_s` (frame rate under 10 fps for that long: what you measured meanwhile is suspect). A game
whose main thread is blocked for 60 s (180 s during a map load), or that stopped sending heartbeats while its process runs,
is `state: "hung"`: close it (`instances_close {pids}` / `game_terminate`) and relaunch, do not wait for it. A call in flight
to a frozen process fails with `instance_hung` after 30 s of silence. `instances_launch` refuses with `low_memory` when the
free commit (virtual memory) or RAM cannot hold the clients (about 1.6 GB of commit and 1.2 GB of RAM each, plus 1 GB of
commit for the machine): close clients you do not use or start fewer; `ignore_low_memory: true` starts anyway. A harness
must treat `low_memory`, `instance_hung`, `client_crashed`, `instance_gone`, `instance_unreachable` and `game_not_running`
as infrastructure problems, not as failed tests.
**Joining it from the local game**: `connect <this machine's LAN address>:27015` (in `console_exec`, or the game
console). A GMod dedicated server ignores connections from `127.0.0.1`, so use the LAN address (`ipconfig` /
`ip addr`). The client realm stays available because the server runs on this machine.
**Stopping it**: the `game_quit` tool with its `instance`, or `quit` in its console. Leave a server the user started
themselves running unless they ask.
## Reporting frictions to the maintainers
The maintainers of gmod-mcp want every friction agents meet with it, without making work for the user. Follow the
guide's "Reporting frictions" section (resource `mcpagent://guide`). In short:
- Note frictions with gmod-mcp itself while you work (wrong or unclear description, error without a reason, missing
tool, workaround you had to write). When you brief sub-agents that use gmod-mcp, ask them to list theirs in their
report.
- At the end of the task, only for frictions that cost real time or a feature, or came back several times: offer the
user, in one line, to report them, and say it costs them nothing (you draft, check duplicates and file).
- The issue is public, in English: no secrets, tokens, personal paths, project or addon names, or project code.
Include the gmod-mcp version (`status`: `agent_version`), platform, coding agent (e.g. Claude Code) and model.
- The user can turn these offers off with the plugin option `feedback_offers`. Its current value is
`${user_config.feedback_offers}`: `false` means never offer (if you see the placeholder itself, treat it as `true`).
Mention the option when you offer. If the user asks to stop, set it for them:
`echo '{"feedback_offers": "false"}' | claude plugin configure gmod-mcp@gmod-mcp --values-stdin` (or they use
`/plugin configure gmod-mcp@gmod-mcp`), then they restart Claude Code.
- Search duplicates in https://github.com/ExtReMLapin/gmod-mcp/issues first when you can. File with `gh issue create
--repo ExtReMLapin/gmod-mcp --label agent-feedback` when `gh auth status` succeeds; otherwise give the prefilled
`issues/new?labels=agent-feedback&title=...&body=...` URL, one click left for the user.
## When it still does not answer
- `garrysmod/console.log` (written thanks to `-condebug`): the module's lines start with `[mcpagent]`.
`active: ... http://127.0.0.1:<port>/mcp` means the server is up on that port; `inactive: the -mcp flag is not on the
command line` and `refused: ...` say why it is not.
- No `[mcpagent]` line at all on the very first start: the module only loads with a map; start again with
`+map gm_construct`.
- The process is running but the URL gives `000`: wait for the main menu or the map load to finish.
- **Another program holds port 27080** (the bridge's tools answer `port_conflict`, the console says "port 27080 is held by
another program", or the check in section 1 gets an answer that is not 401 + `X-Gmod-Mcp`): the module takes the
next free port (the `active:` line names it), but the bridge only talks to the base port. Find the program:
`Get-NetTCPConnection -LocalPort 27080 | Select-Object OwningProcess` then `Get-Process -Id <pid>` (Windows
PowerShell), `ss -ltnp 'sport = :27080'` (Linux). Never kill it yourself: tell the user what it is. Then either
free port 27080, or ask the user to set the `GMOD_MCP_PORT` environment variable to the game's port and restart
Claude Code (`port_conflict` names that port when a gmod-mcp answers on one of the next 15).