Search Content
search_textSearch file contents for literal text or an RE2 regex to find files and lines containing specific text.
Instructions
Search file contents under the roots for literal text or an RE2 regex. Use when you need the files and lines that contain some text. Do not use it to find files by name; use find_files instead. A regex may span lines; the hit is on its first line. Skips hidden entries, .gitignore matches, and build folders unless includeHidden or includeIgnored. Lines over 1000 chars are clipped around the match. Stops early at 10000 matching lines or the timeout, setting stoppedReason. Returns root, file:line: text rows (a named file prints its path once), matches with column and context, totals, and skip counts. A multi-page or stopped first page also returns nextCursor, valid about 5 min after its last page, and resourceUri, valid about 60 s.
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": {
"searchPattern": "<searchPattern>"
},
"name": "search_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | File or directory to search (default: the only root). A named file is searched alone: pattern, maxDepth, and hidden/ignored filtering do not apply. Result paths are relative to the root, not to path. | |
| cursor | No | Opaque pagination cursor. Pass it unchanged for the next page. Pages come from one snapshot taken on the first call. It lasts 5 min past its last page; on refusal, retry without it. | |
| context | No | Lines shown before and after each match, like grep -C. | |
| exclude | No | Globs for entries to leave out, with everything under a matching folder. Without / a pattern matches a name at any depth (vendor, *.test.ts); with / it matches the path relative to path. | |
| isRegex | No | Treat searchPattern as an RE2 regex | |
| pattern | No | Glob limiting which files are searched: *.ts matches names at any depth, src/**/*.ts matches paths relative to path. Default: all files. | |
| maxDepth | No | Max directory depth. 0 scans only the base directory. Omit for no limit. | |
| maxResults | No | Matching lines per page; context lines do not count. Later pages come via cursor. | |
| caseSensitive | No | Match case exactly. replace_text matches case by default, so pass true to preview what it will replace. | |
| includeHidden | No | Include hidden items (starting with .) | |
| searchPattern | Yes | Text to find, literal unless isRegex is true. RE2 has no lookahead, lookbehind, or backreferences. | |
| includeIgnored | No | Include ignored items (node_modules, .git, etc). |