File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,12 +145,12 @@ The server's directory access control follows this flow:
145145 - Fails if destination exists
146146
147147- ** search_files**
148- - Recursively search for files/directories
148+ - Recursively search for files/directories that match or do not match patterns
149149 - Inputs:
150150 - ` path ` (string): Starting directory
151151 - ` pattern ` (string): Search pattern
152- - ` excludePatterns ` (string[ ] ): Exclude any patterns. Glob formats are supported.
153- - Case-insensitive matching
152+ - ` excludePatterns ` (string[ ] ): Exclude any patterns.
153+ - Glob-style pattern matching
154154 - Returns full paths to matches
155155
156156- ** directory_tree**
Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ describe('Lib Functions', () => {
316316
317317 const result = await searchFilesWithValidation (
318318 testDir ,
319- 'test' ,
319+ '* test* ' ,
320320 allowedDirs ,
321321 { excludePatterns : [ '*.log' , 'node_modules' ] }
322322 ) ;
@@ -346,7 +346,7 @@ describe('Lib Functions', () => {
346346
347347 const result = await searchFilesWithValidation (
348348 testDir ,
349- 'test' ,
349+ '* test* ' ,
350350 allowedDirs ,
351351 { }
352352 ) ;
@@ -370,7 +370,7 @@ describe('Lib Functions', () => {
370370
371371 const result = await searchFilesWithValidation (
372372 testDir ,
373- 'test' ,
373+ '* test* ' ,
374374 allowedDirs ,
375375 { excludePatterns : [ '*.backup' ] }
376376 ) ;
Original file line number Diff line number Diff line change @@ -277,9 +277,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
277277 name : "search_files" ,
278278 description :
279279 "Recursively search for files and directories matching a pattern. " +
280- "Searches through all subdirectories from the starting path. The search " +
281- "is case-insensitive and matches partial names. Returns full paths to all " +
282- "matching items. Great for finding files when you don't know their exact location. " +
280+ "The patterns should be glob-style patterns that match paths relative to the working directory. " +
281+ "Use pattern like '*.ext' to match files in current directory, and '**/*.ext' to match files in all subdirectories. " +
282+ "Returns full paths to all matching items. Great for finding files when you don't know their exact location. " +
283283 "Only searches within allowed directories." ,
284284 inputSchema : zodToJsonSchema ( SearchFilesArgsSchema ) as ToolInput ,
285285 } ,
Original file line number Diff line number Diff line change @@ -367,14 +367,14 @@ export async function searchFilesWithValidation(
367367 await validatePath ( fullPath ) ;
368368
369369 const relativePath = path . relative ( rootPath , fullPath ) ;
370- const shouldExclude = excludePatterns . some ( excludePattern => {
371- const globPattern = excludePattern . includes ( '*' ) ? excludePattern : `**/${ excludePattern } /**` ;
372- return minimatch ( relativePath , globPattern , { dot : true } ) ;
373- } ) ;
370+ const shouldExclude = excludePatterns . some ( excludePattern =>
371+ minimatch ( relativePath , excludePattern , { dot : true } )
372+ ) ;
374373
375374 if ( shouldExclude ) continue ;
376375
377- if ( entry . name . toLowerCase ( ) . includes ( pattern . toLowerCase ( ) ) ) {
376+ // Use glob matching for the search pattern
377+ if ( minimatch ( relativePath , pattern , { dot : true } ) ) {
378378 results . push ( fullPath ) ;
379379 }
380380
You can’t perform that action at this time.
0 commit comments