file_search
Find a literal string in a file or entire directory tree, then view each match with surrounding context lines for quick orientation.
Instructions
Search for a literal string pattern in a file or recursively in a directory. Returns structured hits with surrounding context lines. Case-insensitive. Replaces grep -n. For regex searches, use shell_exec.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to a file or directory. Tilde (~) is expanded to the home directory. Directories are searched recursively. | |
| pattern | Yes | Search string. Treated as a case-insensitive literal (not regex). | |
| max_results | No | Stop after this many total matches. Default 50, max 200. | |
| context_lines | No | Number of lines to include before and after each match. Default 2, max 5. | |
| include_pattern | No | Directory mode only: only search files whose name ends with this string. Example: ".ts" for TypeScript files. Omit to search all files. |