Skip to main content
Glama
mcollina

MCP Ripgrep Server

by mcollina

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)) {

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses the key non-searching behavior, but lacks details on other behaviors like symlink handling or .gitignore respect, which would be expected from a ripgrep-based tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is front-loaded with the key action. Every word serves a purpose with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of sibling tools and 4 parameters, the description explains the core purpose well but lacks details about output format, filtering nuances, or potential limitations. Adequate but with gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with each parameter described. The description adds overarching context about ripgrep behavior but does not add significant detail beyond the schema. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists files that ripgrep would search, with the unique aspect of not actually searching. This distinguishes it from sibling tools like 'search' which perform actual searches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for previewing search scope via 'without actually searching them', but does not explicitly mention when to use alternatives or provide exclusion criteria. Context is clear but lacks direct guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.