find-tools
Search for MCP tools using keywords or regex patterns to identify available tools for specific tasks. Filter results by name, description, or both, and toggle case sensitivity.
Instructions
Use this tool to find best tools by searching with keywords or regex patterns. If you don't have a specific tool for a task, this is the best way to discover what tools are available.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caseSensitive | No | Whether the search should be case-sensitive | |
| pattern | Yes | Regex pattern to search for in tool names and descriptions | |
| searchIn | No | Where to search: in tool names, descriptions, or both | both |
Implementation Reference
- src/index.ts:137-175 (registration)Registration of the 'find-tools' tool including description, input schema reference, and handler function.server.tool( "find-tools", `Use this tool to find best tools by searching with keywords or regex patterns. If you don't have a specific tool for a task, this is the best way to discover what tools are available. `, { pattern: FindToolsParamsSchema.shape.pattern, searchIn: FindToolsParamsSchema.shape.searchIn, caseSensitive: FindToolsParamsSchema.shape.caseSensitive, }, async (args, extra) => { try { const { pattern, searchIn, caseSensitive } = args; const results = await serverManager.findTools(pattern, { searchIn, caseSensitive, }); return { content: [ { type: "text", text: JSON.stringify(results, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to find tools: ${(error as Error).message}`, }, ], isError: true, }; } }, );
- src/server-manager.ts:340-392 (handler)Core implementation of tool search logic in McpServerManager.findTools method, which iterates over connected servers, lists their tools, and filters using regex on name/description.async findTools( pattern: string, options: { searchIn?: "name" | "description" | "both"; caseSensitive?: boolean; } = {} ): Promise<Record<string, any[]>> { const { searchIn = "both", caseSensitive = false } = options; const servers = this.getConnectedServers(); if (servers.length === 0) { return {}; } // Create regex pattern let regex: RegExp; try { regex = new RegExp(pattern, caseSensitive ? "" : "i"); } catch (error) { throw new Error(`Invalid regex pattern: ${(error as Error).message}`); } const results: Record<string, any[]> = {}; // Search tools in each server for (const serverName of servers) { try { const toolsResponse = await this.listTools(serverName); if (toolsResponse.tools && Array.isArray(toolsResponse.tools)) { const matchedTools = toolsResponse.tools.filter((tool: any) => { const nameMatch = searchIn !== "description" && tool.name && regex.test(tool.name); const descriptionMatch = searchIn !== "name" && tool.description && regex.test(tool.description); return nameMatch || descriptionMatch; }).map((tool: any) => ({ name: tool.name, description: tool.description, })); if (matchedTools.length > 0) { results[serverName] = matchedTools; } } } catch (error) { // Include error information in results results[serverName] = [{ error: `Failed to search tools: ${(error as Error).message}` }]; } } return results; }
- src/types.ts:63-77 (schema)Zod schema defining the input parameters for the 'find-tools' tool: pattern (string), searchIn (enum), caseSensitive (boolean). Referenced in the tool registration.export const FindToolsParamsSchema = z.object({ pattern: z .string() .describe("Regex pattern to search for in tool names and descriptions"), searchIn: z .enum(["name", "description", "both"]) .optional() .default("both") .describe("Where to search: in tool names, descriptions, or both"), caseSensitive: z .boolean() .optional() .default(false) .describe("Whether the search should be case-sensitive"), });