grep_files
Search file contents using regular expressions, returning matching lines with context. Configure case sensitivity, file types, and output modes.
Instructions
Search text patterns within file contents using regex. Returns matching line numbers and context - use with read_file/read_multiple_files to retrieve actual content. Supports: regex patterns, case-insensitive (-i), context lines (-A/-B/-C), file type filters (type: js/py/ts/etc), glob patterns, multiline mode. Output modes: content (lines+context), files_with_matches (paths only), count (match counts). Respects ignored folders. Use head_limit to cap results. Only searches within allowed directories.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Regex pattern to search for | |
| path | No | Directory/file to search (optional) | |
| type | No | File type filter: js, py, ts, etc | |
| glob | No | Glob filter: *.js, **/*.test.ts | |
| -i | No | Case insensitive | |
| -A | No | Lines after match | |
| -B | No | Lines before match | |
| -C | No | Lines before+after match | |
| output_mode | No | content|files_with_matches|count | content |
| head_limit | No | Limit results to N | |
| multiline | No | Allow . to match newlines |