search_files
Search files using pattern matching with regex, file type, size, date filters, and exclude comments or string literals for cleaner code results.
Instructions
Advanced file and code search tool with comprehensive filtering and matching capabilities. Searches for patterns in files within allowed directories with support for regex patterns, file type filtering, size constraints, date filtering, and content preprocessing. When called without arguments, searches for common patterns in the current directory. Supports excluding comments and string literals for cleaner code searches. Results can be formatted as text, JSON, or structured output with configurable sorting and grouping options.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | Search pattern - can be literal text or regex depending on regexMode. Defaults to searching for common file types if not specified | .* |
| searchPath | No | Directory path to search in. Must be within allowed directories. Defaults to first allowed directory if not specified | |
| extensions | No | Array of file extensions to include (e.g., ['.js', '.ts', '.py']). Include the dot prefix | |
| excludeExtensions | No | Array of file extensions to exclude | |
| excludePatterns | No | Array of filename patterns to exclude (supports simple wildcards) | |
| regexMode | No | Whether to treat pattern as a regular expression | |
| caseSensitive | No | Whether search should be case sensitive | |
| wordBoundary | No | Whether to match whole words only | |
| multiline | No | Whether to enable multiline regex matching | |
| maxDepth | No | Maximum directory recursion depth. Unlimited if not specified | |
| followSymlinks | No | Whether to follow symbolic links | |
| includeBinary | No | Whether to search in binary files | |
| minSize | No | Minimum file size in bytes | |
| maxSize | No | Maximum file size in bytes | |
| modifiedAfter | No | Only include files modified after this date (ISO 8601 format) | |
| modifiedBefore | No | Only include files modified before this date (ISO 8601 format) | |
| snippetLength | No | Length of text snippet around matches | |
| maxResults | No | Maximum number of match results to return | |
| sortBy | No | How to sort the results | relevance |
| groupByFile | No | Whether to group results by file | |
| excludeComments | No | Whether to exclude comments from search (language-aware) | |
| excludeStrings | No | Whether to exclude string literals from search | |
| outputFormat | No | Output format for results | text |