Skip to main content
Glama

grep_text_files

Read-only

Search file contents using regex, including non-UTF-8 encodings. Match multiple patterns in one pass and output lines, filenames, or counts.

Instructions

Regex search in file contents with encoding support. PREFER THIS over built-in Grep for non-UTF-8 files. Skips .gitignore'd files (respectGitignore=false to include). Parameters: pattern (regex) or patterns (array), paths (array of files, or dirs searched recursively), caseSensitive (default true), contextBefore/After, maxMatches (default 1000), offset, include/includes, exclude/excludes, encoding. patterns finds ANY of several regexes in ONE pass — sweeping a codebase for a list of names is one call, not one per name. outputMode: "content" (default, matching lines), "files_with_matches" (paths only, far cheaper when you just need WHICH files), "count" (matching lines per file). contextBefore/After apply to content mode only. matchesOnly=true returns the matched substring instead of the whole line, for extracting values — with patterns it also tells you which one hit. offset skips the first N results, so you can page past maxMatches; the response echoes nextOffset when truncated. Include and exclude patterns are basename-only globs; {a,b} alternatives work and a leading **/ is ignored. Includes match any pattern and excludes reject any match. Do not combine a singular field with its plural. Example: {"patterns": ["TCustomer", "TOrder"], "paths": ["D:\proj\src"], "includes": [".pas", ".dfm"], "outputMode": "files_with_matches"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYes
offsetNo
excludeNo
includeNo
patternYes
encodingNo
excludesNo
includesNo
patternsNo
maxMatchesNo
outputModeNo
matchesOnlyNo
contextAfterNo
caseSensitiveNo
contextBeforeNo
respectGitignoreNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hintNo
filesNo
countsNo
matchesYes
truncatedNo
nextOffsetNo
filesMatchedYes
totalMatchesYes
filesSearchedYes
Behavior5/5

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

The description reveals many behavioral traits: skips .gitignore'd files unless respectGitignore=false, defaults for caseSensitive and maxMatches, context modes limited to content mode, matchesOnly semantics, offset pagination with nextOffset echo, and glob specifics. This goes well beyond the readOnlyHint annotation, providing substantial operational insight.

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?

Though long, the description is highly organized and front-loaded. It starts with purpose and preference, then systematically covers parameters, output modes, and edge cases. Every sentence contributes useful detail, and the example anchors understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 16-parameter tool with no schema descriptions, the description is exceptionally complete. It covers defaults, modes, glob semantics, paging, and even includes a concrete example. The output schema can handle return structure, so this is sufficient for an agent to select and use the tool correctly.

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

Parameters5/5

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

With no parameter descriptions in the schema (0% coverage), the description compensates fully. It defines every parameter, clarifies the difference between singular and plural forms, documents defaults, and explains how contextBefore/After and matchesOnly behave. This is essential for correct invocation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear verb+resource: 'Regex search in file contents with encoding support.' It explicitly distinguishes from the built-in Grep by recommending this tool for non-UTF-8 files, and the example further illustrates its intended use.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It says 'PREFER THIS over built-in Grep for non-UTF-8 files,' naming the alternative. It also provides thorough guidance on when to use outputMode 'files_with_matches' vs 'content', explains the efficiency of 'patterns' for multiple regexes, and warns against combining singular and plural fields.

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/dimitar-grigorov/mcp-file-tools'

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