Skip to main content
Glama

searchGlob

Locate files in a directory by matching a specific glob pattern. Specify the pattern and path to streamline file searches efficiently.

Instructions

Search for files matching a pattern

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoThe directory to search in. Defaults to the current working directory.
patternYesThe glob pattern to match files against

Implementation Reference

  • The core implementation of searchGlob, which uses the Unix 'find' command to locate files matching the given pattern.
    export async function searchGlob( pattern: string, searchPath: string = process.cwd() ): Promise<string[]> { try { const { stdout } = await execPromise(`find ${searchPath} -type f -name "${pattern}" | sort`); return stdout.trim().split('\n').filter(Boolean); } catch (error) { throw error; } }
  • Registers the MCP tool 'searchGlob' with input schema validation using Zod and a handler that delegates to the core searchGlob function.
    server.tool( "searchGlob", "Search for files matching a pattern", { pattern: z.string().describe("The glob pattern to match files against"), path: z.string().optional().describe("The directory to search in. Defaults to the current working directory.") }, async ({ pattern, path }) => { try { const results = await searchGlob(pattern, path); return { content: [{ type: "text", text: results.join('\n') }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: true }; } } );
  • Input schema for the searchGlob tool using Zod for validation.
    pattern: z.string().describe("The glob pattern to match files against"), path: z.string().optional().describe("The directory to search in. Defaults to the current working directory.") },

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/auchenberg/claude-code-mcp'

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