Skip to main content
Glama

ssh_disconnect

Terminate an active SSH connection to free up resources and manage server sessions. Specify the connection ID to close the established remote session.

Instructions

Disconnect from an SSH server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesConnection ID to disconnect

Implementation Reference

  • The handler function that executes the ssh_disconnect tool. It validates input with DisconnectSSHSchema, retrieves the NodeSSH instance from connectionPool, calls dispose() to disconnect, removes entries 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}`, }, ], }; }
  • Zod schema defining the input parameters for the ssh_disconnect tool: requires a connectionId string.
    const DisconnectSSHSchema = z.object({ connectionId: z.string().describe('Connection ID to disconnect') });
  • src/index.ts:256-264 (registration)
    Registration of the ssh_disconnect tool in the listTools response, specifying name, description, and inputSchema matching the handler 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)
    Switch case in CallToolRequestSchema handler that routes ssh_disconnect calls to the handleSSHDisconnect method.
    return await this.handleSSHDisconnect(args); case 'ssh_execute':

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/widjis/mcp-ssh'

If you have feedback or need assistance with the MCP directory API, please join our Discord server