Skip to main content
Glama
balloonf
by balloonf

ssh_close_session

Terminate a specific SSH session using the session ID to manage active connections efficiently within the SSH MCP Server.

Instructions

특정 SSH 세션 종료

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Implementation Reference

  • main.py:296-306 (handler)
    MCP tool handler for 'ssh_close_session'. Calls the session manager to close the session and returns appropriate success/error message.
    async def ssh_close_session(session_id: str) -> str:
        """특정 SSH 세션 종료"""
        try:
            success = await ssh_manager.close_session(session_id)
            if success:
                return f"Session '{session_id}' closed successfully"
            else:
                return f"Session '{session_id}' not found"
        except Exception as e:
            return f"Failed to close session: {str(e)}"
  • Core implementation in SSHSessionManager that closes the SSH connection, cancels monitoring task, cleans up metadata, and logs the action.
    async def close_session(self, session_id: str) -> bool:
        """특정 세션 종료"""
        
        if session_id not in self.connections:
            return False
        
        try:
            # 연결 종료
            conn = self.connections[session_id]
            conn.close()
            
            # 모니터링 태스크 종료
            if session_id in self.connection_tasks:
                self.connection_tasks[session_id].cancel()
                del self.connection_tasks[session_id]
            
            # 메타데이터 정리
            del self.connections[session_id]
            del self.session_metadata[session_id]
            
            logger.info(f"SSH session closed: {session_id}")
            return True
            
        except Exception as e:
            logger.error(f"Error closing session {session_id}: {e}")
            return False
Install Server

Other Tools

Related Tools

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/balloonf/ssh_mcp'

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