Skip to main content
Glama

AST structural search

ast_search

Run tree-sitter queries against source files to locate AST captures with line numbers, enabling structural pattern matching beyond grep.

Instructions

Run a tree-sitter query (S-expression pattern) against a source file and return captures with line numbers. Use for AST-shaped matching that Grep cannot express.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesfile path
limitNomax captures returned (default 50, hard max 200)
offsetNoskip the first N captures before applying limit
patternYestree-sitter query pattern, e.g. (method_invocation name: (identifier) @m)
languageNooverride language inference
Install Server

TDQS

A3.9/5.0
Behavior3/5

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

No annotations are provided, so the description carries the behavioral burden. It discloses that the operation is a query that 'returns captures with line numbers,' which implies read-only behavior. However, it does not mention whether the file must be indexed, how language inference works, or what errors may occur — relevant gaps given the sibling index-related tools.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

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

The description is two sentences with no filler. The first sentence front-loads the action and output; the second sentence states the appropriate use case. Every word contributes to understanding the tool.

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?

The core call pattern is covered: file, query pattern, and captures with line numbers. However, with no output schema or annotations, the return shape and preconditions such as indexing requirements or language behavior are underspecified. The rich schema helps, but the description alone is not fully self-sufficient for an agent.

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 baseline is 3. The description slightly enriches the pattern parameter by calling it an 'S-expression pattern,' but it adds no additional meaning about file path, language override, limit, or offset beyond what the schema already provides.

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 specific operation: 'Run a tree-sitter query (S-expression pattern) against a source file and return captures with line numbers.' It clearly identifies the resource (source file), the action (AST query), and the output (captures with line numbers). It also frames itself as 'AST-shaped matching' distinct from Grep, which differentiates it from generic search tools.

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?

The description explicitly says when to use the tool: 'Use for AST-shaped matching that Grep cannot express.' This gives a clear context and an implied exclusion for simpler text searches. However, it does not compare against sibling code-intelligence tools like find_references or list_definitions, leaving some selection ambiguity within the tool suite.

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

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zhaoxingxing06/kimi-tree-lens'

If you have feedback or need assistance with the MCP directory API, please join our Discord server