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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| max_depth | No | ||
| output_file | No |