search_directory
Searches for a text pattern across all files in a directory, returning matches grouped by file with line numbers and context while respecting ignore rules and optional file filters.
Instructions
Search for a text pattern across all files in a directory.
Returns results grouped by file with line numbers and context. Use
include_pattern to filter by file extension (e.g. '*.py'). Automatically
ignores __pycache__, node_modules, and .git, plus nested .gitignore/
.ignore rules. Prefer fuzzy=False (default) for multi-file search
performance.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"absolute_dir_path": "<absolute_dir_path>",
"pattern": "<pattern>"
},
"name": "search_directory"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fuzzy | No | Enable fuzzy matching (null = false; expensive for many files). Explicit true together with regex=true is ignored and a warning is returned. | |
| regex | No | Enable Python regex matching (default: false). | |
| invert | No | Return non-matching lines, like grep -v (default: false). | |
| pattern | Yes | Text pattern to search for. | |
| max_results | No | Total match cap across all files (1-500). Defaults to server config (100). | |
| context_lines | No | Lines of context before/after each match (default: 2). | |
| case_sensitive | No | Case-sensitive search (default: false). | |
| include_hidden | No | Include dot-files and dot-dirs (default: false). | |
| include_pattern | No | fnmatch glob matched against file names (default: '*'). Examples: '*.py', '*.md', '*.ts'. | * |
| absolute_dir_path | Yes | The absolute path to the directory to search. | |
| respect_gitignore | No | Honor nested .gitignore/.ignore files when filtering files (default: server default, true). Set false to search ignored files too. |