Skip to main content
Glama

grep_text_files

Read-only

Search file contents with regex across directories, including non-UTF-8 encodings like CP1251 and ISO-8859. Skips .gitignore'd files by default.

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
patternNo
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

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv4.5.0
    • changedInput schema / required
      Previous value: -[
      -  "pattern",
      -  "paths"
      -]New value: +[
      +  "paths"
      +]
  2. Changed2 schema fields changedv4.2.0
    • addedInput schema / properties / patterns
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": [
      +    "null",
      +    "array"
      +  ]
      +}
    • addedOutput schema / properties / hint
      Added value: +{
      +  "type": "string"
      +}
  3. Addedv3.3.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations cover only the safety profile (readOnly/openWorld/idempotent), so the description carries real weight beyond them and does: it discloses gitignore skipping with the override flag, the default maxMatches=1000, the truncation/nextOffset echo for paging, and the fact that contextBefore/After only apply in content mode. These are non-obvious behaviors an agent would otherwise get wrong.

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?

Purpose and the sibling preference are front-loaded, and every sentence carries information. It is dense and runs long as a single paragraph, but there is no true filler; a bulleted parameter block would scan faster, which keeps it from a 5.

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?

With 16 parameters, an enum-free schema, and an output schema that covers return shape, the description needs to supply the calling contract — defaults, mode selection, glob rules, paging, and mutual-exclusion rules — and it does all of that. Nothing material is left for the agent to guess.

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?

Schema coverage is 0% across 16 parameters, so the description must compensate fully and does — it documents every one of pattern/patterns, paths, caseSensitive (default true), contextBefore/After, maxMatches, offset, include/includes, exclude/exclude, encoding, outputMode, matchesOnly, and respectGitignore, including default values, glob semantics ('basename-only', '{a,b}', leading '**/'), and a worked example object.

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?

States a specific verb+resource ('Regex search in file contents') plus an unusual capability (encoding support) that no sibling offers. It also positions itself against an implicit alternative ('PREFER THIS over built-in Grep for non-UTF-8 files'), so an agent can distinguish it from search_files at a glance.

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?

Explicitly states when to prefer it (non-UTF-8 files), when it is cheaper to switch modes ('files_with_matches ... far cheaper when you just need WHICH files'), and how to avoid the singleton/plural conflict ('Do not combine a singular field with its plural'). This is routing guidance plus exclusion guidance in one place.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.