Skip to main content
Glama

Trace a line

trace
Read-only

Casts a single line segment between two points in a loaded GMod map to detect hits and return position, surface, entity, and collision details.

Instructions

One util.TraceLine from start to end. Result: hit, hit_world, hit_sky, hit_nodraw, pos (hit position, or end if nothing was hit), normal, fraction (0..1 along the segment), distance (to the hit, or the whole length), mat_type + mat_name (MAT_* constant), surfaceprop (name) + surfaceprop_id, texture, entity (summary, {id: 0, class: worldspawn} for the world, or null), start_solid, all_solid, fraction_left_solid, hitgroup, physics_bone. Example: {"start": [0, 0, 64], "end": [0, 0, -1000]}. For everything a segment crosses (walls, doors, thickness), use trace_through. Needs a loaded map (map_load): the server and client realms do not exist at the main menu.

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": {
      "start": "<start>",
      "end": "<end>"
    },
    "name": "trace"
  }
}

Input Schema

NameRequiredDescriptionDefault
endYesEnd, [x, y, z] in Hammer units.
maskNoContent mask: MASK_SOLID (default), MASK_SHOT, MASK_SHOT_HULL, MASK_SOLID_BRUSHONLY, MASK_PLAYERSOLID, MASK_PLAYERSOLID_BRUSHONLY, MASK_NPCSOLID, MASK_WATER, MASK_VISIBLE, MASK_OPAQUE, MASK_ALL, or the number.
realmNoRealm (default server).
startYesStart, [x, y, z] in Hammer units.
filterNoEntity indexes the trace ignores (e.g. the player).
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
hitYes
posYes
nextNo
noteNo
entityNo
normalNo
hit_skyNo
textureNo
warningNo
distanceYes
fractionYes
hitgroupNo
mat_nameNo
mat_typeNo
all_solidNo
hit_worldNo
next_callNo
hit_nodrawNo
answered_byNo
start_solidNo
surfacepropNo
physics_boneNo
surfaceprop_idNo
truncated_noteNo
version_warningNo
fraction_left_solidNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so the description's added value is the realm caveat and the failure mode at the main menu, which the annotations do not convey. It also spells out edge-case semantics (pos falls back to end on a miss, distance equals the whole length, entity is {id: 0, class: worldspawn} for world or null), though much of the return-field detail overlaps 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.

Conciseness4/5

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

The purpose and the trace_through split are front-loaded, then the return fields, then the example, then the prerequisite — a sensible order. The long comma-separated result enumeration is dense but each item is a distinct output field; a bulleted or grouped form would read better without losing content.

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?

The tool has an output schema and full annotation coverage, and the description still adds the prerequisite, the sibling routing rule, and a concrete call example. Nothing an agent needs in order to invoke this correctly appears to be missing.

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 description coverage is 100%, including the mask constant list, realm default, and filter meaning, so the schema already carries parameter semantics. The description adds only the worked example {"start": [0, 0, 64], "end": [0, 0, -1000]} and the units note; it says nothing extra about mask, filter, or instance relay behavior. Baseline 3 applies.

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?

"One util.TraceLine from start to end" gives a specific verb and resource, and the description immediately distinguishes it from trace_through ("For everything a segment crosses ... use trace_through"). An agent can choose between the two raycast tools 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: use this for a single hit along a segment, use trace_through for all crossings (walls, doors, thickness). It also states the precondition "Needs a loaded map (map_load): the server and client realms do not exist at the main menu," which tells the agent when the tool will fail and what to call first.

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