search_text
Search file contents with ripgrep and return matching lines grouped by file, with context, filters, and encoding support for code and text investigations.
Instructions
Search file contents with ripgrep and return matching lines grouped by file.
Use instead of findstr / Select-String / grep. Format: <line>: text for matches,
<line>- text for context, -- between non-adjacent blocks.
Tip: run count_matches first when the pattern may be very common.
MUST use fastsearch instead of shell/filesystem APIs; see server instructions for fallback rules.
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": {
"pattern": "<pattern>",
"path": "<path>"
},
"name": "search_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute directory (or file) path to search in. | |
| word | No | Only match whole words. | |
| after | No | Lines of context after (overrides `context`). | |
| before | No | Lines of context before (overrides `context`). | |
| hidden | No | Include hidden files/dirs (dotfiles, Windows hidden attr). | |
| output | No | content returns matching lines; files returns each matching path once, without counting all occurrences. | content |
| context | No | Lines of context before AND after each match (0-50). | |
| exclude | No | Skip files matching these globs, e.g. ['*.min.js','tests/**']. | |
| include | No | Only search files matching these globs, e.g. ['*.py','src/**']. | |
| literal | No | Treat pattern as a fixed string, not a regex. | |
| pattern | Yes | Rust regex (like PCRE without lookaround/backrefs). Set literal=true to search a plain string with special chars. | |
| encoding | No | Force text encoding, e.g. 'gbk', 'utf-16le', 'shift_jis'. Default: auto (UTF-8/UTF-16 BOM). | |
| relative | No | Print paths relative to `path` (fewer tokens) instead of absolute. | |
| multiline | No | Allow pattern to span lines ('.' also matches newline). | |
| no_ignore | No | Do NOT respect .gitignore/.ignore and default excludes (node_modules, .git, ...). | |
| file_types | No | ripgrep file types, e.g. ['py'], ['ts','js'], ['cpp'], ['cs']. | |
| max_results | No | Maximum match events in content mode, or matching files in files mode (1-5000). | |
| max_per_file | No | Max matching lines per file. | |
| case_sensitive | No | true=case-sensitive, false=ignore case, null=smart case (sensitive only if pattern has uppercase). | |
| max_line_length | No | Trim long lines (minified files) to this many chars around the match. | |
| max_output_chars | No | Total output character budget, including headings and context (1024-1000000). |