|
10 | 10 | @mcp.tool() |
11 | 11 | def find_code( |
12 | 12 | project_folder: str = Field(description="The path to the project folder"), |
13 | | - pattern: str = Field(description="The ast-grep pattern to search for"), |
| 13 | + pattern: str = Field(description="The ast-grep pattern to search for. Note the pattern must has valid AST structure."), |
14 | 14 | language: str = Field(description="The language of the query", default=""), |
15 | 15 | ) -> List[dict[str, Any]]: |
16 | | - """Find code in a project folder that matches the given ast-grep pattern""" |
| 16 | + """ |
| 17 | + Find code in a project folder that matches the given ast-grep pattern. |
| 18 | + Pattern is good for simple and single-AST node result. |
| 19 | + For more complex usage, please use YAML by `find_code_by_rule`. |
| 20 | + """ |
17 | 21 | return run_ast_grep_command(pattern, project_folder, language) |
18 | 22 |
|
19 | 23 | @mcp.tool() |
20 | 24 | def find_code_by_rule( |
21 | 25 | project_folder: str = Field(description="The path to the project folder"), |
22 | | - yaml: str = Field(description="The ast-grep pattern to search for"), |
| 26 | + yaml: str = Field(description="The ast-grep YAML rule to search. It must have id, language, rule fields."), |
23 | 27 | ) -> List[dict[str, Any]]: |
24 | | - """Find code using ast-grep's YAML rule in a project folder""" |
| 28 | + """ |
| 29 | + Find code using ast-grep's YAML rule in a project folder. |
| 30 | + YAML rule is more powerful than simple pattern and can perform complex search like find AST inside/having another AST. |
| 31 | + It is a more advanced search tool than the simple `find_code`. |
| 32 | + """ |
25 | 33 | return run_ast_grep_yaml(yaml, project_folder) |
26 | 34 |
|
27 | 35 | def run_ast_grep_command(pattern: str, project_folder: str, language: Optional[str]) -> List[dict[str, Any]]: |
|
0 commit comments