ssh_disconnect
Terminate an active SSH connection to a remote server. Use this tool to close sessions and free up resources when remote operations are complete.
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 ssh_disconnect tool: validates input with DisconnectSSHSchema, retrieves SSH connection by ID from pool, disposes the connection, removes from pool and context maps, returns 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 input schema for ssh_disconnect tool requiring 'connectionId' string parameter.const DisconnectSSHSchema = z.object({ connectionId: z.string().describe('Connection ID to disconnect') });
- src/index.ts:256-265 (registration)Tool registration in ListToolsRequestSchema handler: defines name, description, and inputSchema matching the DisconnectSSHSchema.name: 'ssh_disconnect', description: 'Disconnect from an SSH server', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'Connection ID to disconnect' } }, required: ['connectionId'] }, },
- src/index.ts:487-488 (registration)Dispatch/registration in CallToolRequestSchema switch statement: maps tool name to handler function.case 'ssh_disconnect': return await this.handleSSHDisconnect(args);