Skip to main content
Glama
MrGNSS

Desktop Commander MCP

search_files

Find files and directories by pattern across subfolders from a specified starting path within permitted locations.

Instructions

Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. Only searches within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
patternYes

Implementation Reference

  • The main handler function for the search_files tool. Recursively searches for files and directories matching the given pattern starting from rootPath, with path validation for security.
    export async function searchFiles(rootPath: string, pattern: string): Promise<string[]> {
        const results: string[] = [];
    
        async function search(currentPath: string) {
            const entries = await fs.readdir(currentPath, { withFileTypes: true });
    
            for (const entry of entries) {
                const fullPath = path.join(currentPath, entry.name);
                
                try {
                    await validatePath(fullPath);
    
                    if (entry.name.toLowerCase().includes(pattern.toLowerCase())) {
                        results.push(fullPath);
                    }
    
                    if (entry.isDirectory()) {
                        await search(fullPath);
                    }
                } catch (error) {
                    continue;
                }
            }
        }
    
        const validPath = await validatePath(rootPath);
        await search(validPath);
        return results;
    }
  • Zod schema defining the input arguments for the search_files tool: path (starting directory) and pattern (search string).
    export const SearchFilesArgsSchema = z.object({
      path: z.string(),
      pattern: z.string(),
    });
  • src/server.ts:172-179 (registration)
    Tool registration in the ListTools response, including name, description, and input schema reference.
    {
      name: "search_files",
      description:
        "Recursively search for files and directories matching a pattern. " +
        "Searches through all subdirectories from the starting path. " +
        "Only searches within allowed directories.",
      inputSchema: zodToJsonSchema(SearchFilesArgsSchema),
    },
  • src/server.ts:308-313 (registration)
    Dispatch handler in CallToolRequest that parses args, calls the searchFiles function, and formats the response.
    case "search_files": {
      const parsed = SearchFilesArgsSchema.parse(args);
      const results = await searchFiles(parsed.path, parsed.pattern);
      return {
        content: [{ type: "text", text: results.length > 0 ? results.join('\n') : "No matches found" }],
      };
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 discloses behavioral traits like recursion and directory restrictions, but fails to mention critical aspects such as performance implications (e.g., time-consuming for large directories), error handling, or output format (e.g., list of paths). This leaves significant gaps for an agent to understand the tool's behavior.

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 appropriately sized and front-loaded, with three concise sentences that each add value: the first defines the core action, the second specifies recursion, and the third adds a constraint. There is no wasted text, making it efficient for an agent to parse.

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

Completeness2/5

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

Given the tool's complexity (recursive search with parameters), lack of annotations, and no output schema, the description is incomplete. It misses key contextual details like what the output contains (e.g., file paths, metadata), how errors are handled, or performance considerations, which are essential for proper tool invocation.

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

Parameters2/5

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

The input schema has 0% description coverage, so the description must compensate. It adds some meaning by implying 'path' is the starting point and 'pattern' is the search criteria, but does not explain parameter details like format (e.g., glob vs. regex for pattern) or constraints (e.g., path must exist). This is insufficient given the low 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 with specific verbs ('search for files and directories') and resources ('matching a pattern'), and distinguishes its scope ('recursively', 'through all subdirectories from the starting path'). However, it does not explicitly differentiate from sibling tools like 'list_directory' or 'get_file_info', which slightly reduces clarity.

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 specifying 'recursively' and 'only searches within allowed directories', which suggests when to use this tool for deep searches. However, it lacks explicit guidance on when to choose this over alternatives like 'list_directory' (for non-recursive listing) or 'get_file_info' (for single file details), leaving some ambiguity.

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/MrGNSS/ClaudeDesktopCommander'

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