Skip to main content
Glama

ssh_close_session

Terminates SSH connections to remote servers by closing active sessions, helping manage resources and maintain security.

Instructions

Closes an SSH session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID to close

Implementation Reference

  • Implementation of the `closeSession` method that removes the session from the manager and closes the SSH and SFTP connections.
     * Closes an SSH session
     */
    async closeSession(sessionId: string): Promise<boolean> {
      logger.debug('Closing SSH session', { sessionId });
    
      const session = this.sessions.get(sessionId);
      if (!session) {
        logger.warn('Session not found for closing', { sessionId });
        return false;
      }
    
      try {
        await session.sftp.end();
        session.ssh.dispose();
      } catch (error) {
        logger.warn('Error closing session', { sessionId, error });
      }
    
      this.sessions.delete(sessionId);
      logger.info('SSH session closed', { sessionId });
      return true;
    }
  • src/mcp.ts:395-400 (registration)
    Tool handler registration and execution logic for `ssh_close_session` in `src/mcp.ts`.
    case 'ssh_close_session': {
      const { sessionId } = SessionIdSchema.parse(args);
      const result = await sessionManager.closeSession(sessionId);
      logger.info('SSH session closed', { sessionId });
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }

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