Skip to main content
Glama

find_by_content

Search for files containing specific text within directories using file patterns and result limits to locate content efficiently.

Instructions

Find files containing specific text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to search for (literal, not regex)
pathNoDirectory to search
file_patternNoFile pattern (e.g., *.ts)
max_resultsNoMaximum results

Implementation Reference

  • Implementation of the find_by_content logic.
    async function findByContentImpl(input: {
      text: string;
      path?: string;
      file_pattern?: string;
      max_results?: number;
    }): Promise<ToolResult> {
      // Escape special regex characters for literal search
      const escapedText = input.text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    
      return await grepSearchImpl({
        pattern: escapedText,
        path: input.path,
        glob: input.file_pattern,
        case_sensitive: true,
        max_results: input.max_results ?? 100,
        context_lines: 0,
      });
    }
  • Registration of the find_by_content MCP tool.
    // find_by_content tool (simpler interface)
    server.tool(
      'find_by_content',
      'Find files containing specific text',
      {
        text: z.string().describe('Text to search for (literal, not regex)'),
        path: z.string().optional().describe('Directory to search'),
        file_pattern: z.string().optional().describe('File pattern (e.g., *.ts)'),
        max_results: z.number().optional().describe('Maximum results'),
      },
      async (args) => {
        return await findByContentImpl(args);
      }
    );
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 states the tool searches for text in files but doesn't mention whether it's case-sensitive, recursive, what happens with large result sets, error conditions, or performance characteristics. For a search tool with zero annotation coverage, 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.

Conciseness5/5

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

The description is a single, efficient sentence that states the core functionality without any wasted words. It's appropriately sized for a search tool and front-loads the essential information.

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 (4 parameters, search functionality) and the absence of both annotations and output schema, the description is insufficient. It doesn't explain what the tool returns (file paths? content snippets? match counts?), error handling, or important behavioral constraints needed for effective use.

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 description implies text searching but doesn't add meaning beyond what the 100% schema coverage already provides. The schema fully documents all 4 parameters including their purposes and constraints (e.g., 'literal, not regex' for text). The description doesn't explain parameter interactions or provide additional context, meeting the baseline for high schema coverage.

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 'Find files containing specific text' clearly states the tool's purpose with a specific verb ('Find') and resource ('files'), and distinguishes it from siblings like 'grep_search' by focusing on content matching rather than pattern-based search. However, it doesn't explicitly differentiate from all siblings like 'glob_search' which searches by filename pattern.

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 'grep_search' or 'glob_search'. It doesn't mention prerequisites, exclusions, or comparative advantages, leaving the agent to infer usage from the tool name alone.

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/mcp-tool-shop-org/mcp-file-forge'

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