Skip to main content
Glama

listKnownHosts

Retrieve a consolidated list of SSH hosts from configuration and known hosts files to manage remote connections.

Instructions

Returns a consolidated list of all known SSH hosts, prioritizing ~/.ssh/config entries first, then additional hosts from ~/.ssh/known_hosts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'listKnownHosts' tool. It calls the config parser's getAllKnownHosts method to retrieve the list of known SSH hosts.
    async listKnownHosts(): Promise<SSHHostInfo[]> {
      return await this.configParser.getAllKnownHosts();
    }
  • Interface defining the structure of SSHHostInfo, which is the return type of the listKnownHosts tool.
    export interface SSHHostInfo {
      hostname: string;
      alias?: string;
      user?: string;
      port?: number;
      identityFile?: string;
      [key: string]: any; // For other configuration options
    }
  • Helper method in SSHConfigParser that implements the core logic: parses ~/.ssh/config for hosts and ~/.ssh/known_hosts for additional hostnames, combining them into SSHHostInfo array.
    async getAllKnownHosts(): Promise<SSHHostInfo[]> {
      const configHosts = await this.parseConfig();
      const knownHostnames = await this.parseKnownHosts();
    
      // Add hosts from known_hosts that aren't in the config
      for (const hostname of knownHostnames) {
        if (!configHosts.some(host => 
            host.hostname === hostname || 
            host.alias === hostname)) {
          configHosts.push({
            hostname: hostname
          });
        }
      }
    
      return configHosts;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden. It effectively discloses key behavioral traits: the consolidation of multiple sources, prioritization logic, and the specific file paths involved. It doesn't mention potential issues like file permissions, missing files, or output format details, but provides solid operational context.

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

Conciseness5/5

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

The description is a single, well-structured sentence that efficiently conveys the tool's purpose, data sources, and prioritization logic. Every element earns its place with no wasted words, making it easy to parse and understand.

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

Completeness4/5

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

For a zero-parameter tool with no annotations or output schema, the description provides strong context about what the tool does and how it operates. It could be more complete by mentioning the return format or handling of edge cases, but it adequately covers the core functionality given the simplicity.

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?

The tool has zero parameters with 100% schema description coverage, so the baseline is 4. The description appropriately doesn't discuss parameters, focusing instead on the tool's behavior and data sources, which adds value beyond the empty schema.

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?

The description clearly states the specific action ('Returns a consolidated list') and resource ('all known SSH hosts'), with explicit prioritization rules (~/.ssh/config entries first, then ~/.ssh/known_hosts). It distinguishes itself from sibling tools like 'getHostInfo' by focusing on listing rather than detailed information retrieval.

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

Usage Guidelines3/5

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

The description implies usage context through the prioritization rules, suggesting it's for retrieving SSH host configurations. However, it lacks explicit guidance on when to use this tool versus alternatives like 'getHostInfo' or 'checkConnectivity', and doesn't mention prerequisites or exclusions.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AiondaDotCom/mcp-ssh'

If you have feedback or need assistance with the MCP directory API, please join our Discord server