Skip to main content
Glama

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

Implementation Reference

  • 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.` }] }; } } );
  • 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.` }] }; } } );

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