ssh_disconnect
Terminate an active SSH connection to a remote server by specifying its connection ID, freeing up resources and closing the secure session.
Instructions
Disconnect from an SSH server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionId | Yes | Connection ID to disconnect |
Implementation Reference
- src/index.ts:599-624 (handler)Executes the disconnection of the specified SSH connection by disposing the NodeSSH instance, removing it from the connection pool and context maps, and returning a success message.private async handleSSHDisconnect(args: unknown) { const params = DisconnectSSHSchema.parse(args); const ssh = connectionPool.get(params.connectionId); if (!ssh) { throw new McpError( ErrorCode.InvalidParams, `Connection ID '${params.connectionId}' not found` ); } ssh.dispose(); connectionPool.delete(params.connectionId); // Clean up connection context connectionContexts.delete(params.connectionId); return { content: [ { type: 'text', text: `Disconnected from ${params.connectionId}`, }, ], }; }
- src/index.ts:70-72 (schema)Zod schema for validating input parameters to the ssh_disconnect tool, requiring a connectionId string.const DisconnectSSHSchema = z.object({ connectionId: z.string().describe('Connection ID to disconnect') });
- src/index.ts:256-265 (registration)Registers the ssh_disconnect tool in the list of available tools returned by ListToolsRequestSchema handler, including name, description, and input schema.name: 'ssh_disconnect', description: 'Disconnect from an SSH server', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'Connection ID to disconnect' } }, required: ['connectionId'] }, },