@@ -132,7 +132,7 @@ const MoveFileArgsSchema = z.object({
132132
133133const SearchFilesArgsSchema = z . object ( {
134134 path : z . string ( ) ,
135- pattern : z . string ( ) ,
135+ patterns : z . array ( z . string ( ) ) ,
136136 excludePatterns : z . array ( z . string ( ) ) . optional ( ) . default ( [ ] )
137137} ) ;
138138
@@ -261,6 +261,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
261261 "Get a recursive tree view of files and directories as a JSON structure. " +
262262 "Each entry includes 'name', 'type' (file/directory), and 'children' for directories. " +
263263 "Files have no children array, while directories always have a children array (which may be empty). " +
264+ "Supports excluding paths using glob patterns (e.g., ['node_modules', '**/*.log', '.git']). " +
264265 "The output is formatted with 2-space indentation for readability. Only works within allowed directories." ,
265266 inputSchema : zodToJsonSchema ( DirectoryTreeArgsSchema ) as ToolInput ,
266267 } ,
@@ -276,9 +277,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
276277 {
277278 name : "search_files" ,
278279 description :
279- "Recursively search for files and directories matching a pattern. " +
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. " +
280+ "Recursively search for files and directories matching glob patterns. " +
281+ "The patterns should be glob-style patterns that match paths relative to the search path. " +
282+ "Use patterns like ['*.ext'] to match files in current directory, and ['**/*.ext'] to match files in all subdirectories. " +
283+ "Multiple patterns can be provided to match different file types, e.g., ['**/*.js', '**/*.ts']. " +
282284 "Returns full paths to all matching items. Great for finding files when you don't know their exact location. " +
283285 "Only searches within allowed directories." ,
284286 inputSchema : zodToJsonSchema ( SearchFilesArgsSchema ) as ToolInput ,
@@ -539,16 +541,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
539541
540542 for ( const entry of entries ) {
541543 const relativePath = path . relative ( rootPath , path . join ( currentPath , entry . name ) ) ;
542- const shouldExclude = excludePatterns . some ( pattern => {
543- if ( pattern . includes ( '*' ) ) {
544- return minimatch ( relativePath , pattern , { dot : true } ) ;
545- }
546- // For files: match exact name or as part of path
547- // For directories: match as directory path
548- return minimatch ( relativePath , pattern , { dot : true } ) ||
549- minimatch ( relativePath , `**/${ pattern } ` , { dot : true } ) ||
550- minimatch ( relativePath , `**/${ pattern } /**` , { dot : true } ) ;
551- } ) ;
544+ // Use glob matching exclusively for consistency
545+ const shouldExclude = excludePatterns . some ( pattern =>
546+ minimatch ( relativePath , pattern , { dot : true } )
547+ ) ;
552548 if ( shouldExclude )
553549 continue ;
554550
@@ -596,7 +592,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
596592 throw new Error ( `Invalid arguments for search_files: ${ parsed . error } ` ) ;
597593 }
598594 const validPath = await validatePath ( parsed . data . path ) ;
599- const results = await searchFilesWithValidation ( validPath , parsed . data . pattern , allowedDirectories , { excludePatterns : parsed . data . excludePatterns } ) ;
595+ const results = await searchFilesWithValidation ( validPath , parsed . data . patterns , allowedDirectories , { excludePatterns : parsed . data . excludePatterns } ) ;
600596 return {
601597 content : [ { type : "text" , text : results . length > 0 ? results . join ( "\n" ) : "No matches found" } ] ,
602598 } ;
0 commit comments