ssh_disconnect
Terminate an active SSH connection by specifying the connection ID. Use this function to manage and control multiple SSH sessions effectively within the SSH MCP Server environment.
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)The handler function that executes the ssh_disconnect tool. It validates input with DisconnectSSHSchema, retrieves the SSH connection from the pool, disposes it, removes from connectionPool and connectionContexts, and returns 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 defining the input parameters for the ssh_disconnect tool: connectionId (string). Used for validation in the handler.const DisconnectSSHSchema = z.object({ connectionId: z.string().describe('Connection ID to disconnect') });
- src/index.ts:256-265 (registration)Registration of the ssh_disconnect tool in the ListTools response, providing 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'] }, },
- src/index.ts:488-489 (registration)Handler registration in the CallToolRequestSchema switch statement, mapping 'ssh_disconnect' to the handleSSHDisconnect method.return await this.handleSSHDisconnect(args); case 'ssh_execute':