ssh_disconnect
Disconnect from a remote machine via SSH by providing host, username, and optional port. Securely closes the active session established through the read-only SSH MCP server.
Instructions
Disconnect from the remote machine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | Remote host | |
| username | Yes | SSH username | |
| port | No | SSH port (default: 22) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- ssh_readonly_fastmcp.py:152-179 (handler)The ssh_disconnect tool handler function. Uses @mcp.tool() decorator, accepts host/username/port params, looks up the connection in the global ssh_clients dict, closes the paramiko SSH client, deletes the entry, and returns a status message.
@mcp.tool() def ssh_disconnect( host: str, username: str, port: int = 22 ) -> str: """ Disconnect from the remote machine. Args: host: Remote host username: SSH username port: SSH port (default: 22) Returns: Disconnection status message """ connection_id = f"{username}@{host}:{port}" if connection_id in ssh_clients: try: ssh_clients[connection_id]['client'].close() del ssh_clients[connection_id] return f"Successfully disconnected from {connection_id}" except Exception as e: return f"Disconnection error: {str(e)}" else: return f"Not connected to {connection_id}" - ssh_readonly_fastmcp.py:152-152 (registration)The @mcp.tool() decorator on line 152 registers ssh_disconnect as a FastMCP tool.
@mcp.tool() - ssh_readonly_fastmcp_mcast.py:266-293 (handler)Duplicate implementation of ssh_disconnect in the multicast variant of the server. Same logic - closes the paramiko client and removes it from the global ssh_clients dict.
@mcp.tool() def ssh_disconnect( host: str, username: str, port: int = 22 ) -> str: """ Disconnect from the remote machine. Args: host: Remote host username: SSH username port: SSH port (default: 22) Returns: Disconnection status message """ connection_id = f"{username}@{host}:{port}" if connection_id in ssh_clients: try: ssh_clients[connection_id]['client'].close() del ssh_clients[connection_id] return f"Successfully disconnected from {connection_id}" except Exception as e: return f"Disconnection error: {str(e)}" else: return f"Not connected to {connection_id}" - ssh_readonly_fastmcp_mcast.py:266-266 (registration)The @mcp.tool() decorator on line 266 registers ssh_disconnect in the multicast server variant.
@mcp.tool()