mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 08:03:26 +02:00
feat: add search_files handler with excludePatterns support
This commit is contained in:
@@ -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" }],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user