Skip to main content
Glama

close_all_sessions

Terminate all active SSH connections to remote hosts, ensuring complete session cleanup and resource release for secure connection management.

Instructions

Close all active SSH sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler implementation for 'close_all_sessions'. It is decorated with @mcp.tool() for registration and delegates the core logic to SSHSessionManager.close_all_sessions() while handling logging and response.
    @mcp.tool() def close_all_sessions() -> str: """Close all active SSH sessions.""" logger = session_manager.logger.getChild('tool_close_all_sessions') logger.info("Closing all active SSH sessions.") session_manager.close_all_sessions() response = "All SSH sessions closed" logger.info(response) return response
  • The core helper method in SSHSessionManager that closes all active SSH sessions, persistent shells, clears commands via command_executor, and cleans up all related tracking dictionaries under a thread lock.
    def close_all_sessions(self): """Close all sessions and cleanup resources.""" logger = self.logger.getChild('close_all') logger.info("Closing all active sessions and resources.") with self._lock: # Clear all commands first logger.debug("Clearing all commands") self.command_executor.clear_all_commands() # Close all persistent shells logger.debug(f"Closing {len(self._session_shells)} persistent shells.") for key, shell in self._session_shells.items(): try: shell.close() except Exception as e: logger.warning(f"Error closing shell for {key}: {e}") self._session_shells.clear() # Close all SSH sessions logger.debug(f"Closing {len(self._sessions)} SSH clients.") for key, client in self._sessions.items(): try: client.close() except Exception as e: logger.warning(f"Error closing client for {key}: {e}") self._sessions.clear() self._enable_mode.clear() self._session_shell_types.clear() self._session_prompt_patterns.clear() self._session_prompts.clear() self._session_shell_types.clear() logger.info("All sessions closed.")

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/devnullvoid/mcp-ssh-session'

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