Skip to main content
Glama
delorenj

Super Windows CLI MCP Server

ssh_execute

Execute commands on remote hosts via SSH to manage systems and run administrative tasks from the Super Windows CLI MCP Server.

Instructions

Execute a command on a remote host via SSH

Example usage:

{
  "connectionId": "raspberry-pi",
  "command": "uname -a"
}

Configuration required in config.json:

{
  "ssh": {
    "enabled": true,
    "connections": {
      "raspberry-pi": {
        "host": "raspberrypi.local",
        "port": 22,
        "username": "pi",
        "password": "raspberry"
      }
    }
  }
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesID of the SSH connection to use
commandYesCommand to execute

Implementation Reference

  • The primary handler for the 'ssh_execute' tool. It validates the input arguments using Zod, checks SSH configuration, retrieves or creates an SSH connection via the connection pool, executes the command on the remote host, logs to history if enabled, and returns the output with metadata including exit code.
    case "ssh_execute": {
      if (!this.config.ssh.enabled) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          "SSH support is disabled in configuration"
        );
      }
    
      const args = z.object({
        connectionId: z.string(),
        command: z.string()
      }).parse(request.params.arguments);
    
      const connectionConfig = this.config.ssh.connections[args.connectionId];
      if (!connectionConfig) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          `Unknown SSH connection ID: ${args.connectionId}`
        );
      }
    
      try {
        // Validate command
        this.validateCommand('cmd', args.command);
    
        const connection = await this.sshPool.getConnection(args.connectionId, connectionConfig);
        const { output, exitCode } = await connection.executeCommand(args.command);
    
        // Store in history if enabled
        if (this.config.security.logCommands) {
          this.commandHistory.push({
            command: args.command,
            output,
            timestamp: new Date().toISOString(),
            exitCode,
            connectionId: args.connectionId
          });
    
          if (this.commandHistory.length > this.config.security.maxHistorySize) {
            this.commandHistory = this.commandHistory.slice(-this.config.security.maxHistorySize);
          }
        }
    
        return {
          content: [{
            type: "text",
            text: output || 'Command completed successfully (no output)'
          }],
          isError: exitCode !== 0,
          metadata: {
            exitCode,
            connectionId: args.connectionId
          }
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        if (this.config.security.logCommands) {
          this.commandHistory.push({
            command: args.command,
            output: `SSH error: ${errorMessage}`,
            timestamp: new Date().toISOString(),
            exitCode: -1,
            connectionId: args.connectionId
          });
        }
        throw new McpError(
          ErrorCode.InternalError,
          `SSH error: ${errorMessage}`
        );
      }
    }
  • src/index.ts:209-251 (registration)
    Tool registration in the ListTools response, including name, description, and input schema definition based on configured SSH connections.
              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"]
              }
            },
  • Core SSH command execution logic in SSHConnection class. Uses ssh2 Client.exec to run the command, captures stdout/stderr, and returns output with exit code. Handles reconnection if needed.
    async executeCommand(command: string): Promise<{ output: string; exitCode: number }> {
      this.lastActivity = Date.now();
    
      // Check connection and attempt reconnect if needed
      if (!this.isConnected) {
        await this.connect();
      }
    
      return new Promise((resolve, reject) => {
        this.client.exec(command, (err, stream) => {
          if (err) {
            reject(err);
            return;
          }
    
          let output = '';
          let errorOutput = '';
    
          stream
            .on('data', (data: Buffer) => {
              output += data.toString();
            })
            .stderr.on('data', (data: Buffer) => {
              errorOutput += data.toString();
            });
    
          stream.on('close', (code: number) => {
            this.lastActivity = Date.now();
            resolve({
              output: output || errorOutput,
              exitCode: code || 0
            });
          });
        });
      });
    }
  • TypeScript interface defining the configuration for SSH connections used by the ssh_execute tool.
    export interface SSHConnectionConfig {
      host: string;
      port: number;
      username: string;
      privateKeyPath?: string;
      password?: string;
      keepaliveInterval?: number;
      keepaliveCountMax?: number;
      readyTimeout?: number;
    }
  • SSHConnectionPool class manages persistent SSH connections, creates new ones as needed, handles reconnection, and provides connection for executeCommand.
    export class SSHConnectionPool {
      private connections: Map<string, SSHConnection> = new Map();
    
      async getConnection(connectionId: string, config: SSHConnectionConfig): Promise<SSHConnection> {
        let connection = this.connections.get(connectionId);
        
        if (!connection) {
          connection = new SSHConnection(config);
          this.connections.set(connectionId, connection);
          await connection.connect();
        } else if (!connection.isActive()) {
          await connection.connect();
        }
    
        return connection;
      }
    
      async closeConnection(connectionId: string): Promise<void> {
        const connection = this.connections.get(connectionId);
        if (connection) {
          connection.disconnect();
          this.connections.delete(connectionId);
        }
      }
    
      closeAll(): void {
        for (const connection of this.connections.values()) {
          connection.disconnect();
        }
        this.connections.clear();
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the action and configuration but lacks critical details: it doesn't mention authentication requirements (implied by config but not stated), potential security risks, error handling, or output format. For a tool that executes remote commands with no annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The example and configuration details are relevant but could be more concise; the configuration block is lengthy and might be better summarized. Overall, it's efficient with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of SSH command execution, no annotations, and no output schema, the description is incomplete. It covers basic usage and configuration but omits essential context: authentication details, error scenarios, security implications, and what the tool returns (e.g., stdout, stderr, exit code). This leaves gaps for an AI agent to use the tool safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters ('connectionId' and 'command'). The description adds minimal value beyond the schema—it provides an example usage that illustrates parameter semantics but doesn't explain enum values for 'connectionId' or additional constraints. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute a command') and resource ('on a remote host via SSH'), distinguishing it from sibling tools like 'execute_command' (likely local), 'get_command_history' (query), and 'ssh_disconnect' (connection management). The verb+resource combination is precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the example and configuration details, suggesting it's for remote SSH execution. However, it doesn't explicitly state when to use this tool versus alternatives like 'execute_command' (presumably for local commands) or provide clear exclusions. The guidance is helpful but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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