AST structural search
ast_searchRun tree-sitter queries against source files to locate AST captures with line numbers, enabling structural pattern matching beyond grep.
Instructions
Run a tree-sitter query (S-expression pattern) against a source file and return captures with line numbers. Use for AST-shaped matching that Grep cannot express.
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": "<file>",
"pattern": "<pattern>"
},
"name": "ast_search"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | file path | |
| limit | No | max captures returned (default 50, hard max 200) | |
| offset | No | skip the first N captures before applying limit | |
| pattern | Yes | tree-sitter query pattern, e.g. (method_invocation name: (identifier) @m) | |
| language | No | override language inference |