Skip to main content
Glama

shell_find

Search for files in directory hierarchies using command arguments to locate specific items within the Shell-MCP server's secure environment.

Instructions

Search for files in a directory hierarchy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoCommand arguments

Implementation Reference

  • Generic handler for calling shell tools like shell_find. Resolves 'shell_find' to 'shell.find' from allowedCommands, validates arguments, executes the 'find' command via CommandExecutor, and streams the output.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        const command = String(request.params?.name || '');
        const fullCommand = `shell.${command.replace('shell_', '')}`;  // Replace shell_ back to shell.
        
        if (!(fullCommand in allowedCommands)) {
          return {
            content: [{ type: "text", text: `Unknown command: ${command}` }],
            isError: true
          };
        }
        
        const actualCommand = allowedCommands[fullCommand].command;
        const args = Array.isArray(request.params?.arguments?.args)
          ? request.params.arguments.args.map(String)
          : [];
      
        validator.validateCommand(actualCommand, args);
        const stream = await executor.execute(actualCommand, args);
      
        return {
          content: [{
            type: "text",
            text: await new Promise((resolve, reject) => {
              const chunks: Buffer[] = [];
              stream.stdout.on('data', (chunk: Buffer) => chunks.push(chunk));
              stream.stdout.on('end', () => resolve(Buffer.concat(chunks).toString()));
              stream.stdout.on('error', reject);
            })
          }]
        };
      } catch (error) {
        return {
          content: [{ 
            type: "text", 
            text: `Command execution failed: ${error instanceof Error ? error.message : String(error)}` 
          }],
          isError: true
        };
      }
    });
  • src/index.ts:27-43 (registration)
    Registers all available tools by mapping allowedCommands to MCP tools, transforming keys like 'shell.find' to 'shell_find'.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools = Object.entries(allowedCommands).map(([name, config]) => ({
        name: name.replace('shell.', 'shell_'),  // Replace shell. with shell_
        description: config.description,
        inputSchema: {
          type: "object",
          properties: {
            args: {
              type: "array",
              items: { type: "string" },
              description: "Command arguments"
            }
          }
        }
      }));
      return { tools };
    });
  • Input schema for shell_find and other shell tools: object with 'args' array of strings.
      type: "object",
      properties: {
        args: {
          type: "array",
          items: { type: "string" },
          description: "Command arguments"
        }
      }
    }
  • Configuration for the 'shell.find' command, which is mapped to tool 'shell_find'. Defines the executable command, description, allowed arguments, and timeout.
    'shell.find': {
      command: 'find',
      description: 'Search for files in a directory hierarchy',
      allowedArgs: [
        '-name',
        '-type',
        '-size',
        '-mtime',
        '-maxdepth',
        '-mindepth',
        '-ls',
        '*'      // allow paths and patterns
      ],
      timeout: 10000
    },
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 of behavioral disclosure. It states the action ('search') but doesn't cover critical aspects like whether it's read-only, if it requires specific permissions, how results are returned, or potential side effects (e.g., performance impact on large directories). This leaves significant gaps for safe and effective use.

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, clear sentence with no wasted words. It's front-loaded with the core purpose ('Search for files'), making it easy to parse quickly. This efficiency is ideal for tool selection without unnecessary elaboration.

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 complexity of a shell-based file search tool with no annotations and no output schema, the description is insufficient. It lacks details on behavior, output format, error handling, and usage context, which are crucial for an agent to invoke it correctly. More information is needed to compensate for the missing structured data.

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?

The input schema has 100% description coverage, with the 'args' parameter documented as 'Command arguments'. The description doesn't add any semantic details beyond this, such as example arguments or formatting rules. Since the schema already provides basic parameter info, the baseline score of 3 is appropriate, but no extra value is contributed.

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 'Search for files in a directory hierarchy' clearly states the verb ('search') and resource ('files in a directory hierarchy'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'shell_ls' or 'shell_whereis', which also deal with file/directory operations, but the specific focus on searching is clear.

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 no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, typical use cases, or comparisons to siblings like 'shell_ls' (list files) or 'shell_grep' (search within files). Without such context, an agent might struggle to choose appropriately among similar tools.

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/kevinwatt/shell-mcp'

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