Skip to content

Commit 63c4f3a

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 4b6ce39 commit 63c4f3a

2 files changed

Lines changed: 415 additions & 49 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

@@ -130,14 +131,27 @@ The server's directory access control follows this flow:
130131
- `destination` (string)
131132
- Fails if destination exists
132133

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

142156
- **get_file_info**
143157
- Get detailed file/directory metadata

0 commit comments

Comments
 (0)