Skip to main content
Glama

Is this function the code on disk?

lua_function_source
Read-only

Locate a Lua function's definition and check if the running realm's bytecode matches the file on disk, so edited addon tests are trustworthy.

Instructions

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. Use it before trusting a test result after an edit (a map that was not reloaded, a file the client got from the server, another copy of the addon). Pick the realm the function lives in (default menu in client mode, server on srcds: addon code is usually in 'server' or 'client'). The file is found like the engine does (mounted Lua folder first, then lua/, gamemodes/, addons). Result: {source ("@" as the engine names it), linedefined, lastlinedefined, file/disk (absolute; the copy this realm ran), from_mount (true: it came from the mounted Lua folder, recorded when the folder was put in front of the realm's Lua path; false: the installed copy), mount_has_file, provenance (mount_in_place_at_load | reloaded_from_mount | installed | not_on_disk | no_file), file_age_s, matches_disk: true (same code) | false (edited since it was loaded, or another copy) | null (no file: code from lua_exec/RunString, or only inside a .gma), line_on_disk (where it starts now), note}. Example: {"realm": "server", "expr": "MyAddon.Update"}.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "expr": "<expr>"
    },
    "name": "lua_function_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
exprYesLua expression giving the function, e.g. 'MyAddon.Update' or 'hook.GetTable().Think.MyHook'.
realmNoLua state to run in. Default: menu in client mode, which has no game libraries (ents, util.TraceLine, players...): pass 'server' or 'client' for game code; they exist only once a map is loaded (map_load). On srcds: server (the default; no menu or client realm).
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
diskNo
fileNo
nextNo
noteNo
sourceYes
warningNo
next_callNo
file_age_sNo
from_mountNo
provenanceNo
answered_byNo
linedefinedYes
loaded_fromNo
line_on_diskNo
matches_diskYes
mount_has_fileNo
truncated_noteNo
lastlinedefinedYes
provenance_noteNo
version_warningNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint and closed-world, and the description adds real behavior: the comparison recompiles the file in the same realm, the file is resolved like the engine does (mount first, then lua/, gamemodes/, addons), and it flags the no-file case from lua_exec/RunString or .gma contents. Much of the remaining text is return-value documentation, which the output schema already carries.

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 core purpose is front-loaded and the sentence order is logical, but the body is a dense run of parentheticals and a long enumerated result-field breakdown that overlaps what the output schema provides. It is information-rich yet heavier than needed for a 3-parameter read-only probe.

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?

Covers everything an agent needs: what is compared, which realm to pick and why, how the file path is resolved, what matches_disk true/false/null each mean, and a worked example. Nothing material is left for the agent to infer.

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 coverage is 100%, so expr, realm, and instance are already documented, including the realm default rules. The description's realm guidance ('addon code is usually in server or client', 'no game libraries in menu') adds modest practical color, and the example call is useful, but it largely restates schema content.

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?

Names a specific verb and resource: tells where a function was defined and whether the running bytecode matches the file recompiled from disk. The framing ('Is this function the code on disk?') plus the concrete mechanics distinguish it from lua_inspect/lua_exec siblings without needing their schemas.

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?

Gives an explicit trigger: use it before trusting a test result after an edit, with the failure modes spelled out (map not reloaded, file from server, another copy of the addon). Realm selection is also guided (addon code usually in 'server' or 'client'). No sibling alternatives are named, which is the only gap.

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