Skip to main content
Glama

list-files

Preview files that ripgrep would search before running actual searches. Filter by file type, glob patterns, or include hidden files to scope your search targets.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for the 'list-files' tool, which executes 'rg --files' with optional filters like filePattern, fileType, and includeHidden, processes the output, and returns the list of files.
    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" } ] }; }
  • The input schema definition and registration of the 'list-files' tool in the ListToolsRequestHandler.
    { 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:185-185 (registration)
    Tool name validation check in the CallToolRequestHandler switch dispatch.
    if (!["search", "advanced-search", "count-matches", "list-files", "list-file-types"].includes(toolName)) {

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