A powerful search tool built on regular expressions.
GrepSearch file contents with regular expressions, including legacy encodings like GBK and Big5. Retrieve matching files, lines, or counts to find what you need.
Instructions
A powerful search tool for file contents.
Usage:
ALWAYS use Grep for search tasks. NEVER invoke grep or rg as a Bash command.
Supports full regular expressions, file glob filters, file type filters, context lines, match-only output, multiline matching, pagination, file lists, and per-file counts.
Use output_mode=files_with_matches when you only need file paths; this is the default.
Use output_mode=content to see matching lines. Line numbers are included by default.
Use output_mode=count to see match counts per file.
scan_mode=exact is the default: pagination never stops scanning, so counts are exact when scanComplete is true. scan_mode=fast is opt-in and only valid for files_with_matches; it stops each matching file at its first match and reports countsExact=false.
Results are limited to 250 entries by default; use head_limit and offset for pagination. Check structuredContent scanComplete, truncationReason, and outputTruncated whenever a search is resource-limited.
ASCII patterns are searched once with ripgrep and ignore file encoding.
Non-ASCII patterns (Chinese, etc.) are grouped by detected file encoding and searched with rg --encoding per group.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| -A | No | Show lines after each match | |
| -B | No | Show lines before each match | |
| -C | No | Show lines before and after each match | |
| -i | No | Case-insensitive search | |
| -n | No | Show line numbers in content mode. Defaults to true. | |
| -o | No | Print only matching non-empty parts of each line | |
| glob | No | Glob pattern used to filter files, for example *.js or **/*.ts | |
| path | No | File or directory to search. Defaults to the current working directory. | |
| type | No | File type filter such as js, ts, py, rust, go, or java | |
| offset | No | Skip the first N result lines or entries | |
| context | No | Alias for -C | |
| pattern | Yes | The regular expression pattern to search for in file contents | |
| multiline | No | Enable multiline matching where dot also matches newlines | |
| scan_mode | No | exact scans all eligible files and returns exact counts when complete. fast is opt-in for files_with_matches only and stops each matching file after its first match, so counts are not exact. | exact |
| head_limit | No | Limit returned lines or entries. Defaults to 250; 0 means unlimited. | |
| output_mode | No | Output mode. Defaults to files_with_matches. |