Skip to content

Commit 4d210d2

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 c8fe7d9 commit 4d210d2

File tree

4 files changed

+995
-50
lines changed

4 files changed

+995
-50
lines changed

src/filesystem/README.md

Lines changed: 19 additions & 4 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,28 @@ The server's directory access control follows this flow:
144145
- `destination` (string)
145146
- Fails if destination exists
146147

147-
- **search_files**
148+
- **search_files_by_name**
148149
- Recursively search for files/directories that match or do not match patterns
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.
153154
- Glob-style pattern matching
154-
- Returns full paths to matches
155+
- Case-insensitive matching
156+
- Returns full paths to matching files/directories
157+
158+
- **search_file_contents**
159+
- Search for text patterns within file contents (similar to grep)
160+
- Inputs:
161+
- `path` (string): Starting directory or specific file
162+
- `searchText` (string): Text to search for - supports plain text substring matching or regex if useRegex is true
163+
- `useRegex` (boolean): Whether to interpret searchText as a regular expression (default: false)
164+
- `caseSensitive` (boolean): Enable case-sensitive search (default: false)
165+
- `maxResults` (number): Maximum number of results to return (default: 100)
166+
- `contextLines` (number): Number of context lines to show around matches (default: 2)
167+
- `includePatterns` (string[]): Glob patterns for paths to include in search (e.g., ["**/*.js", "**/*.ts"])
168+
- `excludePatterns` (string[]): Glob patterns for paths to exclude from search (e.g., ["node_modules/**", "*.test.ts"])
169+
- Returns matching files with line numbers, matched text, and context
155170

156171
- **directory_tree**
157172
- Get recursive JSON tree structure of directory contents

0 commit comments

Comments
 (0)