Skip to main content
Glama
ast-grep

ast-grep MCP Server

by ast-grep

dump_syntax_tree

Debug code rules by inspecting syntax tree structures. Use to discover correct syntax kinds and analyze how patterns are interpreted in ast-grep.

Instructions

Dump code's syntax structure or dump a query's pattern structure. This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule. The tool requires three arguments: code, language and format. The first two are self-explanatory. format is the output format of the syntax tree. use format=cst to inspect the code's concrete syntax tree structure, useful to debug target code. use format=pattern to inspect how ast-grep interprets a pattern, useful to debug pattern rule.

Internally calls: ast-grep run --pattern --lang --debug-query=

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe code you need
languageYesThe language of the code. Supported: bash, c, cpp, csharp, css, elixir, go, haskell, html, java, javascript, json, jsx, kotlin, lua, nix, php, python, ruby, rust, scala, solidity, swift, tsx, typescript, yaml
formatNoCode dump format. Available values: pattern, ast, cstcst
Behavior4/5

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

Since no annotations are provided, the description carries the full burden of behavioral disclosure. It does well by explaining the tool's internal implementation ('Internally calls: ast-grep run...'), which reveals it's a wrapper around a command-line tool. However, it doesn't mention potential side effects, error conditions, or output format details beyond the format parameter options.

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 well-structured and appropriately sized. It starts with the core purpose, provides usage guidance, explains parameters with practical examples, and ends with implementation details. While slightly longer than minimal, every sentence adds value and the information is front-loaded with the most important details first.

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?

For a debugging tool with 3 parameters and no output schema, the description provides good context about what the tool does, when to use it, and how parameters affect behavior. It could be more complete by describing the output format or potential error cases, but given the tool's relatively simple purpose and good parameter documentation, it's mostly sufficient for an agent to use it correctly.

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

Parameters4/5

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

With 100% schema description coverage, the baseline is 3, but the description adds significant value by explaining the practical meaning of the format parameter options (cst for 'debug target code' and pattern for 'debug pattern rule'), which goes beyond the schema's technical enum values. It also clarifies that code and language are 'self-explanatory' and provides context about what the tool actually does with these 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 the tool's purpose with specific verbs ('dump code's syntax structure' and 'dump a query's pattern structure') and distinguishes it from sibling tools by specifying it's for debugging syntax/pattern discovery rather than finding or testing code. It explicitly mentions this is for 'debugging a rule' which differentiates it from find_code, find_code_by_rule, and test_match_code_rule.

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 ('Call it when debugging a rule') and offers clear alternatives for different debugging scenarios with the format parameter (use format=cst for debugging target code, use format=pattern for debugging pattern rule). This gives the agent specific decision criteria for tool selection.

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/ast-grep/ast-grep-mcp'

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