Skip to main content
Glama
ai-yliu

Filesystem MCP Server

by ai-yliu

search_files

Recursively locate files or directories by specifying a starting path and a case-insensitive search pattern, enabling precise navigation and discovery within allowed filesystem paths.

Instructions

Recursively search for files/directories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesStarting directory for search
patternYesSearch pattern (case-insensitive)

Implementation Reference

  • Handler for the 'search_files' tool. Recursively searches the directory starting from the given path for entries matching the pattern (case-insensitive RegExp on name), collects full paths of matches, and returns them as newline-separated text content.
    case 'search_files': { const { path: dirPath, pattern } = request.params.arguments as { path: string; pattern: string }; validatePath(dirPath); const results: string[] = []; const patternRegex = new RegExp(pattern, 'i'); async function searchDirectory(currentPath: string) { const entries = await fs.readdir(currentPath); for (const entry of entries) { const entryPath = path.join(currentPath, entry); const stats = await fs.stat(entryPath); if (patternRegex.test(entry)) { results.push(entryPath); } if (stats.isDirectory()) { await searchDirectory(entryPath); } } } await searchDirectory(dirPath); return { content: [ { type: 'text', text: results.join('\n'), }, ], }; }
  • src/index.ts:190-207 (registration)
    Registration of the 'search_files' tool in the ListTools response, including name, description, and input schema requiring 'path' and 'pattern'.
    { name: 'search_files', description: 'Recursively search for files/directories', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Starting directory for search', }, pattern: { type: 'string', description: 'Search pattern (case-insensitive)', }, }, required: ['path', 'pattern'], }, },

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/ai-yliu/filesystem-mcp-server'

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