Skip to main content
Glama

Reload a Lua file from disk

lua_reload
Destructive

Reread an addon or gamemode Lua file from disk and run it in its realms to test edits without reloading the map. Optionally rerun every changed file of a mounted Lua folder.

Instructions

Reads an addon or gamemode file from the disk again and runs it in its realms, to test an edit without reloading the map, in every realm it belongs to in one call. On the machine that hosts the game (singleplayer or listen server) include() from lua_exec also reads the edited file, in the server and the client realm (checked live); a client connected to a separate server (e.g. a local srcds) only has the copies that server sent, so there lua_reload is the way to run an edit on the client. Looks under the mounted Lua folder if any (lua_mount), then lua/, gamemodes/, addons/*/lua|gamemodes/: the engine's order, so the copy the game would load (other matches are listed). Errors name the real file. Running a file again redefines its functions and hooks; what it built at load time (entities, timers, net strings) is not reset. Returns {ok, file, chunkname, realms: {: lua_exec result or {error}}, other_matches?}. Example: {"path": "my_addon/sh_core.lua"} (shared file: runs in server then client). With a mounted folder (lua_mount) there is no autorefresh: mounted_changed: true (instead of path) runs again every file of that folder whose time differs from what each realm loaded (modified, added; the list is status.lua_mount.stale_files), in alphabetical order and in the realms each file belongs to, and returns {ok, mode, path, reloaded: [{file, chunkname, reason, realms: {: lua_exec result or {error}}}], skipped: [{file, why}] (deleted files, entity/weapon/effect files: map_load or lua_reload {path}), realms_without_mount, note?, warning?}; error no_mount if no folder is mounted, error reload_failed (isError, the whole result in details) if a file fails in a realm. Limits: a reload re-runs the file, it does not undo what the old copy did (hooks and timers it added under another name, net strings, entities), and it does not reload a realm that loaded before the folder was mounted (map_load).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "lua_reload"
  }
}

Input Schema

NameRequiredDescriptionDefault
jitNoObsolete. gmod-mcp no longer turns the LuaJIT compiler off, neither for this code nor for the functions it defines (hooks and timers run at real speed, timings are real). jit: true now only ignores `budget`.
pathNoThe file as include() names it (e.g. 'autorun/my_addon.lua', 'my_addon/sh_core.lua'), a path relative to the game folder ('addons/my_addon/lua/...'), or an absolute path.
depthNoCut tables deeper than this (default: no cut).
limitNoCut tables longer than this (default: no cut).
budgetNoOptional time limit in seconds, best effort (none by default). It stops loops written in this code itself (error budget_exceeded), not a loop inside a compiled function it calls. Without it, an infinite loop freezes the game: the call fails with main_thread_timeout after timeout_s, status shows main_thread_stalled, and game_terminate ends the game.
fieldsNoKeep only these keys of each returned table (e.g. ["pass", "fails"]): the rest of a large result is dropped before it reaches you. Only returned tables are projected: when none is (a JSON string, a number), the result says so in fields_note.
realmsNoRealms to run it in. Default from the name: server/ folder, sv_ prefix or init.lua -> server; client/ folder or cl_ prefix -> client; lua/menu/ -> menu; otherwise server then client (shared file).
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
chunknameNoChunk name: the source shown by debug.getinfo, errors and tracebacks, e.g. '@addons/my_addon/lua/my_addon/core.lua' for code that identifies its caller by file. Default: '=mcpagent:lua_exec', or the file's path.
timeout_sNoHow long to wait for the game's answer (default 60, or budget + 10). Past it the call fails with main_thread_timeout; the code may still be running.
max_stringNoCut strings longer than this (default: no cut).
mounted_changedNoInstead of `path`: reload every file of the mounted Lua folder (lua_mount) that changed since each realm loaded it (status.lua_mount.stale_files), each in the realms it runs in. Not with `path`.

Output Schema

NameRequiredDescriptionDefault
okYes
fileNo
modeNo
nextNo
noteNo
pathNo
realmsNo
skippedNo
warningNo
reloadedNo
chunknameNo
next_callNo
answered_byNo
other_matchesNo
truncated_noteNo
version_warningNo
realms_without_mountNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare destructiveHint=true, and the description earns that by explaining exactly what is and is not undone: functions and hooks are redefined, but entities, timers and net strings built at load time persist, and a realm that loaded before mounting is not reloaded. It also discloses error modes (no_mount, reload_failed, budget_exceeded, main_thread_timeout) and that missing budget can freeze the game — context the annotations cannot carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One dense run-on paragraph with chained parentheses and semicolons, mixing purpose, lookup order, return shapes, error codes and limits. The two long return-shape literals restate what the output schema already provides and do not earn their space; key operational warnings are buried mid-paragraph rather than front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 12-parameter tool with two modes, all three real realms, mount dependence, and destructive re-execution, the description covers defaults, search order, error codes and limits. Nothing an agent needs to call it correctly in either mode is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: a worked example showing a shared file runs in server then client, the mutual exclusivity of mounted_changed and path, alphabetical ordering and skipped-file reasons in mounted mode. It stops short of explaining the projection parameters (limit, depth, max_string, fields), which the schema already handles.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first clause states a concrete verb and resource — 'Reads an addon or gamemode file from the disk again and runs it in its realms' — plus the goal ('to test an edit without reloading the map'). It explicitly contrasts itself with map_load and lua_exec's include(), so an agent can distinguish it from siblings without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit routing rules: on a listen server include() via lua_exec suffices, but on a client connected to a separate srcds 'lua_reload is the way to run an edit on the client'. It also names when to use mounted_changed instead of path, and when map_load or lua_reload {path} is required for entity/weapon/effect files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.