Skip to main content
Glama

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
NameRequiredDescriptionDefault
sessionIdYesSSH session ID to check

Implementation Reference

  • 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',
  • 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']
      }
    },

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/oaslananka/mcp-ssh-tool'

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