Skip to main content
Glama

Load Lua from another folder first

lua_mount
Idempotent

Mount a local addon Lua folder into one running Garry's Mod process to test or override its Lua files at the next map load.

Instructions

Mounted Lua folder: 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 (the client gets the folder's copy), lua_openscript, file.Read/Find with "LUA", and gmod-mcp's own lua_exec_file / lua_job {path} / lua_check / lua_reload / lua_function_source. A file in the folder hides the installed addon's file of the same Lua path; files only in the game are still loaded. Other games are not affected. Example: path "D:/dev/my-addon-wt" (a worktree of the addon installed as addons/my_addon): D:/dev/my-addon-wt/lua/autorun/my_addon.lua runs as autorun/my_addon.lua; D:/dev/my-addon-wt/lua/my_addon/core.lua is what include("my_addon/core.lua") loads, instead of addons/my_addon/lua/my_addon/core.lua; D:/dev/my-addon-wt/gamemodes//... are gamemode files; materials/, sound/, models/ and everything outside lua/ and gamemodes/ are not mounted. IT TAKES EFFECT AT THE NEXT MAP LOAD: call map_load right after (code already running stays until loaded again). No autorefresh: status.lua_mount.stale_files lists the folder's files that changed since each realm loaded them; lua_reload {mounted_changed: true} runs them again (or lua_reload {path}, or map_load); lua_function_source / lua_inspect of a function say which copy it came from (from_mount, disk). The engine names the folder's files from the folder's root (debug.getinfo source "@lua/my_addon/x.lua", not "@addons/my_addon/lua/my_addon/x.lua"). Only Lua (not materials, sounds, data/). path: the addon's root or its lua/ folder, absolute; null removes it (from the next map load); omitted: the current folder and the engine's Lua search paths (lsv = server, lcl = client). If the result says base_lua_mounted: false, remove the folder at once. engine_serves_folder (with a map loaded) is what the game's own file system says: false means it lists the folder but finds none of its files (a path it cannot read), so the game runs the installed code whatever else says mounted: a warning names the way out. A test client can start with one: instances_launch {lua_mount}. empty_cache (default true) empties the engine's Lua file cache. Windows game clients only (unsupported_platform on Linux; client only, unsupported on srcds). Full guide: resource mcpagent://guide, section "Mounted Lua folder".

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

Input Schema

NameRequiredDescriptionDefault
pathNoAbsolute path of the folder to mount: the addon's root, i.e. the folder that contains lua/ (e.g. "D:/dev/my-addon-wt"), or that lua/ folder itself (same result). Must be outside the game folder. null or "" unmounts it (from the next map load). Omit it to read the current state.
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
empty_cacheNoEmpty the engine's Lua file cache after the change (default true).
allow_shadowNoMount a folder that replaces files of the game's own base Lua (lua/includes/init.lua...) anyway. Refused by default (error shadows_base_lua): such a folder made a client hang in its load.

Output Schema

NameRequiredDescriptionDefault
nextNo
noteNo
removedNo
warningNo
previousNo
lua_mountNo
next_callNo
hook_callsNo
mount_hookNo
answered_byNo
search_pathsNo
cache_emptiedNo
engine_servesNo
fs_first_slotNo
hook_path_idsNo
folder_missingNo
truncated_noteNo
version_warningNo
base_lua_mountedNo
engine_serves_folderNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.5/5.0
Behavior5/5

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

The description discloses far more than the annotations: affected lookup paths, shadowing behavior, next-map-load timing, lack of autorefresh, stale-file detection, engine source naming, limited mounting scope to Lua/gamemodes, and the base_lua_mounted false warning. These are important behavioral traits for a tool with non-obvious process-wide effects.

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

Conciseness3/5

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

The purpose is front-loaded, but the description is a very dense single paragraph that combines mechanics, examples, warnings, platform constraints, and alternate tool calls. Most content is relevant, yet the lack of structure and length make it harder to scan than a well-organized definition.

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?

Given the complexity of mounting a shadow Lua tree, the description covers effects, timing, platform limits, failure signals, and follow-up actions. With an output schema present, it does not need to explain return values, and the remaining behavioral context is sufficiently complete.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents path, instance, empty_cache, and allow_shadow thoroughly. The description adds useful path examples, but most parameter meaning is already present in the schema, making this baseline-level rather than strongly additive.

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 description names a specific operation and resource: mounting a Lua folder into this game process only, with lookup precedence over installed files. It clearly distinguishes scope from other games and from non-Lua assets, so an agent can understand what is being changed without opening the 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?

It gives explicit operational guidance: call map_load right after because the mount takes effect on the next map load, use lua_reload for changed files, omit path to read current state, and null to unmount. It also states exclusions such as Windows game clients only, client-only support, and unsupported platform behavior on Linux/srcds.

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