Skip to content

Commit c2f6f9b

Browse files
authored
Add underlying ast-grep commands to MCP tool documentation
This helps MCP clients to better understand the mapping between tool parameters and ast-grep syntax.
1 parent 8b5628c commit c2f6f9b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def dump_syntax_tree(
2626
`format` is the output format of the syntax tree.
2727
use `format=cst` to inspect the code's concrete syntax tree structure, useful to debug target code.
2828
use `format=pattern` to inspect how ast-grep interprets a pattern, useful to debug pattern rule.
29+
30+
Internally calls: ast-grep run --pattern <code> --lang <language> --debug-query=<format>
2931
"""
3032
return run_ast_grep_dump(code, language, format.value)
3133

@@ -38,6 +40,8 @@ def test_match_code_rule(
3840
"""
3941
Test a code against an ast-grep YAML rule.
4042
This is useful to test a rule before using it in a project.
43+
44+
Internally calls: ast-grep scan --inline-rules <yaml> --json --stdin
4145
"""
4246
args = ["ast-grep", "scan","--inline-rules", yaml, "--json", "--stdin"]
4347
try:
@@ -66,6 +70,8 @@ def find_code(
6670
Find code in a project folder that matches the given ast-grep pattern.
6771
Pattern is good for simple and single-AST node result.
6872
For more complex usage, please use YAML by `find_code_by_rule`.
73+
74+
Internally calls: ast-grep run --pattern <pattern> --json <project_folder>
6975
"""
7076
return run_ast_grep_command(pattern, project_folder, language)
7177

@@ -80,6 +86,8 @@ def find_code_by_rule(
8086
It is a more advanced search tool than the simple `find_code`.
8187
8288
Tip: When using relational rules (inside/has), add `stopBy: end` to ensure complete traversal.
89+
90+
Internally calls: ast-grep scan --inline-rules <yaml> --json <project_folder>
8391
"""
8492
return run_ast_grep_yaml(yaml, project_folder)
8593

0 commit comments

Comments
 (0)