Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault

No arguments

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

The game is not running right now: start it with -mcp; the tools come back by themselves.

gmod-mcp drives a LOCAL Garry's Mod instance (mode client, instance 'none yet: the game is not running'). Feedback: while you work, note frictions with gmod-mcp itself (a wrong description, an error without a reason, a missing tool, a workaround). At the end of your task, only if one cost real time or came back, offer the user in one line to report it to the maintainers (you do everything). The issue is PUBLIC: no secrets, personal paths, project or addon names, or project code. Procedure: guide "Reporting frictions" (https://github.com/ExtReMLapin/gmod-mcp). The user can turn these offers off (plugin option feedback_offers: /plugin configure gmod-mcp@gmod-mcp, then restart Claude Code): say so in your offer. Realms: 'menu' (client mode, always there), 'client' and 'server' (once a map is loaded, recreated on every map change); srcds has only 'server'. Order: status -> map_load -> lua_exec / ents_find / trace / screenshot... -> errors_since. Pitfalls: (1) realm_unavailable: load a map (srcds: use realm 'server'; client-side tools answer 'unsupported'); client_locked: no client realm while connected to a non-loopback server. (2) Effects take a frame: use wait_for / wait_frames, not guesses. (3) map_load run as a background task: wait for its result before any realm tool (an earlier call reaches the OLD map; results carry generation). (4) Every instance shares the game folder with the user's own game (archived convars, data/, cookies): restore what a test changes. (5) A frozen game: status reports it, game_terminate ends it. More: guide "Pitfalls the instructions used to list". Lua files: working directory = /garrysmod/lua/mcpagent_tmp (lua/mcpagent_tmp/): if you share this disk write there, then lua_exec_file(realm, 'name.lua'); else lua_file_write. Long Lua work (scans, timed tests): never loop inside lua_exec (the game freezes): use lua_job (job:step() in loops, job:progress, return the result); prompt write-lua-job. Docs: api_search (what exists in each realm), wiki_search / wiki_page. Full guide: resource mcpagent://guide. Code Mode (calling these tools from a script): a call returns a JSON string, so JSON.parse it (accept an object too); an error throws, e.detail.error.code / e.detail.error.message say why (guide section "Code Mode"). Multi-instance: instances_list; every tool accepts 'instance'. client_crashed / server_crashed = that game crashed (details.dump is for a human): relaunch and rerun; instance_hung = frozen: close it and relaunch; instances_launch refuses with low_memory when the machine is full. Launches and map loads (engine bug FP7137: a starting game makes the others release their GPU resources for 2-10 s, and a map load ending then crashes them): the bridge makes instances_launch and map_load wait for each other (waited_s; errors map_load_in_progress / launch_in_progress: retry). Launch all clients in one call; start no game and change no map by hand meanwhile; other games can be unreachable for 15-18 s after a start. Guide "Launches and map loads". Testing an addon branch: lua_mount {path: } (or instances_launch {lua_mount}), effective at the next map_load. Guide "Mounted Lua folder".

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tasks
{
  "list": {},
  "cancel": {},
  "requests": {
    "tools": {
      "call": {}
    }
  }
}
tools
{
  "listChanged": true
}
prompts
{
  "listChanged": true
}
resources
{
  "subscribe": false,
  "listChanged": true
}
completions
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
statusA

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.

lua_execA

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.

lua_exec_fileA

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.

lua_reloadA

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.

lua_checkA

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.

lua_inspectA

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.

lua_function_sourceA

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.

lua_file_writeA

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}.

lua_file_readA

lua_file_read(name). Reads a file of the game's lua/mcpagent_tmp/ folder. Result: {path, content}. Error not_found.

lua_file_listA

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]}.

lua_file_deleteA

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.

map_listA

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}.

map_loadA

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.

disconnectA

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.

game_quitA

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.

game_terminateA

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.

wait_forA

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.

wait_framesA

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.

console_execA

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.

console_waitA

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.

console_readA

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.

console_bufferA

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}.

errors_sinceA

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.

errors_clearA

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}.

convar_getA

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.

convar_setA

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).

concommand_listA

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?}.

ents_findA

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.

ent_infoA

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.

ent_spawnA

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.

ent_removeA

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.

ent_fireA

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.

players_listA

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.

player_setA

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.

bots_addA

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.

traceA

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.

trace_throughA

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.

screenshotA

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.

screenshot_fromA

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.

debug_drawA

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}.

debug_clearA

debug_clear(). Client only (unsupported on srcds). Removes every primitive drawn by debug_draw (client realm). Result: {cleared: count}.

sound_emitA

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.

sound_traceA

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.

perf_snapshotA

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.

ui_clickA

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}.

ui_keyA

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"}.

api_searchA

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}.

wiki_searchA

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.

wiki_pageA

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.

events_waitA

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}.

reports_readA

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}.

reports_channelsB

reports_channels(). Report channels of this instance: {channels: [{channel, buffered (values kept), total (ever published), next_cursor}]}.

reports_clearA

reports_clear(channel?). Deletes a report channel and its values (all channels if channel is absent). Result: {cleared}.

hook_listA

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.

hook_traceA

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.

perf_hook_costA

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.

tests_runA

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.

lua_jobA

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.

lua_job_statusA

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.

lua_job_cancelA

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.

instances_listA

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.

lua_mountA

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.

instances_launchA

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.

instances_closeA

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.

instance_selectA

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).

Prompts

Interactive templates invoked by user choice

NameDescription
write-lua-jobWrite and run a lua_job script for a long task (scan, batch of traces, timed test) with progress reporting.
debug-errorsCollect the recent Lua errors, find their root cause in the code and propose (or apply) a fix.
run-testsRun a GLuaTest-format test file, then analyze the failures.
check-mapLoad a map, then report errors, entity counts, performance and a screenshot.

Resources

Contextual data attached and managed by the client

NameDescription
guideRealms, workflow, temporary files, return formats, error codes.
tests-formatGLuaTest format accepted by tests_run and list of assertions.
configAbsolute paths (game, Lua temporary directory, data), mode, port, instance identifier.
errorsLast 100 Lua errors of every realm (JSON). Subscribable: updated when a new error is captured.
consoleLast 200 console lines. Subscribable: updated when new lines are printed.

TDQS

A3.9/5.0

Scored across 65 tools

Disambiguation4/5

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.

Naming Consistency4/5

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.

Tool Count2/5

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.

Completeness5/5

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

ActivityMaintained
ResponsivenessLimited data