Skip to content

Commit a7bb012

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 d624316 commit a7bb012

File tree

2 files changed

+456
-90
lines changed

2 files changed

+456
-90
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

1314
**Note**: The server will only allow operations within directories specified via `args`.
@@ -71,14 +72,27 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
7172
- `destination` (string)
7273
- Fails if destination exists
7374

74-
- **search_files**
75-
- Recursively search for files/directories
75+
- **search_files_by_name**
76+
- Find files and directories whose names match a pattern
7677
- Inputs:
7778
- `path` (string): Starting directory
78-
- `pattern` (string): Search pattern
79+
- `pattern` (string): Name pattern to match
7980
- `excludePatterns` (string[]): Exclude any patterns. Glob formats are supported.
8081
- Case-insensitive matching
81-
- Returns full paths to matches
82+
- Returns full paths to matching files/directories
83+
84+
- **search_file_contents**
85+
- Search for text patterns within file contents (similar to grep)
86+
- Inputs:
87+
- `path` (string): Starting directory or specific file
88+
- `searchText` (string): Text to search for - supports plain text substring matching or regex if useRegex is true
89+
- `useRegex` (boolean): Whether to interpret searchText as a regular expression (default: false)
90+
- `caseSensitive` (boolean): Enable case-sensitive search (default: false)
91+
- `maxResults` (number): Maximum number of results to return (default: 100)
92+
- `contextLines` (number): Number of context lines to show around matches (default: 2)
93+
- `includePatterns` (string[]): Glob patterns for paths to include in search (e.g., ["**/*.js", "**/*.ts"])
94+
- `excludePatterns` (string[]): Glob patterns for paths to exclude from search (e.g., ["node_modules/**", "*.test.ts"])
95+
- Returns matching files with line numbers, matched text, and context
8296

8397
- **get_file_info**
8498
- Get detailed file/directory metadata

0 commit comments

Comments
 (0)