Skip to main content
Glama

code_query

Query a codebase read-only to locate symbols, references, callers, callees, tests, and impact, inspect file outlines or bodies, and validate candidate changes before editing.

Instructions

Where is X, who calls it, what's in this file. mode: outline|symbols|body|map|search|impact|references|callers|callees|tests|validate|capabilities. Read-only; search_terms=hypotheses.

Input Schema

NameRequiredDescriptionDefault
dirNomap only: subdir inside workspace_dir (escapes rejected).
fileNoRequired for outline/callers/callees/impact/tests/validate; optional with symbol for references.
kindNoreferences: filter by kind (call,import,use,assign,extends,implements).
lineNocallers/callees: disambiguate a line.
modeYesmap=overview; body=read; search=code_search; tests=find_tests; validate=sandbox_validate; capabilities=list; capability=describe.
nameNocapability mode: exact original tool name.
pageNomap only: page number (default 1; pass next_page).
richNobody only: include rich projection (outline).
depthNocallers/callees/impact: traversal depth.
limitNoMax rows (symbols, references).
queryNosymbols: substring; capabilities: optional name/summary filter.
cursorNocapabilities mode: pagination offset (from next_cursor).
symbolNoRequired for references; optional with file for callers/callees/impact.
optionsNoPer-mode passthrough; protected keys rejected; details via mode=capability.
categoryNocapabilities mode: filter by category (e.g. query/audit/maintain).
page_sizeNomap: entries per page (default 12).
max_tokensNomap only: map token budget (default 700).
budget_hintNobody: max chars (default 1200; 0 = full).
new_contentNovalidate only: candidate full content to check (no write).
search_termsNosearch: identifier guesses (≤8), hypotheses.
workspace_dirYesRoot (abs); auto-indexed on first read.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.6.1
    • changedInput schema / properties / budget_hint / description
      Previous value: -"body only: max chars (default 1200; 0 = full, hard-capped)."New value: +"body: max chars (default 1200; 0 = full)."
    • changedInput schema / properties / kind / description
      Previous value: -"references only: filter by kind (call,import,use,assign,extends,implements; comma-separated)."New value: +"references: filter by kind (call,import,use,assign,extends,implements)."
    • changedInput schema / properties / mode / description
      Previous value: -"map=compact paged overview (+dir drill); body=read file/symbol content without a task; search=code_search intent search; tests=find_tests candidates; validate=sandbox_validate content; capabilities=list; capability=describe by name."New value: +"map=overview; body=read; search=code_search; tests=find_tests; validate=sandbox_validate; capabilities=list; capability=describe."
    • changedInput schema / properties / options / description
      Previous value: -"Advanced per-mode passthrough to the original tool (e.g. callers: max_callers; impact: symbols/change_type; body: locators/context_lines). Protected keys rejected; full schema via mode=capability."New value: +"Per-mode passthrough; protected keys rejected; details via mode=capability."
    • changedInput schema / properties / page_size / description
      Previous value: -"map only: entries per page (default 12; packing hint)."New value: +"map: entries per page (default 12)."
    • changedInput schema / properties / query / description
      Previous value: -"Required for symbols (substring); capabilities: optional name/summary filter."New value: +"symbols: substring; capabilities: optional name/summary filter."
    • addedInput schema / properties / search_terms
      Added value: +{
      +  "description": "search: identifier guesses (≤8), hypotheses.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • changedInput schema / properties / workspace_dir / description
      Previous value: -"Root (abs). Any workspace path works — a fresh one is indexed automatically on first read."New value: +"Root (abs); auto-indexed on first read."
  2. Changed1 schema field changedv0.5.29
    • changedInput schema / properties / workspace_dir / description
      Previous value: -"Root (abs)."New value: +"Root (abs). Any workspace path works — a fresh one is indexed automatically on first read."
  3. Addedv0.5.28

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations supplied, the description carries the full burden, and it does deliver one important disclosure: 'Read-only'. It also hints that search terms should be treated as hypotheses. Beyond that it says nothing about indexing behavior, pagination/cursor semantics, token budgets, or result shape, which matter for a 13-mode tool.

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 is front-loaded with user-facing questions followed by the mode list, with essentially no filler. The tradeoff is that the mode run-on and the 'search_terms=hypotheses' shorthand are terse to the point of being cryptic.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mega-tool with 13 modes, 21 parameters, a nested options passthrough, and no annotations or output schema, the description is thin: it does not help an agent choose among the many modes or explain the cursor/page/budget mechanics. The unusually rich schema compensates substantially, but mode-selection guidance remains largely absent.

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%, so the schema already documents all 21 parameters, setting the baseline at 3. The description adds only marginal meaning, chiefly the framing that search_terms are hypotheses (the schema already says this) and the mode enumeration, which the schema also contains.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives three concrete use cases ('Where is X, who calls it, what's in this file'), which tells an agent this is a code navigation/structural query tool, and it enumerates the available modes. It does not distinguish itself from siblings like code_read or code_check, and the mode list omits 'capability' which appears in the schema enum, so it is clear but not fully differentiated.

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

Usage Guidelines3/5

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

Listing the modes implies which kind of query to run for each question, which is a form of usage guidance. However, there is no explicit statement of when to prefer code_query over code_read or code_check, and no when-not guidance or prerequisite notes are given.

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