ssh_dir_search_files_content
Recursively search file contents under a remote directory for a text or regex pattern. Returns matching file paths, line numbers, and content, and flags any files skipped.
Instructions
Recursively search file CONTENTS for a pattern under a directory (unlike ssh_dir_search_glob/ssh_file_find_lines_with_pattern, which match filenames or search within a single already-known file respectively).
Regex flavor differs by platform when regex=True: POSIX extended regex
(grep -E) on Linux/macOS - avoid PCRE-only syntax like \d, use [0-9] or
[[:digit:]] instead; Python's re module on Windows. When regex=False
(default), the pattern is matched as a literal fixed string.
On Windows the whole search runs over SFTP (directory listings + raw file reads, matched locally), so non-ASCII file names and content are handled correctly.
Returns:
List of {'file': str, 'line': int, 'content': str} - one entry per matching
line, across all files under dir_path. Empty list if nothing matches (not
an error) - but only when every file could be searched.
If some files or subdirectories could NOT be searched (unreadable, or on
Windows larger than 10 MB), the result is instead
`{'status': 'incomplete', 'matches': [...same entries...], 'skipped': [{'path',
'reason'}, ...], 'skipped_count': int, 'note': str}` - so "no matches" is never
claimed for files that weren't actually searched. A missing or unreadable
`dir_path` itself is an error.
Long-running calls: if this takes longer than the server's wait cap (default 50s), it
returns {"status": "in_progress", "handle_id": ...} instead of the result - the work keeps
running. Get the result by polling ssh_cmd_check_status(handle_id=...), which returns this
tool's normal response once finished. Do not call it again meanwhile. Only one such
operation runs at a time; another one started meanwhile fails with a 'busy' error.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regex | No | Treat pattern as regular expression | |
| pattern | Yes | Text or pattern to search for | |
| dir_path | Yes | Directory to search in | |
| use_sudo | No | Use sudo for the operation | |
| case_sensitive | No | Perform case-sensitive search |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |