searchGlob
Find files matching a specific pattern within directories to locate code, documents, or resources using glob matching syntax.
Instructions
Search for files matching a pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | The glob pattern to match files against | |
| path | No | The directory to search in. Defaults to the current working directory. |
Implementation Reference
- src/utils/file.ts:70-80 (handler)Core implementation of the searchGlob tool. Uses the 'find' shell command to locate files matching the given pattern in the specified path.
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; } } - src/server/tools.ts:110-113 (schema)Zod input schema defining parameters for the searchGlob tool: pattern (required string) and path (optional string).
{ 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.") }, - src/server/tools.ts:108-130 (registration)Registration of the searchGlob tool on the MCP server using server.tool(), including description, input schema, and thin wrapper handler that calls the core searchGlob function.
"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 }; } } );