getHostInfo
Retrieve SSH host configuration details to manage remote connections and access settings for secure server interactions.
Instructions
Returns all configuration details for an SSH host
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostAlias | Yes | Alias or hostname of the SSH host |
Implementation Reference
- src/ssh-client.ts:52-55 (handler)The core handler function for the "getHostInfo" MCP tool. It parses the SSH configuration file and returns the matching host information (SSHHostInfo or null) based on the provided hostAlias.
async getHostInfo(hostAlias: string): Promise<SSHHostInfo | null> { const hosts = await this.configParser.parseConfig(); return hosts.find(host => host.alias === hostAlias || host.hostname === hostAlias) || null; } - src/types.ts:2-8 (schema)TypeScript interface defining the structure of SSH host information returned by the getHostInfo tool.
export interface SSHHostInfo { hostname: string; alias?: string; user?: string; port?: number; identityFile?: string; [key: string]: any; // For other configuration options - src/ssh-config-parser.ts:20-29 (helper)Helper method called by getHostInfo to parse the entire SSH config file (~/.ssh/config) into an array of SSHHostInfo objects.
async parseConfig(): Promise<SSHHostInfo[]> { try { const content = await readFile(this.configPath, 'utf-8'); const config = sshConfig.parse(content); return this.extractHostsFromConfig(config); } catch (error) { console.error('Error reading SSH config:', error); return []; } }