Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

search_files

Find files and directories matching patterns across subdirectories from a specified path within allowed 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 core handler function that recursively searches files matching the given pattern within the allowed directories starting from rootPath.
    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-178 (registration)
    Tool registration in the list of available tools, specifying name, description, and input schema.
    {
      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),
  • Dispatch handler in the main tool call switch statement that parses arguments and invokes the searchFiles function.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions recursion and allowed directory constraints, but lacks details on permissions, rate limits, error handling, or output format. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is appropriately sized with three sentences. It's front-loaded with the core purpose, followed by scope and constraints. Each sentence adds value without redundancy, though minor improvements in clarity could enhance structure.

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), no annotations, no output schema, and low schema coverage, the description is incomplete. It misses critical details like result format, error cases, performance implications, and how it differs from simpler listing tools, making it inadequate for full contextual understanding.

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 0%, so the description must compensate. It explains that 'path' is the starting point and 'pattern' is what to match, adding basic semantics. However, it doesn't clarify parameter formats (e.g., regex vs glob for pattern) or examples, leaving room for ambiguity despite covering both parameters.

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: 'Recursively search for files and directories matching a pattern.' It specifies the verb (search), resource (files and directories), and scope (recursively). However, it doesn't explicitly differentiate from sibling tools like 'list_directory' or 'get_file_info', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides minimal guidance: 'Only searches within allowed directories.' It implies a constraint but doesn't explain when to use this tool versus alternatives like 'list_directory' or 'read_file'. No explicit when/when-not instructions or sibling tool comparisons are included.

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/StrawHatAI/claude-dev-tools'

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