treesitter-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| treesitter_analyze_fileA | Analyze a source code file and extract symbols (functions, classes, etc.). Args: file_path: Path to the source code file to analyze (supports .py, .c, .cpp, .h, .hpp) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - file_path: The analyzed file path - language: Detected programming language - symbols: List of extracted symbols (functions, classes, etc.) - errors: Any parsing errors encountered OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} Note: This function does not return the full AST to avoid serialization issues. Use treesitter_get_ast() if you need the complete AST. |
| treesitter_get_call_graphA | Generate a call graph showing function calls and their relationships. Args: file_path: Path to the source code file output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - nodes: List of CallGraphNode objects, each with: - name: Function name - location: Source location (start/end points) - calls: List of function names called by this function OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_find_functionA | Search for a specific function definition by name. Args: file_path: Path to the source code file name: Name of the function to find include_source: If True, includes the source code for each matched function. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - query: The search query (function name) - matches: List of Symbol objects representing matching function definitions. If include_source is True, each match includes a "source" field. OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_find_variableA | Search for variable declarations and usages by name. Args: file_path: Path to the source code file name: Name of the variable to find include_source: If True, includes the source code for each matched variable. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - query: The search query (variable name) - matches: List of Symbol objects representing variable declarations and usages. If include_source is True, each match includes a "source" field. OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_get_supported_languagesA | Get a list of programming languages supported by the analyzer. Args: output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: List of supported language names (e.g., ['python', 'c', 'cpp']) OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_get_astA | 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} |
| treesitter_get_node_at_pointA | Return the AST node covering a specific point (row, column). Args: file_path: Path to the source code file row: Row number (0-based) column: Column number (0-based) max_depth: Maximum depth of the AST to return. 0 for just the node. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: AST node as dictionary OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_get_node_for_rangeA | Return the smallest AST node covering a point range. Args: file_path: Path to the source code file start_row: Starting row (0-based) start_column: Starting column (0-based) end_row: Ending row (0-based) end_column: Ending column (0-based) max_depth: Maximum depth of the AST to return. 0 for just the node. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: AST node as dictionary OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_cursor_walkA | Return a cursor-style view (focus node + context) at a point. Args: file_path: Path to the source code file row: Row number (0-based) column: Column number (0-based) max_depth: Maximum depth of the AST to return. output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary with focus, ancestors, siblings, and children OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_get_source_for_rangeA | Extract the source code text for a given line/column range. Args: file_path: Path to the source code file start_row: Starting line number (0-based) start_column: Starting column number (0-based) end_row: Ending line number (0-based) end_column: Ending column number (0-based) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - file_path: The analyzed file path - range: The requested range - source: The extracted source code text OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_run_queryA | Execute a custom Tree-sitter query against a source file. Args: query: Tree-sitter query string in S-expression format file_path: Path to the source code file language: Optional language override (auto-detected from file extension if not provided) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Query results as a dictionary or list, depending on the query structure OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_find_usageA | Find all usages/references of a symbol (identifier) in a source file. Args: name: Symbol name to search for file_path: Path to the source code file language: Optional language override (auto-detected from file extension if not provided) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: Dictionary containing: - query: The search query (symbol name) - matches: List of Symbol objects representing all usages of the symbol OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
| treesitter_get_dependenciesA | Extract all dependencies (imports/includes) from a source file. Args: file_path: Path to the source code file output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload. Returns: List of dependency strings: - For Python: import module names - For C/C++: included file paths (without quotes/brackets) OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N} |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 13 tools
get_node_for_range and get_node_at_point are nearly identical since a point is a zero-length range. find_function, find_variable, and find_usage all search by symbol name and return Symbol objects, differing only in the type of symbol. cursor_walk also provides node context at a point, overlapping with get_node_at_point, making boundaries unclear.
All tools follow a consistent treesitter_ prefix with snake_case and a verb-object structure (get_, find_, run_, analyze_). The only minor deviation is cursor_walk, which inverts the typical verb-object order but remains clear and easy to parse.
13 tools is well within the ideal range for a code analysis server. Each tool addresses a distinct aspect of Tree-sitter functionality (AST, queries, symbols, dependencies, call graph) without bloat or excessive redundancy.
The server covers core workflows: AST inspection, query execution, symbol lookup, dependency extraction, call graph generation, and language support. Minor gaps include a unified symbol search (function and variable tools could be merged) and a more direct node navigation tool, though cursor_walk partially fills that need.