Skip to main content
Glama
mcollina

MCP Ripgrep Server

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)) {
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool lists files 'without actually searching them,' which hints at a read-only, non-destructive behavior, but doesn't disclose other traits like performance characteristics, rate limits, or authentication needs. For a tool with zero annotation coverage, this is a significant gap in behavioral context.

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, efficient sentence that front-loads the core purpose. It avoids unnecessary words and directly communicates the tool's function, making it easy to parse and understand quickly.

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 tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on output format, error handling, or integration with sibling tools. Without annotations or an output schema, more context would improve completeness for effective agent use.

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 description coverage is 100%, so the schema already documents all parameters (path, filePattern, fileType, includeHidden) with descriptions. The description doesn't add any parameter-specific semantics beyond what the schema provides, such as examples or constraints, meeting the baseline score of 3 for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'List files that would be searched by ripgrep without actually searching them.' It specifies the verb ('List files') and resource ('files that would be searched by ripgrep'), but doesn't explicitly differentiate from sibling tools like 'list-file-types' or 'search' beyond the ripgrep reference.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'without actually searching them,' suggesting this is for previewing what ripgrep would search. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'search' or 'list-file-types,' leaving the agent to infer based on the ripgrep reference.

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

Install Server

Other 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