ssh_disconnect
Terminate an active SSH connection by specifying its connection ID using this tool. Maintain control over SSH sessions with precision and efficiency.
Instructions
Close an SSH connection
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionId | Yes | ID of an active SSH connection |
Input Schema (JSON Schema)
{
"properties": {
"connectionId": {
"description": "ID of an active SSH connection",
"type": "string"
}
},
"required": [
"connectionId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:622-649 (handler)The core handler function that executes the ssh_disconnect tool: checks for active connection by ID, ends the SSH client connection using conn.end(), removes it from the connections Map, and returns appropriate success or error response.private async handleSSHDisconnect(params: any) { const { connectionId } = params; // Check if the connection exists if (!this.connections.has(connectionId)) { return { content: [{ type: "text", text: `No active SSH connection with ID: ${connectionId}` }], isError: true }; } const { conn, config } = this.connections.get(connectionId)!; try { // Close the connection conn.end(); this.connections.delete(connectionId); return { content: [{ type: "text", text: `Disconnected from ${config.username}@${config.host}:${config.port}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to disconnect: ${error.message}` }], isError: true }; } }
- src/index.ts:286-287 (registration)Registration and dispatch point in the CallToolRequestSchema handler's switch statement that routes ssh_disconnect calls to the handleSSHDisconnect method.case 'ssh_disconnect': return this.handleSSHDisconnect(request.params.arguments);
- src/index.ts:255-264 (schema)Schema definition for ssh_disconnect tool returned by ListToolsRequestSchema handler, specifying input validation requiring 'connectionId' string.{ name: 'ssh_disconnect', description: 'Close an SSH connection', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'ID of an active SSH connection' } }, required: ['connectionId'] }
- src/index.ts:158-169 (schema)Initial tool schema registration in server.setTools call, defining input schema for ssh_disconnect.ssh_disconnect: { description: "Close an SSH connection", inputSchema: { type: "object", properties: { connectionId: { type: "string", description: "ID of an active SSH connection" } }, required: ["connectionId"] }