Skip to main content
Glama

Inspect a Lua value

lua_inspect
Read-only

Evaluates a side-effect-free Lua expression and describes its value, type, table keys, metatable, or function source to help you discover APIs and structures.

Instructions

Evaluates an expression in a realm (it runs: keep it side-effect free; 2 s time limit) and describes the value. Result: {type, value (serialized to depth; 0 = summary only), and for a table: count, keys: [{key, key_type, type}] up to limit, truncated; metatable?: {type, name (MetaName), keys, methods (functions of __index)}}; for a function also {source, linedefined, lastlinedefined, from_mount, disk, mount_has_file, provenance} (see lua_function_source). Use it to discover an API or a structure; use lua_exec to compute something. Example: {"realm": "server", "expr": "FindMetaTable("Player")", "depth": 0, "limit": 300}.

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

Input Schema

NameRequiredDescriptionDefault
exprYesLua expression, e.g. 'hook.GetTable()' or 'FindMetaTable("Entity")'.
depthNoDepth (default 1).
limitNoMax number of keys (default 100).
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
keysNo
nextNo
noteNo
typeYes
countNo
valueNo
sourceNo
warningNo
metatableNo
next_callNo
truncatedNo
from_mountNo
provenanceNo
answered_byNo
linedefinedNo
loaded_fromNo
mount_has_fileNo
truncated_noteNo
lastlinedefinedNo
provenance_noteNo
version_warningNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.5/5.0
Behavior4/5

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

Beyond the readOnlyHint/openWorldHint annotations it discloses non-obvious traits: the expression is actually executed with a 2 s execution limit, side effects are the caller's responsibility, key listings are truncated at `limit`, and results are nested by `depth`. That is real added context, though much of the response-shape enumeration duplicates the existing output schema.

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 critical guidance is front-loaded, but the middle is a dense run-on clause of nested braces and field lists that is hard to scan and largely restates the output schema. The information is useful, yet the packaging costs readability.

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 5-parameter evaluation tool it covers everything an agent needs: execution semantics, time limit, realm behavior implications, serialization depth, truncation, provenance for functions, and which sibling to use for the other job. An output schema exists, so return values need not be explained further.

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; the description earns above that by explaining what `depth` actually does ("serialized to `depth`; 0 = summary only") and that `limit` truncates the returned key list — semantics the schema's terse "Depth (default 1)" does not convey. It does not, however, add anything about `realm` or `instance` beyond what the schema already documents.

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 ("Evaluates an expression in a realm ... and describes the value") and immediately differentiates itself from lua_exec ("use lua_exec to compute something") and lua_function_source (pointed to for function details). An agent can pick this tool over its closest siblings without opening either 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?

Explicit routing guidance: "Use it to discover an API or a structure; use lua_exec to compute something." It also front-loads the operating constraint ("keep it side-effect free; 2 s time limit") and gives a concrete worked example invocation, so both when-to-use and how-to-call are covered.

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