Skip to main content
Glama

fast_search_files

Search files by name or content using regex patterns, with auto-chunking, context lines, and binary file support for efficient file discovery.

Instructions

Searches for files (by name/content) - supports auto-chunking, regex, context, and line numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesDirectory to search in
patternYesSearch pattern (regex supported)
content_searchNoSearch file content
case_sensitiveNoCase-sensitive search
max_resultsNoMaximum number of results
context_linesNoNumber of context lines around a match
file_patternNoFilename filter pattern (e.g., *.js, *.txt)
include_binaryNoInclude binary files in search
continuation_tokenNoContinuation token from a previous call
auto_chunkNoEnable auto-chunking

Implementation Reference

  • api/server.ts:178-192 (registration)
    Registration of the 'fast_search_files' tool in the MCP_TOOLS array, including name, description, and input schema.
    {
      name: 'fast_search_files',
      description: '파일을 검색합니다 (이름/내용)',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: '검색할 디렉토리' },
          pattern: { type: 'string', description: '검색 패턴' },
          content_search: { type: 'boolean', description: '파일 내용 검색', default: false },
          case_sensitive: { type: 'boolean', description: '대소문자 구분', default: false },
          max_results: { type: 'number', description: '최대 결과 수', default: 100 }
        },
        required: ['path', 'pattern']
      }
    },
  • api/server.ts:338-340 (registration)
    Dispatch case in the main tools/call switch statement that invokes the handleSearchFiles function.
    case 'fast_search_files':
      result = await handleSearchFiles(args);
      break;
  • The complete handler function implementing the fast_search_files tool. Performs recursive directory search for files matching pattern in name or content (if enabled), with limits and exclusions.
    async function handleSearchFiles(args: any) {
      const { 
        path: searchPath, 
        pattern, 
        content_search = false, 
        case_sensitive = false, 
        max_results = 100
      } = args;
      
      const safePath_resolved = safePath(searchPath);
      const maxResults = Math.min(max_results, 200);
      const results: any[] = [];
      
      const searchPattern = case_sensitive ? pattern : pattern.toLowerCase();
      
      async function searchDirectory(dirPath: string) {
        if (results.length >= maxResults) return;
        
        try {
          const entries = await fs.readdir(dirPath, { withFileTypes: true });
          
          for (const entry of entries) {
            if (results.length >= maxResults) break;
            
            const fullPath = path.join(dirPath, entry.name);
            
            if (shouldExcludePath(fullPath)) continue;
            
            if (entry.isFile()) {
              const searchName = case_sensitive ? entry.name : entry.name.toLowerCase();
              let matched = false;
              let matchType = '';
              
              if (searchName.includes(searchPattern)) {
                matched = true;
                matchType = 'filename';
              }
              
              if (!matched && content_search) {
                try {
                  const stats = await fs.stat(fullPath);
                  if (stats.size < 10 * 1024 * 1024) { // 10MB 제한
                    const content = await fs.readFile(fullPath, 'utf-8');
                    const searchContent = case_sensitive ? content : content.toLowerCase();
                    if (searchContent.includes(searchPattern)) {
                      matched = true;
                      matchType = 'content';
                    }
                  }
                } catch {
                  // 바이너리 파일 등 읽기 실패 무시
                }
              }
              
              if (matched) {
                const stats = await fs.stat(fullPath);
                results.push({
                  path: fullPath,
                  name: entry.name,
                  match_type: matchType,
                  size: stats.size,
                  size_readable: formatSize(stats.size),
                  modified: stats.mtime.toISOString(),
                  extension: path.extname(fullPath)
                });
              }
            } else if (entry.isDirectory()) {
              await searchDirectory(fullPath);
            }
          }
        } catch {
          // 권한 없는 디렉토리 등 무시
        }
      }
      
      await searchDirectory(safePath_resolved);
      
      return {
        results: results,
        total_found: results.length,
        search_pattern: pattern,
        search_path: safePath_resolved,
        content_search: content_search,
        case_sensitive: case_sensitive,
        max_results_reached: results.length >= maxResults,
        timestamp: new Date().toISOString()
      };
    }
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 features like auto-chunking, regex support, context lines, and line numbers, but doesn't explain what these mean operationally (e.g., how auto-chunking affects performance, what 'context' includes, whether searches are recursive, or if there are rate limits). For a 10-parameter tool with no annotations, this leaves significant behavioral gaps.

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 a single, efficient sentence that front-loads the core purpose ('Searches for files') and lists key features. There's no wasted text, though it could be slightly more structured (e.g., separating purpose from features).

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 (10 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return format (e.g., what data is included in results), how pagination works with continuation_token, or error conditions. For a search tool with many options, this leaves the agent guessing about output and behavior.

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 10 parameters thoroughly. The description adds minimal value beyond the schema—it mentions 'auto-chunking, regex, context, and line numbers' which correspond to parameters like auto_chunk, pattern (regex), and context_lines, but doesn't provide additional semantic context or usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

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 searches for files by name or content, which is a specific verb+resource combination. It distinguishes from siblings like fast_list_directory (which lists without searching) and fast_search_code (which appears specialized for code). However, it doesn't explicitly differentiate from fast_search_code beyond mentioning 'files' vs 'code'.

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 like fast_search_code or fast_find_large_files. It mentions capabilities (auto-chunking, regex, etc.) but doesn't specify scenarios where this tool is preferred over other search or file operations tools in the sibling list.

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/efforthye/fast-filesystem-mcp'

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