Skip to main content
Glama

ast_find_pattern

ast_find_pattern
Read-onlyIdempotent

Search TypeScript and JavaScript code by AST pattern matching instead of text, returning typed matches with file, line, column ranges, and captured variables.

Instructions

Code-intelligence tool for structural pattern search: run one ast-grep pattern against every fresh indexed TypeScript / TSX / JavaScript / JSX file and return typed matches (file, line range, column range, matched text, captured metavariables). Ambiguous TSX/JSX snippets that start with {, [, or < retry with an auto-anchored const _ = ... parser context when the original pattern returns zero matches, and patternAttempts / match patternVariant report which form matched. Reef-backed freshness guard skips stale/deleted/unknown indexed files so old AST rows do not become phantom matches; set MAKO_REEF_BACKED=legacy for the one-release rollback path. Read-only; never edits files. Use when text/FTS search is too noisy for structural queries (e.g. console.log($X), await supabase.rpc($NAME), useEffect($FN, [])).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNo
projectRefNo
patternYes
capturesNo
languagesNo
pathGlobNo
maxMatchesNo
maxFilesNo
excludeAcknowledgedCategoryNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolNameYes
projectIdYes
patternYes
languagesAppliedYes
filesScannedYes
patternAttemptsYes
matchesYes
acknowledgedCountYes
reefFreshnessYes
reefExecutionYes
truncatedYes
warningsYes
_hintsYes
Behavior5/5

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

Annotations already provide readOnlyHint=true, idempotentHint=true, and openWorldHint=true. The description adds substantial behavioral context: it never edits files (read-only), explains the retry logic for ambiguous TSX/JSX snippets with auto-anchored parser context, describes the reef-backed freshness guard to avoid phantom matches, and mentions the MAKO_REEF_BACKED environment variable for rollback. No contradictions with annotations.

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 description is relatively long but front-loaded with the core purpose. Each sentence adds value, covering purpose, retry logic, freshness guard, and usage guidance. No fluff, but could be slightly more structured (e.g., separate sections). Overall efficient for the amount of information.

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

Completeness4/5

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

Given 9 parameters with 0% schema coverage, the description explains key behavioral traits (retry, freshness, safety) and return values. However, it does not detail all parameters or provide output schema details (though output schema exists externally). For a moderate-complexity tool, it covers the most important aspects but leaves some gaps, such as parameter documentation and error conditions.

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 0%, so the description must compensate. It explains the 'pattern' parameter (ast-grep pattern), mentions 'captures' (captured metavariables), and implies 'languages' by listing file types. However, other parameters like projectId, projectRef, pathGlob, maxMatches, maxFiles, and excludeAcknowledgedCategory are not explained. The description adds partial value but is insufficient for all 9 parameters.

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 clearly states it is a code-intelligence tool for structural pattern search using ast-grep, specifies the file types (TypeScript/TSX/JavaScript/JSX), and lists the return value (typed matches: file, line range, column range, matched text, captured metavariables). It effectively distinguishes itself from text/FTS search by labeling it as structural pattern search.

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 to use it when text/FTS search is too noisy for structural queries, with concrete examples like console.log($X) and await supabase.rpc($NAME). It does not explicitly exclude scenarios, but the 'use when' guidance is clear and helpful. It also mentions retry behavior for ambiguous TSX/JSX snippets, providing context for when the tool automatically adjusts.

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

Install Server

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/drhalto/agentmako'

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