Skip to main content
Glama

Check Lua without running it

lua_check
Read-only

Compile 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

NameRequiredDescriptionDefault
codeNoLua code to check (instead of path).
pathNoFile 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/).
limitNoMax entries per list (default 200).
realmNoLua 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).
globalsNoAlso list unknown and written globals (default true).
instanceNoOptional. 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

NameRequiredDescriptionDefault
okYes
nextNo
noteNo
pathNo
notesNo
realmYes
errorsYes
checkedYes
warningNo
next_callNo
truncatedNo
answered_byNo
truncated_noteNo
globals_writtenNo
unknown_globalsNo
version_warningNo

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?

Far exceeds the annotations: readOnlyHint is confirmed by 'runs nothing', and the description adds real behavioral detail — per-file error reporting (parser stops at the first error), the realm-dependence of unknown-global analysis, the explicit carve-outs for ENT/SWEP/GM/EFFECT/TOOL, truncation via limit, and the realm_unavailable/not_found error codes. Nothing here contradicts the annotations.

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

Conciseness4/5

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

The lead clause is front-loaded and the whole thing is information-dense rather than padded. It occasionally compresses into backticked fragments ('`code`, or `path`: a file or a whole folder') that read as notes rather than prose, which costs a little clarity.

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 six-parameter tool with realm-dependent analysis, every question an agent would ask is answered: input modes, path resolution, realm consequences, output fields, truncation, and error codes. The return-shape restatement is partly redundant with the output schema, but it does not leave any gap.

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 already 100%, so the baseline is 3, but the description adds genuine meaning beyond the schema: it frames code vs path as mutually exclusive inputs, explains that path can be a whole folder of .lua files (e.g. an addon), and gives practical guidance on choosing a realm ('client'/'server' need a map; 'menu' lacks most game functions).

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?

States a specific verb and resource — compiles Lua with the game's own parser and runs nothing — which immediately separates it from the lua_exec siblings without needing to name them. The scope (GLua dialect quirks like !=, &&, //, continue) further pins down exactly what 'compile' means here.

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

Usage Guidelines4/5

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

The phrase 'runs nothing' plus the code/path duality makes it clear this is the static-check path rather than the execute path, and the example call shows the intended shape. It stops short of explicit routing ('use this instead of lua_exec when...'), so the alternative is implied rather than stated.

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