Skip to main content
Glama
d3v1an
by d3v1an

ssh_exec

Execute commands on remote SSH servers with safety features, including confirmation prompts for destructive operations to prevent accidental system changes.

Instructions

Ejecuta un comando en el servidor remoto. Si el comando es destructivo (rm -rf, reboot, etc.) requiere confirm: true para ejecutarse

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesComando a ejecutar en el servidor remoto
confirmNoConfirmar ejecución de comandos peligrosos. Requerido cuando el comando es detectado como destructivo

Implementation Reference

  • The handler function `handleExec` executes a shell command on the remote server using the SSH client, including security checks for dangerous commands.
    private async handleExec(args: any): Promise<CallToolResult> {
      this.requireConnection();
      const command = args.command as string;
      const confirm = args.confirm as boolean | undefined;
    
      const check = isDangerousCommand(command);
      if (check.dangerous && !confirm) {
        return {
          content: [
            {
              type: "text",
              text: [
                `ADVERTENCIA: Comando potencialmente destructivo detectado.`,
                `Comando: ${command}`,
                `Razón: ${check.reason}`,
                ``,
                `Para ejecutar este comando, reenvía con confirm: true.`,
              ].join("\n"),
            },
          ],
        };
      }
    
      try {
        const output = await this.execCommand(command);
        this.audit("ssh_exec", command, "ok");
        this.recordOperation("ssh_exec", { command, confirm }, output, false);
        return {
          content: [{ type: "text", text: output || "(sin salida)" }],
        };
      } catch (error) {
        const msg = error instanceof Error ? error.message : String(error);
        this.audit("ssh_exec", command, "error");
        throw new Error(`Error ejecutando comando: ${msg}`);
      }
    }
  • The `ssh_exec` tool schema definition, including input parameters `command` and `confirm`.
      name: "ssh_exec",
      description:
        "Ejecuta un comando en el servidor remoto. Si el comando es destructivo (rm -rf, reboot, etc.) requiere confirm: true para ejecutarse",
      inputSchema: {
        type: "object",
        properties: {
          command: {
            type: "string",
            description: "Comando a ejecutar en el servidor remoto",
          },
          confirm: {
            type: "boolean",
            description:
              "Confirmar ejecución de comandos peligrosos. Requerido cuando el comando es detectado como destructivo",
          },
        },
        required: ["command"],
      },
    },
  • src/index.ts:65-66 (registration)
    Registration of the 'ssh_exec' tool within the `CallToolRequestSchema` switch statement.
    case "ssh_exec":
      return await this.handleExec(args);

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/d3v1an/ssh-mcp'

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