treesitter_find_variable
Find variable declarations and usages by name in source code. Locate every reference, with optional source snippets, to analyze or debug quickly.
Instructions
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}
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": {
"file_path": "<file_path>",
"name": "<name>"
},
"name": "treesitter_find_variable"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| file_path | Yes | ||
| output_file | No | ||
| include_source | No |