Skip to main content
Glama
Faucet94

Super Windows CLI MCP Server

by Faucet94

ssh_disconnect

Cleanly terminate SSH connections with a specified ID when they are no longer needed. Ensures proper closure of remote sessions to maintain system efficiency and security.

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

  • Executes the ssh_disconnect tool: validates input, checks SSH configuration, closes the specified SSH connection using the connection pool, and returns a confirmation 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}`
        }]
      };
    }
  • Defines the input schema, name, and description for the ssh_disconnect tool, registered in the 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"]
              }
            }
  • src/index.ts:123-277 (registration)
    Registers the ssh_disconnect tool in the list of available tools returned by listTools handler.
          tools: [
            {
              name: "execute_command",
              description: `Execute a command in the specified shell (powershell, cmd, or gitbash)
    
    Example usage (PowerShell):
    \`\`\`json
    {
      "shell": "powershell",
      "command": "Get-Process | Select-Object -First 5",
      "workingDir": "C:\\Users\\username"
    }
    \`\`\`
    
    Example usage (CMD):
    \`\`\`json
    {
      "shell": "cmd",
      "command": "dir /b",
      "workingDir": "C:\\Projects"
    }
    \`\`\`
    
    Example usage (Git Bash):
    \`\`\`json
    {
      "shell": "gitbash",
      "command": "ls -la",
      "workingDir": "/c/Users/username"
    }
    \`\`\``,
              inputSchema: {
                type: "object",
                properties: {
                  shell: {
                    type: "string",
                    enum: Object.keys(this.config.shells).filter(shell => 
                      this.config.shells[shell as keyof typeof this.config.shells].enabled
                    ),
                    description: "Shell to use for command execution"
                  },
                  command: {
                    type: "string",
                    description: "Command to execute"
                  },
                  workingDir: {
                    type: "string",
                    description: "Working directory for command execution (optional)"
                  }
                },
                required: ["shell", "command"]
              }
            },
            {
              name: "get_command_history",
              description: `Get the history of executed commands
    
    Example usage:
    \`\`\`json
    {
      "limit": 5
    }
    \`\`\`
    
    Example response:
    \`\`\`json
    [
      {
        "command": "Get-Process",
        "output": "...",
        "timestamp": "2024-03-20T10:30:00Z",
        "exitCode": 0
      }
    ]
    \`\`\``,
              inputSchema: {
                type: "object",
                properties: {
                  limit: {
                    type: "number",
                    description: `Maximum number of history entries to return (default: 10, max: ${this.config.security.maxHistorySize})`
                  }
                }
              }
            },
            {
              name: "ssh_execute",
              description: `Execute a command on a remote host via SSH
    
    Example usage:
    \`\`\`json
    {
      "connectionId": "raspberry-pi",
      "command": "uname -a"
    }
    \`\`\`
    
    Configuration required in config.json:
    \`\`\`json
    {
      "ssh": {
        "enabled": true,
        "connections": {
          "raspberry-pi": {
            "host": "raspberrypi.local",
            "port": 22,
            "username": "pi",
            "password": "raspberry"
          }
        }
      }
    }
    \`\`\``,
              inputSchema: {
                type: "object",
                properties: {
                  connectionId: {
                    type: "string",
                    description: "ID of the SSH connection to use",
                    enum: Object.keys(this.config.ssh.connections)
                  },
                  command: {
                    type: "string",
                    description: "Command to execute"
                  }
                },
                required: ["connectionId", "command"]
              }
            },
            {
              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 method: retrieves the connection by ID, 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);
      }
    }
  • SSHConnection.disconnect method: clears reconnect timer and ends the underlying SSH client connection.
    disconnect(): void {
      if (this.reconnectTimer) {
        clearTimeout(this.reconnectTimer);
        this.reconnectTimer = null;
      }
      
      if (this.isConnected) {
        this.client.end();
        this.isConnected = false;
      }
    }
Install Server

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/Faucet94/super-win-cli-mcp-server'

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