Skip to content

Commit fb5ad1d

Browse files
- Rename "search_files" to search_files_by_name.
- Add new "search_file_contents" function. - Add descriptions to help the LLM understand the fields. - Support single file search. - Support glob pattern for search by file name. - Rename 'pattern' argument to 'searchText'. Sometimes the name 'pattern' caused Claude to pass a regex even though it was processed as a simple substring match. - Add unit tests.
1 parent 60eb7c2 commit fb5ad1d

4 files changed

Lines changed: 997 additions & 52 deletions

File tree

src/filesystem/README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
77
- Read/write files
88
- Create/list/delete directories
99
- Move files/directories
10-
- Search files
10+
- Search for files by name
11+
- Search within file contents (grep-like functionality)
1112
- Get file metadata
1213
- Dynamic directory access control via [Roots](https://modelcontextprotocol.io/docs/learn/client-concepts#roots)
1314

@@ -144,14 +145,27 @@ The server's directory access control follows this flow:
144145
- `destination` (string)
145146
- Fails if destination exists
146147

147-
- **search_files**
148-
- Recursively search for files/directories
148+
- **search_files_by_name**
149+
- Find files and directories whose names match a pattern
149150
- Inputs:
150151
- `path` (string): Starting directory
151-
- `pattern` (string): Search pattern
152+
- `pattern` (string): Name pattern to match
152153
- `excludePatterns` (string[]): Exclude any patterns. Glob formats are supported.
153154
- Case-insensitive matching
154-
- Returns full paths to matches
155+
- Returns full paths to matching files/directories
156+
157+
- **search_file_contents**
158+
- Search for text patterns within file contents (similar to grep)
159+
- Inputs:
160+
- `path` (string): Starting directory or specific file
161+
- `searchText` (string): Text to search for - supports plain text substring matching or regex if useRegex is true
162+
- `useRegex` (boolean): Whether to interpret searchText as a regular expression (default: false)
163+
- `caseSensitive` (boolean): Enable case-sensitive search (default: false)
164+
- `maxResults` (number): Maximum number of results to return (default: 100)
165+
- `contextLines` (number): Number of context lines to show around matches (default: 2)
166+
- `includePatterns` (string[]): Glob patterns for paths to include in search (e.g., ["**/*.js", "**/*.ts"])
167+
- `excludePatterns` (string[]): Glob patterns for paths to exclude from search (e.g., ["node_modules/**", "*.test.ts"])
168+
- Returns matching files with line numbers, matched text, and context
155169

156170
- **get_file_info**
157171
- Get detailed file/directory metadata

0 commit comments

Comments
 (0)