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
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Comando a ejecutar en el servidor remoto | |
| confirm | No | Confirmar ejecución de comandos peligrosos. Requerido cuando el comando es detectado como destructivo |
Implementation Reference
- src/index.ts:209-244 (handler)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}`); } } - src/tools.ts:43-61 (schema)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);