You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Motivation
<!-- Why is this change necessary? -->
# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review
- [ x] I have added tests for my changes
- [ x] I have updated the documentation or added new documentation as
needed
---------
Co-authored-by: kopekC <[email protected]>
query: str=Field(..., description="The search query, passed into python's re.match()")
114
+
query: str=Field(
115
+
...,
116
+
description="The search query to find in the codebase. When ripgrep is available, this will be passed as a ripgrep pattern. For regex searches, set use_regex=True. Ripgrep is the preferred method.",
117
+
)
115
118
target_directories: Optional[list[str]] =Field(default=None, description="Optional list of directories to search in")
119
+
file_extensions: Optional[list[str]] =Field(default=None, description="Optional list of file extensions to search (e.g. ['.py', '.ts'])")
120
+
page: int=Field(default=1, description="Page number to return (1-based, default: 1)")
121
+
files_per_page: int=Field(default=10, description="Number of files to return per page (default: 10)")
122
+
use_regex: bool=Field(default=False, description="Whether to treat query as a regex pattern (default: False)")
116
123
117
124
118
125
classSearchTool(BaseTool):
119
126
"""Tool for searching the codebase."""
120
127
121
128
name: ClassVar[str] ="search"
122
-
description: ClassVar[str] ="Search the codebase using text search"
129
+
description: ClassVar[str] ="Search the codebase using text search or regex pattern matching"
Copy file name to clipboardExpand all lines: src/codegen/extensions/mcp/codebase_tools.py
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -37,16 +37,19 @@ def reveal_symbol_tool(
37
37
returnjson.dumps(result, indent=2)
38
38
39
39
40
-
@mcp.tool(name="search_codebase", description="Search the codebase using text search or regex pattern matching")
40
+
@mcp.tool(name="search_codebase", description="The search query to find in the codebase. When ripgrep is available, this will be passed as a ripgrep pattern. For regex searches, set use_regex=True")
41
41
defsearch_codebase_tool(
42
-
query: str,
43
-
target_directories: Annotated[Optional[list[str]], "list of directories to search within"],
42
+
query: Annotated[str, "The search query to find in the codebase. When ripgrep is available, this will be passed as a ripgrep pattern. For regex searches, set use_regex=True."],
44
43
codebase_dir: Annotated[str, "The root directory of your codebase"],
45
44
codebase_language: Annotated[ProgrammingLanguage, "The language the codebase is written in"],
46
-
use_regex: Annotated[bool, "use regex for the search query"],
45
+
target_directories: Annotated[Optional[list[str]], "list of directories to search within"] =None,
46
+
file_extensions: Annotated[Optional[list[str]], "list of file extensions to search (e.g. ['.py', '.ts'])"] =None,
47
+
page: Annotated[int, "page number to return (1-based)"] =1,
48
+
files_per_page: Annotated[int, "number of files to return per page"] =10,
49
+
use_regex: Annotated[bool, "use regex for the search query"] =False,
0 commit comments