Skip to main content
Glama

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
NameRequiredDescriptionDefault
caseSensitiveNoWhether the search should be case-sensitive
patternYesRegex pattern to search for in tool names and descriptions
searchInNoWhere to search: in tool names, descriptions, or bothboth
serverNameYesName of the MCP server to search tools in

Implementation Reference

  • 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}`,
            },
          ],
        };
      }
    }
  • 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,
      }));
    }
  • 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}`,
              },
            ],
          };
        }
      }
    );
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/warpdev/mcp-hub-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server