checkConnectivity
Verify SSH connectivity to a remote host using its alias or hostname. Ensures successful connection setup for further operations on the MCP SSH Agent server.
Instructions
Checks if an SSH connection to the host is possible
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostAlias | Yes | Alias or hostname of the SSH host |
Implementation Reference
- src/ssh-client.ts:60-83 (handler)The handler function that executes the checkConnectivity tool. It attempts to connect to the SSH host specified by hostAlias, runs an 'echo connected' command to test connectivity, and returns a ConnectionStatus indicating success or failure with a message.async checkConnectivity(hostAlias: string): Promise<ConnectionStatus> { try { // Establish connection await this.connectToHost(hostAlias); // Execute ping command const result = await this.ssh.execCommand('echo connected'); const connected = result.stdout.trim() === 'connected'; this.ssh.dispose(); return { connected, message: connected ? 'Connection successful' : 'Echo test failed' }; } catch (error) { console.error(`Connectivity error with ${hostAlias}:`, error); return { connected: false, message: error instanceof Error ? error.message : String(error) }; } }
- src/types.ts:19-22 (schema)TypeScript interface defining the output schema for the checkConnectivity tool.export interface ConnectionStatus { connected: boolean; message: string; }