Search Files
search_filesSearch file contents using regular expressions to find definitions or mentions anywhere in a directory. Supports glob filters and context lines for precise results.
Instructions
Search file contents under a directory with a regular expression (like grep -rn, but no shell quoting to get wrong). Skips binary files, .git and node_modules. Use this to find where something is defined or mentioned.
Args:
path (string): Directory (or single file) to search.
pattern (string): Regular expression, e.g. "function \w+Tools". Plain text works too.
glob (string): Optional filename filter, e.g. ".ts" or "src/**/.js".
context_lines (number): Lines of context around each match (default 0).
max_results (number): Max matching lines returned (default 50).
Returns matches as file:line: text, grouped by file.
Example: { "path": "~/project", "pattern": "registerTool", "glob": "*.ts" }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Directory or file to search | |
| pattern | Yes | Regular expression to find | |
| glob | No | Optional filename glob filter | |
| context_lines | No | Context lines around matches | |
| max_results | No | Max matching lines |