@@ -22,7 +22,7 @@ def dump_syntax_tree(
22
22
"""
23
23
Dump code's syntax structure or dump a query's pattern structure.
24
24
This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule.
25
- The tool requires three argument : code, language and format. The first two are self-explanatory.
25
+ The tool requires three arguments : code, language and format. The first two are self-explanatory.
26
26
`format` is the output format of the syntax tree.
27
27
use `format=cst` to inspect the code's concrete syntax tree structure, useful to debug target code.
28
28
use `format=pattern` to inspect how ast-grep interprets a pattern, useful to debug pattern rule.
@@ -59,7 +59,7 @@ def test_match_code_rule(
59
59
@mcp .tool ()
60
60
def find_code (
61
61
project_folder : str = Field (description = "The absolute path to the project folder. It must be absolute path." ),
62
- pattern : str = Field (description = "The ast-grep pattern to search for. Note the pattern must has valid AST structure." ),
62
+ pattern : str = Field (description = "The ast-grep pattern to search for. Note, the pattern must have valid AST structure." ),
63
63
language : str = Field (description = "The language of the query" , default = "" ),
64
64
) -> List [dict [str , Any ]]:
65
65
"""
@@ -71,13 +71,15 @@ def find_code(
71
71
72
72
@mcp .tool ()
73
73
def find_code_by_rule (
74
- project_folder : str = Field (description = "The path to the project folder" ),
74
+ project_folder : str = Field (description = "The absolute path to the project folder. It must be absolute path. " ),
75
75
yaml : str = Field (description = "The ast-grep YAML rule to search. It must have id, language, rule fields." ),
76
76
) -> List [dict [str , Any ]]:
77
77
"""
78
78
Find code using ast-grep's YAML rule in a project folder.
79
79
YAML rule is more powerful than simple pattern and can perform complex search like find AST inside/having another AST.
80
80
It is a more advanced search tool than the simple `find_code`.
81
+
82
+ Tip: When using relational rules (inside/has), add `stopBy: end` to ensure complete traversal.
81
83
"""
82
84
return run_ast_grep_yaml (yaml , project_folder )
83
85
0 commit comments