Skip to main content
Glama

magento_ast_search

Perform structural PHP code search with AST queries to detect anti-patterns like ->setX(null) calls and method chains missing null guards.

Instructions

Structural PHP code search using tree-sitter AST queries. Unlike magento_grep (text-based), this understands PHP AST — matches code structure regardless of variable names, ignores comments/strings. Available named patterns: "dataobject-set-null" (finds ->setX(null) anti-pattern calls), "unchecked-method-chain" (finds ->a()->b() chains without null guards). Uses Rust tree-sitter for fast, accurate parsing. ⚡ For multi-query workflows use magento_batch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoSubdirectory to search (relative to MAGENTO_ROOT). Default: entire codebase. Example: "vendor/acme/"
patternYesNamed AST query pattern. "dataobject-set-null": finds ->setX(null) calls on DataObjects. "unchecked-method-chain": finds ->a()->b() chains without null guards.
maxResultsNoMaximum matches to return (default: 50, max: 200)
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool uses Rust tree-sitter for fast, accurate parsing and that it ignores comments/strings. This is good, but it doesn't explicitly state whether the tool is read-only or if it modifies state (likely read-only). A score of 4 reflects strong transparency with a minor gap in safety disclosure.

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 concise and well-structured. It begins with a clear statement of functionality, then distinguishes from a sibling, lists available patterns with examples, and ends with a performance note and a usage tip. Every sentence adds value without redundancy.

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?

Given the tool's medium complexity and the absence of an output schema, the description is complete. It covers purpose, usage guidelines, behavioral traits (speed, AST awareness), and parameter details. No additional context is needed for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds significant value by explaining each named pattern in detail, describing the default for 'path' and the default/max for 'maxResults'. This goes beyond the schema's minimal descriptions, making parameter semantics very clear.

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 that the tool performs structural PHP code search using tree-sitter AST queries. It distinguishes itself from the sibling 'magento_grep' by explicitly noting that it understands PHP AST, matches code structure regardless of variable names, and ignores comments and strings, which provides a specific and differentiated purpose.

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?

The description provides explicit guidance on when to use this tool: for AST-based structural search, contrasted with text-based 'magento_grep'. It also mentions available named patterns with examples, and advises using 'magento_batch' for multi-query workflows, giving clear context on when not to use it.

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/krejcif/magector'

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