ast_search
Find code by structure, not text: match syntax-aware patterns with metavariables to locate every call site shaped like a given example, returning file, line, and matched text.
Instructions
Structural code search via ast-grep: match a syntax-aware pattern (metavariables like $X, $$$ARGS) instead of text. Use for 'every call site shaped like this' questions a text grep gets wrong. Returns file/line/matched text.
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": {
"repo": "<repo>",
"pattern": "<pattern>",
"lang": "<lang>"
},
"name": "ast_search"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | Yes | language id: php, python, bash, javascript, typescript, ... | |
| repo | Yes | absolute path to the repo to search | |
| paths | No | restrict to these paths (default repo root) | |
| pattern | Yes | ast-grep pattern, e.g. foo($$$ARGS) |