Skip to main content
Glama

Trace a hook

hook_trace
Read-only

Records calls to a Garry's Mod hook event over a set duration or call cap, serializing arguments so you can inspect what fired and when without changing game behavior.

Instructions

Records the calls of a hook event for duration_s (or until max_calls), with each call's arguments serialized (entities as {__type, id, class...}), through a temporary hook.Add that returns nothing (game behaviour unchanged), removed at the end. Waits the whole duration (progress reported; MCP task possible). Result: {event, calls: [{t (seconds since start), args: [...]}], recorded, total_calls (also those past max_calls), capped, duration_s, tracer_removed}. Not seen: calls that a hook running before it stopped by returning a value. Error realm_lost if the map changes meanwhile. Example: {"realm": "server", "event": "PlayerSay", "duration_s": 10}.

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": {
      "event": "<event>"
    },
    "name": "hook_trace"
  }
}

Input Schema

NameRequiredDescriptionDefault
depthNoArgument serialization depth (default 2).
eventYesE.g. EntityEmitSound, PlayerSpawn, Think.
realmNoDefault server.
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
max_callsNoCap on recorded calls (default 100).
duration_sNoDefault 5.

Output Schema

NameRequiredDescriptionDefault
nextNo
noteNo
callsYes
eventYes
cappedNo
warningNo
recordedYes
next_callNo
duration_sNo
answered_byNo
total_callsYes
tracer_removedNo
truncated_noteNo
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?

Beyond readOnlyHint/openWorldHint, the description discloses the core behavioral traits: a temporary hook.Add that returns nothing so game behavior is unchanged, automatic removal at the end, a blocking wait for the full duration with progress reporting and possible MCP task, a cap where total_calls includes calls past max_calls, and a realm_lost error if the map changes. That is exactly the kind of side-effect and failure-mode context annotations alone cannot convey.

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?

It leads with what the tool does and everything after it (mechanism, wait semantics, result shape, blind spots, error, example) earns its place. The parenthetical density and long single sentences make it heavier than necessary, though nothing is padding.

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 long-running instrumentation tool with a 6-parameter schema, the description covers mechanism, blocking behavior, result fields, a known blind spot, and the likely error condition, and ends with a usable example. The instance-relay note is left to the schema, which is acceptable given the output schema already documents the return shape.

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, but the description adds real meaning: what the serialized args look like (entities as {__type, id, class...}), that max_calls is a cap while total_calls is unbounded, and that the tracer runs for the whole duration_s. The depth parameter's connection to serialization depth is only implied.

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 states a precise verb and resource: it records every call of a named hook event over a bounded duration/call count. The scope (argument serialization, temporary tracer) makes it clearly distinct from siblings like hook_list (enumerating hooks) or perf_hook_cost (measuring cost) without needing to name them.

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?

It gives a clear context for use (watch a hook for duration_s, capped by max_calls) plus a concrete example invocation. It also states a limitation ('not seen: calls that a hook running before it stopped by returning a value'), but it never routes the agent to an alternative such as hook_list for discovering event names or perf_hook_cost for cheaper measurement.

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