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
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
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)}"
- main.py:143-168 (helper)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