Skip to main content
Glama
FutureAtoms

Agentic Control Framework (ACF)

by FutureAtoms

search_files

Search files in a directory using a pattern. Specify the path and pattern to retrieve matching files.

Instructions

Search files by pattern

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
patternYes

Implementation Reference

  • The actual searchFiles function that performs the file search using glob pattern matching. Takes a searchPath, pattern, and allowedDirs; validates path access; uses globSync with '**/<pattern>' to find matching files/directories; returns results with relative paths and types.
    function searchFiles(searchPath, pattern, allowedDirs) {
      try {
        if (!searchPath) {
          return { success: false, message: 'No search path provided' };
        }
    
        if (!pattern) {
          return { success: false, message: 'No search pattern provided' };
        }
    
        if (!isPathAllowed(searchPath, allowedDirs)) {
          return { success: false, message: `Access to path "${searchPath}" is not allowed` };
        }
    
        const resolvedPath = path.resolve(searchPath);
        
        // Check if directory exists
        if (!fs.existsSync(resolvedPath)) {
          return { success: false, message: `Directory not found: ${searchPath}` };
        }
    
        // Check if it's a directory
        const stats = fs.statSync(resolvedPath);
        if (!stats.isDirectory()) {
          return { success: false, message: `Path is not a directory: ${searchPath}` };
        }
    
        // Use glob to search for files
        const searchPattern = path.join(resolvedPath, '**', pattern);
        const matches = globSync(searchPattern, { nodir: false });
        
        // Convert absolute paths back to relative paths
        const results = matches.map(match => ({
          path: path.relative(process.cwd(), match),
          type: fs.statSync(match).isDirectory() ? 'directory' : 'file'
        }));
    
        // Create content string for compatibility
        const content = results.length > 0 
          ? `Found ${results.length} files matching "${pattern}":\n${results.map(r => `${r.type === 'directory' ? '[DIR]' : '[FILE]'} ${r.path}`).join('\n')}`
          : `No files found matching "${pattern}" in ${searchPath}`;
    
        return {
          success: true,
          results,
          count: results.length,
          pattern,
          content // Add content field for compatibility
        };
      } catch (error) {
        logger.error(`Error searching files: ${error.message}`);
        return { success: false, message: `Error searching files: ${error.message}` };
      }
    }
  • MCP tool registration/schema for 'search_files': describes it as 'Search files by pattern', requires 'path' (string) and 'pattern' (string) as input parameters.
    { name:'search_files', description:'Search files by pattern', inputSchema:{ type:'object', properties:{ path:{type:'string'}, pattern:{type:'string'} }, required:['path','pattern'] } },
  • The tools/call handler for 'search_files' that delegates to filesystemTools.searchFiles(args.path, args.pattern, allowedDirectories). This is the dispatch point in the MCP server.
    case 'search_files':
      data = filesystemTools.searchFiles(args.path, args.pattern, allowedDirectories);
  • Export of the searchFiles function in module.exports from filesystem_tools.js.
    module.exports = {
      readFile,
      readMultipleFiles,
      writeFile,
      listDirectory,
      createDirectory,
      moveFile,
      searchFiles,
  • macOS Spotlight-based file search using AppleScript (mdfind command) - a different searchFiles implementation for macOS Spotlight.
    searchFiles: (query) => `
      do shell script "mdfind " & quoted form of "${query}"
    `,
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only states the basic operation, lacking information about whether the search is recursive, case-sensitive, or destructive. For a tool performing file searches, safety and scope details are important.

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

Conciseness3/5

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

The description is a single short sentence, which is efficient but lacks structure. It conveys the core idea without unnecessary verbosity, though additional details would improve clarity without harming conciseness.

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 two required parameters, no output schema, and no parameter descriptions, the description is incomplete. It does not cover expected return format, recursion behavior, pattern syntax, or edge cases, leaving significant gaps for the agent.

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

Parameters1/5

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

The input schema has 0% description coverage, and the description adds no explanation for 'path' or 'pattern'. It fails to specify that 'path' is the directory root and 'pattern' is a glob/regex, leaving ambiguity about acceptable formats and behavior.

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 states a clear verb and resource ('Search files') and mentions the key parameter ('by pattern'). It is easily understood, but does not explicitly distinguish from sibling 'search_code' which searches file contents, relying on the agent to infer the difference.

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?

No guidance on when to use search_files versus alternatives like list_directory or search_code. The description implies usage for pattern-based file name matching but does not explain preferred scenarios or trade-offs.

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/FutureAtoms/agentic-control-framework'

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