Skip to main content
Glama

list-files

Identify files to be searched by ripgrep in a specified path, filtering by file type, pattern, or hidden files, without executing the search.

Instructions

List files that would be searched by ripgrep without actually searching them

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePatternNoFilter by file type or glob
fileTypeNoFilter by file type (e.g., js, py)
includeHiddenNoInclude hidden files and directories
pathYesDirectory or file(s) to search.

Implementation Reference

  • Handler for the 'list-files' tool. Executes 'rg --files' with optional filters (filePattern, fileType, includeHidden) to list files that ripgrep would search, processes output by stripping ANSI codes, and returns as text content.
    case "list-files": { const path = String(args.path); const filePattern = args.filePattern ? String(args.filePattern) : undefined; const fileType = args.fileType ? String(args.fileType) : undefined; const includeHidden = typeof args.includeHidden === 'boolean' ? args.includeHidden : undefined; // Build the rg command with flags let command = "rg --files"; // Add file pattern if specified if (filePattern) { command += ` -g ${escapeShellArg(filePattern)}`; } // Add file type if specified if (fileType) { command += ` -t ${fileType}`; } // Add hidden files flag if specified if (includeHidden === true) { command += " -." } // No colors for file listing command += " --color never"; // Add path command += ` ${escapeShellArg(path)}`; console.error(`Executing: ${command}`); const { stdout, stderr } = await exec(command); // If there's anything in stderr, log it for debugging if (stderr) { console.error(`ripgrep stderr: ${stderr}`); } return { content: [ { type: "text", text: stripAnsiEscapeCodes(stdout) || "No files found" } ] }; }
  • Input schema definition for the 'list-files' tool, specifying parameters: path (required), filePattern, fileType, includeHidden.
    { name: "list-files", description: "List files that would be searched by ripgrep without actually searching them", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory or file(s) to search." }, filePattern: { type: "string", description: "Filter by file type or glob" }, fileType: { type: "string", description: "Filter by file type (e.g., js, py)" }, includeHidden: { type: "boolean", description: "Include hidden files and directories" } }, required: ["path"] } },
  • src/index.ts:94-179 (registration)
    Registers the 'list-files' tool by including it in the response to ListToolsRequestSchema, making it discoverable by MCP clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "search", description: "Search files for patterns using ripgrep (rg)", inputSchema: { type: "object", properties: { pattern: { type: "string", description: "The search pattern (regex by default)" }, path: { type: "string", description: "Directory or file(s) to search." }, caseSensitive: { type: "boolean", description: "Use case sensitive search (default: auto)" }, filePattern: { type: "string", description: "Filter by file type or glob" }, maxResults: { type: "number", description: "Limit the number of matching lines" }, context: { type: "number", description: "Show N lines before and after each match" }, useColors: { type: "boolean", description: "Use colors in output (default: false)" } }, required: ["pattern", "path"] } }, { name: "advanced-search", description: "Advanced search with ripgrep with more options", inputSchema: { type: "object", properties: { pattern: { type: "string", description: "The search pattern (regex by default)" }, path: { type: "string", description: "Directory or file(s) to search." }, caseSensitive: { type: "boolean", description: "Use case sensitive search (default: auto)" }, fixedStrings: { type: "boolean", description: "Treat pattern as a literal string, not a regex" }, filePattern: { type: "string", description: "Filter by file type or glob" }, fileType: { type: "string", description: "Filter by file type (e.g., js, py)" }, maxResults: { type: "number", description: "Limit the number of matching lines" }, context: { type: "number", description: "Show N lines before and after each match" }, invertMatch: { type: "boolean", description: "Show lines that don't match the pattern" }, wordMatch: { type: "boolean", description: "Only show matches surrounded by word boundaries" }, includeHidden: { type: "boolean", description: "Search in hidden files and directories" }, followSymlinks: { type: "boolean", description: "Follow symbolic links" }, showFilenamesOnly: { type: "boolean", description: "Only show filenames of matches, not content" }, showLineNumbers: { type: "boolean", description: "Show line numbers" }, useColors: { type: "boolean", description: "Use colors in output (default: false)" } }, required: ["pattern", "path"] } }, { name: "count-matches", description: "Count matches in files using ripgrep", inputSchema: { type: "object", properties: { pattern: { type: "string", description: "The search pattern (regex by default)" }, path: { type: "string", description: "Directory or file(s) to search." }, caseSensitive: { type: "boolean", description: "Use case sensitive search (default: auto)" }, filePattern: { type: "string", description: "Filter by file type or glob" }, countLines: { type: "boolean", description: "Count matching lines instead of total matches" }, useColors: { type: "boolean", description: "Use colors in output (default: false)" } }, required: ["pattern", "path"] } }, { name: "list-files", description: "List files that would be searched by ripgrep without actually searching them", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory or file(s) to search." }, filePattern: { type: "string", description: "Filter by file type or glob" }, fileType: { type: "string", description: "Filter by file type (e.g., js, py)" }, includeHidden: { type: "boolean", description: "Include hidden files and directories" } }, required: ["path"] } }, { name: "list-file-types", description: "List all supported file types in ripgrep", inputSchema: { type: "object", properties: {} } } ] }; });

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/mcollina/mcp-ripgrep'

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