Skip to content

Commit efc5368

Browse files
Confusing search_files function description leads to misunderstanding of its purpose.
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.
1 parent 503202b commit efc5368

File tree

2 files changed

+415
-49
lines changed

2 files changed

+415
-49
lines changed

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/concepts/roots)
1314

@@ -121,14 +122,27 @@ The server's directory access control follows this flow:
121122
- `destination` (string)
122123
- Fails if destination exists
123124

124-
- **search_files**
125-
- Recursively search for files/directories
125+
- **search_files_by_name**
126+
- Find files and directories whose names match a pattern
126127
- Inputs:
127128
- `path` (string): Starting directory
128-
- `pattern` (string): Search pattern
129+
- `pattern` (string): Name pattern to match
129130
- `excludePatterns` (string[]): Exclude any patterns. Glob formats are supported.
130131
- Case-insensitive matching
131-
- Returns full paths to matches
132+
- Returns full paths to matching files/directories
133+
134+
- **search_file_contents**
135+
- Search for text patterns within file contents (similar to grep)
136+
- Inputs:
137+
- `path` (string): Starting directory or specific file
138+
- `searchText` (string): Text to search for - supports plain text substring matching or regex if useRegex is true
139+
- `useRegex` (boolean): Whether to interpret searchText as a regular expression (default: false)
140+
- `caseSensitive` (boolean): Enable case-sensitive search (default: false)
141+
- `maxResults` (number): Maximum number of results to return (default: 100)
142+
- `contextLines` (number): Number of context lines to show around matches (default: 2)
143+
- `includePatterns` (string[]): Glob patterns for paths to include in search (e.g., ["**/*.js", "**/*.ts"])
144+
- `excludePatterns` (string[]): Glob patterns for paths to exclude from search (e.g., ["node_modules/**", "*.test.ts"])
145+
- Returns matching files with line numbers, matched text, and context
132146

133147
- **get_file_info**
134148
- Get detailed file/directory metadata

0 commit comments

Comments
 (0)