ssh_shell_send
Send input to an active SSH shell session with optional safety checks for potentially dangerous commands, returning the generated output.
Instructions
Envía input a una sesión de shell activa. Si raw es false (default), aplica detección de comandos peligrosos. Retorna el output generado tras enviar el input
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID de la sesión de shell | |
| input | Yes | Texto a enviar a la shell (se agrega \n automáticamente si raw es false) | |
| raw | No | Si es true, envía el input tal cual sin agregar \n ni aplicar detección de comandos peligrosos (default: false) | |
| timeout | No | Tiempo en ms para esperar output después de enviar (default: 2000) | |
| confirm | No | Confirmar ejecución de comandos peligrosos. Solo aplica cuando raw es false |
Implementation Reference
- src/index.ts:637-694 (handler)The handler for the `ssh_shell_send` MCP tool, responsible for sending input to an active SSH shell session and returning the output.
private async handleShellSend(args: any): Promise<CallToolResult> { this.requireConnection(); const sessionId = args.sessionId as string; const input = args.input as string; const raw = (args.raw as boolean) || false; const timeout = (args.timeout as number) || SSHMCPServer.SETTLE_TIMEOUT; const confirm = args.confirm as boolean | undefined; const session = this.shellSessions.get(sessionId); if (!session) { throw new Error(`Sesión "${sessionId}" no encontrada. Usa ssh_shell_start para crear una.`); } // Security check cuando no es raw if (!raw) { const check = isDangerousCommand(input); if (check.dangerous && !confirm) { return { content: [ { type: "text", text: [ `ADVERTENCIA: Comando potencialmente destructivo detectado.`, `Input: ${input}`, `Razón: ${check.reason}`, ``, `Para ejecutar, reenvía con confirm: true.`, ].join("\n"), }, ], }; } } // Limpiar buffer antes de enviar session.buffer = ""; // Enviar input const data = raw ? input : input + "\n"; session.channel.write(data); this.resetIdleTimer(sessionId, session); this.audit("ssh_shell_send", `sessionId=${sessionId} input=${raw ? "(raw)" : input}`, "ok"); // Esperar output return new Promise<CallToolResult>((resolve) => { setTimeout(() => { resolve({ content: [ { type: "text", text: stripAnsi(session.buffer) || "(sin output)", }, ], }); }, timeout); }); } - src/tools.ts:210-241 (schema)The JSON schema definition for the `ssh_shell_send` tool.
name: "ssh_shell_send", description: "Envía input a una sesión de shell activa. Si raw es false (default), aplica detección de comandos peligrosos. Retorna el output generado tras enviar el input", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID de la sesión de shell", }, input: { type: "string", description: "Texto a enviar a la shell (se agrega \\n automáticamente si raw es false)", }, raw: { type: "boolean", description: "Si es true, envía el input tal cual sin agregar \\n ni aplicar detección de comandos peligrosos (default: false)", }, timeout: { type: "number", description: "Tiempo en ms para esperar output después de enviar (default: 2000)", }, confirm: { type: "boolean", description: "Confirmar ejecución de comandos peligrosos. Solo aplica cuando raw es false", }, }, required: ["sessionId", "input"], }, }, - src/index.ts:81-82 (registration)Registration of the `ssh_shell_send` tool in the main request handler switch block.
case "ssh_shell_send": return await this.handleShellSend(args);