Search file contents
search_contentFind which files contain a word or pattern by searching file contents with a regular expression. Returns matching lines with file paths and line numbers.
Instructions
Search file contents under a folder for lines matching a regular expression. Use when: finding which files contain a word or pattern, with line numbers. Instead: search_index or walk_tree to match names; read_file for a whole file. Behavior: read-only, breadth-first; include narrows by file name. Files are read as UTF-8, binary ones too (bad bytes: U+FFFD); over 4 MiB they are skipped; lines are cut at 500 characters. Patterns with nested quantifiers or slower than 5 s on a file are refused (ReDoS). Secret files go to unreadable. Time limit: 60 s. Returns: {matches: [{path, line_no, line}], files_scanned, truncated (max_matches, or a folder at max_depth not searched), unreadable, complete}. An empty result with complete=false does not mean the pattern is absent; when truncated, narrow path or include.
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>"
},
"name": "search_content"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | The folder to search (absolute, or relative to the MCP root); default the MCP root, '/' on a remote backend. | |
| backend | No | Backend id from list_backends; omit for the default. | |
| include | No | Only files whose name matches this glob, case-sensitive, e.g. '*.py' or '*.[ch]'. | |
| pattern | Yes | A Python regular expression, matched against each line, e.g. 'import|require' or '(?i)password'. | |
| path_b64 | No | path as base64 of its raw bytes, for non-UTF-8 names; replaces path. | |
| max_depth | No | Levels to visit, counted from 1: 1 = path's own entries. | |
| max_matches | No | Most matching lines to return. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matches | Yes | ||
| complete | Yes | ||
| truncated | Yes | ||
| unreadable | Yes | ||
| files_scanned | Yes |