Skip to main content
Glama
talentedmrweb

Local Dev Bridge MCP

search_files

Search for text within files in a directory using recursive scanning to locate specific content across your codebase.

Instructions

Search for text within files in a directory (recursive)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to search for
pathNoDirectory to search in (defaults to projects directory)
file_patternNoFile pattern to match (e.g., '*.js', '*.py')

Implementation Reference

  • The core handler function that implements the logic for the 'search_files' tool. It resolves the search path, uses glob to find matching files, reads each file, searches lines case-insensitively for the query, and returns formatted results.
    async searchFiles(query, searchPath, filePattern = '*') {
      const resolvedPath = this.resolvePath(searchPath || '.');
      const pattern = path.join(resolvedPath, '**', filePattern);
      
      const files = await glob(pattern, { 
        ignore: ['**/node_modules/**', '**/.git/**'],
        nodir: true,
      });
      
      const results = [];
      for (const file of files) {
        try {
          const content = await fs.readFile(file, 'utf-8');
          const lines = content.split('\n');
          
          lines.forEach((line, index) => {
            if (line.toLowerCase().includes(query.toLowerCase())) {
              results.push(`${file}:${index + 1}:${line.trim()}`);
            }
          });
        } catch (error) {
          // Skip files that can't be read
        }
      }
      
      const output = results.length > 0 
        ? `Search results for "${query}" in ${resolvedPath}:\n\n${results.slice(0, 100).join('\n')}`
        : `No results found for "${query}" in ${resolvedPath}`;
      
      return {
        content: [
          {
            type: 'text',
            text: output,
          },
        ],
      };
    }
  • Input schema definition for the 'search_files' tool, specifying parameters: query (required), path (optional), file_pattern (optional).
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Text to search for',
        },
        path: {
          type: 'string',
          description: 'Directory to search in (defaults to projects directory)',
        },
        file_pattern: {
          type: 'string',
          description: "File pattern to match (e.g., '*.js', '*.py')",
        },
      },
      required: ['query'],
    },
  • index.js:133-154 (registration)
    Registration of the 'search_files' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'search_files',
      description: 'Search for text within files in a directory (recursive)',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Text to search for',
          },
          path: {
            type: 'string',
            description: 'Directory to search in (defaults to projects directory)',
          },
          file_pattern: {
            type: 'string',
            description: "File pattern to match (e.g., '*.js', '*.py')",
          },
        },
        required: ['query'],
      },
    },
  • index.js:178-179 (registration)
    Dispatch/registration of the 'search_files' handler in the CallToolRequestSchema switch statement, mapping tool call to the searchFiles method.
    case 'search_files':
      return await this.searchFiles(args.query, args.path, args.file_pattern);
  • Helper method used by searchFiles (and other tools) to resolve relative paths to absolute paths within the projects directory.
    resolvePath(inputPath) {
      if (!inputPath || inputPath === '.') {
        return PROJECTS_DIR;
      }
      if (path.isAbsolute(inputPath)) {
        return inputPath;
      }
      return path.join(PROJECTS_DIR, inputPath);
    }
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 tool searches recursively but doesn't cover other critical aspects: it doesn't mention if the search is case-sensitive, what the output format is (e.g., list of matches, file paths), performance implications for large directories, or error handling. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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, efficient sentence: 'Search for text within files in a directory (recursive)'. It is front-loaded with the core purpose and includes essential scope information without any wasted words, making it highly concise and well-structured.

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 (searching files recursively with three parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., search results format), potential limitations, or how it interacts with sibling tools. For a search operation, more context is needed to guide effective use by an agent.

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 clear parameter descriptions: 'query' for text to search, 'path' for the directory (with a default), and 'file_pattern' for filtering. The description adds minimal value beyond the schema by implying recursive search, but it doesn't provide additional syntax or format details. This meets the baseline score when the 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's purpose: 'Search for text within files in a directory (recursive)'. It specifies the verb ('Search'), resource ('text within files'), and scope ('directory (recursive)'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'list_directory' or 'read_file', 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 no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools such as 'list_directory' for listing files without searching or 'read_file' for viewing file contents, nor does it specify prerequisites or exclusions. This lack of contextual advice leaves the agent to infer usage scenarios independently.

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/talentedmrweb/local-dev-bridge-mcp'

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