Skip to main content
Glama
cygnussystems

cygnus-ssh-mcp

Official

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

TableJSON Schema
NameRequiredDescriptionDefault
regexNoTreat pattern as regular expression
patternYesText or pattern to search for
dir_pathYesDirectory to search in
use_sudoNoUse sudo for the operation
case_sensitiveNoPerform case-sensitive search

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.6.1
    • addedOutput schema / properties / result / anyOf
      Added value: +[
      +  {
      +    "items": {},
      +    "type": "array"
      +  },
      +  {
      +    "additionalProperties": true,
      +    "type": "object"
      +  }
      +]
    • removedOutput schema / properties / result / items
      Removed value: -{}
    • removedOutput schema / properties / result / type
      Removed value: -"array"
  2. First observedv1.3.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden, and it does so richly: platform-dependent regex flavor (POSIX ERE vs Python re), Windows SFTP fallback handling, the 'incomplete' result shape that avoids false 'no matches' claims, and the async handle_id/polling contract with the single-operation 'busy' constraint. This is exactly the behavioral context annotations would otherwise supply.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose before diving into platform behavior and return shapes, and each sentence conveys distinct operational value. It is longer than typical but not padded; the inline sibling comparison in the first sentence is slightly dense.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with an output schema, the description still covers the non-obvious return variants ('incomplete' with skipped list, 'in_progress' with handle_id) and the error condition for an unreadable dir_path. An agent has everything needed to invoke and interpret it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning beyond the schema: it clarifies that regex=True changes the regex dialect by platform (with PCRE-avoidance guidance) and that regex=False performs literal fixed-string matching. The use_sudo and case_sensitive params get no extra description, keeping it just short of 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Recursively search file CONTENTS for a pattern under a directory') and immediately distinguishes itself from two named siblings (ssh_dir_search_glob for filenames, ssh_file_find_lines_with_pattern for a single known file). An agent can route correctly without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly contrasts this tool against its closest alternatives and states the selecting condition for each. It also gives when-to-use regex vs literal mode and platform caveats, leaving nothing to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.