Skip to main content
Glama

ssh_disconnect

Terminate SSH connections cleanly using the specified connection ID. This tool ensures secure disconnection when sessions are no longer required on the Windows CLI MCP Server.

Instructions

Disconnect from an SSH server

Example usage:

{ "connectionId": "raspberry-pi" }

Use this to cleanly close SSH connections when they're no longer needed.

Input Schema

NameRequiredDescriptionDefault
connectionIdYesID of the SSH connection to disconnect

Input Schema (JSON Schema)

{ "properties": { "connectionId": { "description": "ID of the SSH connection to disconnect", "enum": [], "type": "string" } }, "required": [ "connectionId" ], "type": "object" }

Implementation Reference

  • Main handler logic for the 'ssh_disconnect' tool. Validates SSH feature is enabled, parses the connectionId argument using Zod, closes the SSH connection using the connection pool, and returns a success message.
    case "ssh_disconnect": { if (!this.config.ssh.enabled) { throw new McpError( ErrorCode.InvalidRequest, "SSH support is disabled in configuration" ); } const args = z.object({ connectionId: z.string() }).parse(request.params.arguments); await this.sshPool.closeConnection(args.connectionId); return { content: [{ type: "text", text: `Disconnected from ${args.connectionId}` }] }; }
  • Tool definition including name, description, and input schema (JSON Schema with connectionId required, enum from config) for registration in listTools response.
    { name: "ssh_disconnect", description: `Disconnect from an SSH server Example usage: \`\`\`json { "connectionId": "raspberry-pi" } \`\`\` Use this to cleanly close SSH connections when they're no longer needed.`, inputSchema: { type: "object", properties: { connectionId: { type: "string", description: "ID of the SSH connection to disconnect", enum: Object.keys(this.config.ssh.connections) } }, required: ["connectionId"] } },
  • SSHConnectionPool.closeConnection: Retrieves the SSHConnection instance by ID from the pool, calls its disconnect method, and removes it from the pool map.
    async closeConnection(connectionId: string): Promise<void> { const connection = this.connections.get(connectionId); if (connection) { connection.disconnect(); this.connections.delete(connectionId); } }
  • SSHConnection.disconnect: Clears any pending reconnect timer, ends the underlying ssh2 Client connection, and marks the connection as inactive.
    disconnect(): void { if (this.reconnectTimer) { clearTimeout(this.reconnectTimer); this.reconnectTimer = null; } if (this.isConnected) { this.client.end(); this.isConnected = false; } }

Other Tools

Related Tools

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/simon-ami/win-cli-mcp-server'

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