Skip to main content
Glama

task_exec

Execute SSH commands on remote servers through the MCP SFTP Orchestrator. Commands complete directly if under 30 seconds or run in background for longer tasks.

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
NameRequiredDescriptionDefault
aliasYesAlias du serveur cible.
cmdYesLa commande complète à exécuter.
rappelNoDéfinit un rappel en secondes.

Implementation Reference

  • Handler function that queues an SSH execution job using queue.addJob, logs it, executes via ssh.executeCommand, polls for completion with waitForJobCompletion, and returns synchronous result or background initiation message.
    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.` }] }; } } );
  • Tool metadata including title, description, and Zod inputSchema defining parameters: alias (server alias), cmd (command to execute), optional rappel (reminder in seconds).
    { 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.") }) },
  • server.js:427-450 (registration)
    MCP server registration of the 'task_exec' tool, including schema and inline handler implementation.
    "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.` }] }; } } );
  • Helper function used by task_exec (and other tools) to asynchronously wait for job completion with polling and timeout.
    async function waitForJobCompletion(jobId, timeout) { return new Promise((resolve) => { const startTime = Date.now(); const interval = setInterval(() => { const job = queue.getJob(jobId); if (job.status === 'completed' || job.status === 'failed') { clearInterval(interval); resolve(job); } else if (Date.now() - startTime > timeout) { clearInterval(interval); resolve(null); } }, 200); }); }

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/fkom13/mcp-sftp-orchestrator'

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