feat: add search_files handler with excludePatterns support

This commit is contained in:
devin-ai-integration[bot]
2024-12-06 21:47:39 +00:00
parent ffd9cb7f53
commit 3cf9a060cd

View File

@@ -163,9 +163,8 @@ const server = new Server(
}, },
{ {
capabilities: { capabilities: {
tools: [ tools: {
{ search_files: {
name: "search_files",
description: "Recursively search for files/directories with optional exclude patterns", description: "Recursively search for files/directories with optional exclude patterns",
inputSchema: zodToJsonSchema(SearchFilesArgsSchema), inputSchema: zodToJsonSchema(SearchFilesArgsSchema),
handler: async (args: z.infer<typeof SearchFilesArgsSchema>) => { handler: async (args: z.infer<typeof SearchFilesArgsSchema>) => {
@@ -173,7 +172,7 @@ const server = new Server(
return searchFiles(validatedPath, args.pattern, args.excludePatterns); return searchFiles(validatedPath, args.pattern, args.excludePatterns);
}, },
}, },
], },
}, },
}, },
); );
@@ -546,7 +545,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
throw new Error(`Invalid arguments for search_files: ${parsed.error}`); throw new Error(`Invalid arguments for search_files: ${parsed.error}`);
} }
const validPath = await validatePath(parsed.data.path); const validPath = await validatePath(parsed.data.path);
const results = await searchFiles(validPath, parsed.data.pattern); const results = await searchFiles(validPath, parsed.data.pattern, parsed.data.excludePatterns);
return { return {
content: [{ type: "text", text: results.length > 0 ? results.join("\n") : "No matches found" }], content: [{ type: "text", text: results.length > 0 ? results.join("\n") : "No matches found" }],
}; };