Skip to main content
Glama
pwno-io

treesitter-mcp

by pwno-io

treesitter_get_ast

Extract the full Abstract Syntax Tree (AST) from a source file to inspect code structure. Limit depth with max_depth or write large results to an output file.

Instructions

Extract the complete Abstract Syntax Tree (AST) from a source file.

Args: file_path: Path to the source code file max_depth: Maximum depth of the AST to return. -1 for no limit (default). Useful for large files to avoid serialization errors. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload.

Returns: Dictionary representing the AST root node with: - type: Node type (e.g., 'module', 'function_definition') - start_point: Starting position (row, column) - end_point: Ending position (row, column) - children: List of child AST nodes - text: Optional text content - id: Optional node identifier OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
max_depthNo
output_fileNo
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 clearly explains the return format (dictionary with type, start_point, end_point, children) and the alternative behavior when output_file is set (writes to file and returns a status dictionary). It also hints at potential issues like serialization errors. However, it does not explicitly state whether the tool is read-only or discuss side effects, though it is implied by 'Extract'.

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 well-organized with a clear opening sentence, an Args section, and a Returns section. Every sentence provides value: the main purpose, parameter details, and return structure. It is concise given the amount of information needed and front-loads the primary action.

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?

For a tool with 3 parameters and no output schema, the description covers all necessary aspects: what the tool does, each parameter's role, return values, and edge-case behavior (output_file). It even notes practical limitations for large files. There are no significant gaps, making it highly complete for the tool's complexity.

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 description coverage is 0%, but the description compensates fully by explaining each parameter: file_path is 'Path to the source code file', max_depth is 'Maximum depth of the AST to return. -1 for no limit' with practical advice, and output_file is 'If provided, writes result to this file instead of returning' with rationale. This adds substantial meaning beyond the bare 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?

The description uses a specific verb and resource: 'Extract the complete Abstract Syntax Tree (AST) from a source file.' This clearly states the tool's function and distinguishes it from siblings like treesitter_get_node_for_range (which targets specific nodes) and treesitter_get_source_for_range (which retrieves source text).

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 provides clear usage context for parameters, e.g., 'max_depth' is 'Useful for large files to avoid serialization errors' and 'output_file' is 'Useful for large outputs to prevent context overload.' It implies when to use these options, though it does not explicitly compare to alternative sibling tools or state when not to use the tool.

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/pwno-io/treesitter-mcp'

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