Skip to main content
Glama
Search Code MCP

Search Code MCP

by joutvhu

Inspect Syntax Tree

dump_tree
Read-onlyIdempotent

Inspect Tree-sitter syntax trees for short code snippets or ast-grep patterns before writing AST rules, and debug why patterns fail to match.

Instructions

Inspect the Tree-sitter syntax tree of a short code snippet or pattern via ast-grep. Call this BEFORE writing 'ast_rule' YAML queries (use format='ast' to discover exact node 'kind' names) or when debugging why an 'ast' pattern didn't match (use format='pattern').

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>",
      "language": "<language>"
    },
    "name": "dump_tree"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesShort representative code snippet (2-5 lines) or an ast-grep pattern (when format='pattern') to inspect.
formatNoTree format: 'ast' (default, named AST nodes only—best for finding 'kind:' names for ast_rule), 'cst' (full concrete syntax tree with punctuation), 'pattern' (shows how ast-grep parses your pattern with $VAR/$$$).ast
languageYesTree-sitter language name, e.g. 'typescript', 'tsx', 'javascript', 'python', 'rust', 'go', 'java'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv1.1.0
    • changedInput schema / properties / code / description
      Previous value: -"Code snippet or query pattern to inspect"New value: +"Short representative code snippet (2-5 lines) or an ast-grep pattern (when format='pattern') to inspect."
    • changedInput schema / properties / format / default
      Previous value: -"cst"New value: +"ast"
    • changedInput schema / properties / format / description
      Previous value: -"Tree dump format: 'cst' (concrete syntax tree), 'ast', or 'pattern'"New value: +"Tree format: 'ast' (default, named AST nodes only—best for finding 'kind:' names for ast_rule), 'cst' (full concrete syntax tree with punctuation), 'pattern' (shows how ast-grep parses your pattern with $VAR/$$$)."
    • changedInput schema / properties / language / description
      Previous value: -"Programming language of the code (e.g. 'typescript', 'python', 'rust')"New value: +"Tree-sitter language name, e.g. 'typescript', 'tsx', 'javascript', 'python', 'rust', 'go', 'java'."
  2. First observedv1.0.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true and destructiveHint=false, so safety is covered. The description adds useful behavioral context the annotations cannot: input should be short (2-5 lines), and the output is a parsed tree used for discovering node kind names or pattern parsing behavior, which is the real value of calling it.

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?

Two sentences with the core purpose front-loaded, followed by the workflow trigger. No filler, and the parenthetical format hints are packed efficiently without breaking readability.

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 three-parameter, read-only inspection tool with full schema coverage and no output schema, the description covers purpose, timing and parameter selection adequately. The only minor gap is that it does not say what the returned tree looks like (text tree, node paths), though that is largely self-evident from 'tree dump'.

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?

Schema coverage is 100%, so the baseline is 3, but the description ties parameter choices to concrete goals — format='ast' for finding kind names, format='pattern' for debugging matches, and a snippet length expectation for `code`. That goal-oriented framing adds meaning beyond the enum's own description, though the language list is left to the schema.

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?

States a specific verb and resource (inspect the Tree-sitter syntax tree) with the underlying engine named (ast-grep), which cleanly separates it from siblings like search, count, find_symbols and replace. An agent immediately understands this is a read-only structural inspector, not a matcher or rewriter.

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?

Gives explicit when-to-use triggers: call it BEFORE writing ast_rule YAML, and call it when debugging why an ast pattern failed to match. It even routes the format parameter per scenario (format='ast' to discover kind names, format='pattern' to debug patterns), leaving nothing to inference.

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

Deploy Server

Other Tools