Skip to main content
Glama
simon-ami

Windows CLI MCP Server

ssh_disconnect

Terminate SSH connections through the Windows CLI MCP Server by specifying a connection ID to close sessions when they are no longer required.

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

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesID of the SSH connection to disconnect

Implementation Reference

  • src/index.ts:400-423 (registration)
    Tool registration in listTools response, including name, description, and input schema for ssh_disconnect.
            {
              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"]
              }
            },
  • The main handler for the ssh_disconnect tool in the CallToolRequestSchema switch statement. It checks if SSH is enabled, parses the connectionId argument, closes the connection via the 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}`
        }]
      };
    }
  • The SSHConnectionPool.closeConnection method called by the tool handler. It retrieves the connection from the pool, calls disconnect() on it, and removes it from the pool.
    async closeConnection(connectionId: string): Promise<void> {
      const connection = this.connections.get(connectionId);
      if (connection) {
        connection.disconnect();
        this.connections.delete(connectionId);
      }
    }
  • The SSHConnection.disconnect() method that performs the actual disconnection by clearing reconnect timer and ending the SSH client.
    disconnect(): void {
      if (this.reconnectTimer) {
        clearTimeout(this.reconnectTimer);
        this.reconnectTimer = null;
      }
      
      if (this.isConnected) {
        this.client.end();
        this.isConnected = false;
      }
    }

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