ssh_ping
Verify SSH session connectivity by checking if a remote server connection remains active and responsive using session ID validation.
Instructions
Checks if an SSH session is still alive and responsive
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | SSH session ID to check |
Implementation Reference
- src/mcp.ts:529-558 (handler)The handler logic for the ssh_ping tool which checks if the session exists and executes an 'echo pong' command to verify connectivity.
case 'ssh_ping': { const { sessionId } = SessionIdSchema.parse(args); const session = sessionManager.getSession(sessionId); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ alive: false, error: 'Session not found or expired' }, null, 2) }] }; } try { const startTime = Date.now(); const pingResult = await session.ssh.execCommand('echo pong'); const latencyMs = Date.now() - startTime; const result = { alive: pingResult.code === 0, latencyMs, sessionId, host: session.info.host, remainingMs: Math.max(0, session.info.expiresAt - Date.now()) }; logger.info('Session ping', { sessionId, alive: result.alive, latencyMs }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', - src/types.ts:225-227 (schema)Validation schema for the sessionId input parameter used by ssh_ping and other tools.
export const SessionIdSchema = z.object({ sessionId: z.string().min(1) }); - src/mcp.ts:347-356 (registration)Tool registration for ssh_ping within the MCP tool list.
name: 'ssh_ping', description: 'Checks if an SSH session is still alive and responsive', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'SSH session ID to check' } }, required: ['sessionId'] } },