task_exec
Execute SSH commands on remote servers via MCP SFTP Orchestrator, returning immediate results for quick tasks or queuing longer operations for background processing.
Instructions
Exécute une commande SSH. Si la tâche prend moins de 30s, le résultat est direct. Sinon, elle passe en arrière-plan.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | Alias du serveur cible. | |
| cmd | Yes | La commande complète à exécuter. | |
| rappel | No | Définit un rappel en secondes. |
Implementation Reference
- server.js:437-450 (handler)Handler function that creates an SSH job in the queue, logs it to history, executes it using ssh.executeCommand, and either returns the direct result if quick or notifies it's backgrounded.async (params) => { const job = queue.addJob({ type: 'ssh', ...params, status: 'pending' }); history.logTask(job); ssh.executeCommand(job.id); const finalJob = await waitForJobCompletion(job.id, config.syncTimeout); if (finalJob) { return { content: [{ type: "text", text: `Résultat direct (tâche ${finalJob.id}): ${finalJob.output || JSON.stringify(finalJob, null, 2)}` }] }; } else { return { content: [{ type: "text", text: `Tâche d'exécution ${job.id} initiée en arrière-plan.` }] }; } } );
- server.js:431-436 (schema)Zod input schema defining parameters for task_exec: server alias, command to execute, and optional reminder in seconds.inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), cmd: z.string().describe("La commande complète à exécuter."), rappel: z.number().optional().describe("Définit un rappel en secondes.") }) },
- server.js:426-450 (registration)MCP server registration of the task_exec tool, including title, description, input schema, and handler reference.server.registerTool( "task_exec", { title: "Exécuter une commande à distance (SSH)", description: `Exécute une commande SSH. Si la tâche prend moins de ${config.syncTimeout / 1000}s, le résultat est direct. Sinon, elle passe en arrière-plan.`, inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), cmd: z.string().describe("La commande complète à exécuter."), rappel: z.number().optional().describe("Définit un rappel en secondes.") }) }, async (params) => { const job = queue.addJob({ type: 'ssh', ...params, status: 'pending' }); history.logTask(job); ssh.executeCommand(job.id); const finalJob = await waitForJobCompletion(job.id, config.syncTimeout); if (finalJob) { return { content: [{ type: "text", text: `Résultat direct (tâche ${finalJob.id}): ${finalJob.output || JSON.stringify(finalJob, null, 2)}` }] }; } else { return { content: [{ type: "text", text: `Tâche d'exécution ${job.id} initiée en arrière-plan.` }] }; } } );