Check Lua without running it
lua_checkCompile Lua with the game's GLua parser without executing it to catch syntax errors, unknown globals, and accidental global writes in code, files, or addon folders.
Instructions
Compiles Lua with the game's own parser (GLua syntax: !=, &&, ||, !, //, /* */, continue) and runs nothing. code, or path: a file or a whole folder (every .lua under it, e.g. an addon), absolute or relative to the game folder or lua/mcpagent_tmp/. Returns ok, errors [{file, line, message}] (one per file: the parser stops at the first error), and from the bytecode: unknown_globals (globals read but neither defined in the checked files nor present in the realm: typos, missing includes, wrong realm) and globals_written (every global assignment, e.g. a forgotten local). Unknown globals depend on the realm: pick the one the code runs in ('client'/'server' need a map; 'menu' lacks most game functions). ENT, SWEP, GM, EFFECT and TOOL are never reported. Result: {ok, realm, checked (files), errors: [{file, line, message}], unknown_globals: [{name, file, line}], globals_written: [{name, file, line}], truncated? (lists cut at limit), notes?}. Errors: realm_unavailable, not_found. Example: {"realm": "server", "path": "addons/my_addon/lua"}.
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_check"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Lua code to check (instead of path). | |
| path | No | File or folder to check (instead of code): absolute, or relative (looked up in lua/mcpagent_tmp/, the mounted Lua folder if any, the game folder e.g. 'addons/my_addon/lua', then lua/, gamemodes/, addons/*/lua/). | |
| limit | No | Max entries per list (default 200). | |
| realm | No | Lua state whose parser and globals are used: 'menu' (default in client mode, always present), 'client' or 'server' (default on srcds, which has only that one). | |
| globals | No | Also list unknown and written globals (default true). | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| next | No | ||
| note | No | ||
| path | No | ||
| notes | No | ||
| realm | Yes | ||
| errors | Yes | ||
| checked | Yes | ||
| warning | No | ||
| next_call | No | ||
| truncated | No | ||
| answered_by | No | ||
| truncated_note | No | ||
| globals_written | No | ||
| unknown_globals | No | ||
| version_warning | No |