find-tools-in-server
Search for tools by name or description in an MCP server using regex patterns. Specify server name, pattern, and search scope for precise results.
Instructions
Find tools matching a pattern in a specific MCP server (returns name and description only)
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 |
| serverName | Yes | Name of the MCP server to search tools in |
Implementation Reference
- src/index.ts:254-282 (handler)The handler function for the "find-tools-in-server" tool. Extracts arguments, invokes serverManager.findToolsInServer, formats the results as JSON text content, or returns an error message.async (args, extra) => { try { const { serverName, pattern, searchIn, caseSensitive } = args; const results = await serverManager.findToolsInServer( serverName, pattern, searchIn, caseSensitive ); return { content: [ { type: "text", text: JSON.stringify({ tools: results }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error finding tools in server '${args.serverName}': ${(error as Error).message}`, }, ], }; } }
- src/server-manager.ts:279-306 (helper)Supporting method in McpServerManager that performs the actual tool filtering logic: lists tools from the server client, applies regex filtering based on pattern, searchIn, and caseSensitive options, returns array of matching {name, description}.async findToolsInServer( serverName: string, pattern: string, searchIn: "name" | "description" | "both" = "both", caseSensitive: boolean = false ): Promise<any[]> { const client = this.getClient(serverName); const toolsResponse = await client.listTools(); if (!toolsResponse.tools || !Array.isArray(toolsResponse.tools)) { return []; } const flags = caseSensitive ? "g" : "gi"; const regex = new RegExp(pattern, flags); 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; }); // Filter to only include name and description return matchedTools.map((tool: any) => ({ name: tool.name, description: tool.description, })); }
- src/types.ts:106-121 (schema)Zod schema defining the input parameters (serverName, pattern, searchIn, caseSensitive) and their descriptions for the "find-tools-in-server" tool.export const FindToolsInServerParamsSchema = z.object({ serverName: z .string() .describe("Name of the MCP server to search tools in"), pattern: z .string() .describe("Regex pattern to search for in tool names and descriptions"), searchIn: z .enum(["name", "description", "both"]) .default("both") .describe("Where to search: in tool names, descriptions, or both"), caseSensitive: z .boolean() .default(false) .describe("Whether the search should be case-sensitive"), });
- src/index.ts:245-283 (registration)Registers the "find-tools-in-server" tool with the MCP server, providing name, description, Zod-derived parameter schema, and the handler function.server.tool( "find-tools-in-server", "Find tools matching a pattern in a specific MCP server (returns name and description only)", { serverName: FindToolsInServerParamsSchema.shape.serverName, pattern: FindToolsInServerParamsSchema.shape.pattern, searchIn: FindToolsInServerParamsSchema.shape.searchIn, caseSensitive: FindToolsInServerParamsSchema.shape.caseSensitive, }, async (args, extra) => { try { const { serverName, pattern, searchIn, caseSensitive } = args; const results = await serverManager.findToolsInServer( serverName, pattern, searchIn, caseSensitive ); return { content: [ { type: "text", text: JSON.stringify({ tools: results }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error finding tools in server '${args.serverName}': ${(error as Error).message}`, }, ], }; } } );