Skip to main content
Glama
fkom13

MCP SFTP Orchestrator

by fkom13

Exécuter une séquence de commandes (SSH)

task_exec_sequence

Execute multiple SSH commands sequentially on a single remote server to automate server management tasks.

Instructions

Exécute plusieurs commandes SSH en séquence sur le même serveur.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aliasYesAlias du serveur cible.
commandsYesListe des commandes à exécuter en séquence (minimum 1).
continueOnErrorNoContinuer même si une commande échoue.
rappelNoDéfinit un rappel en secondes.

Implementation Reference

  • The primary handler function registered for the 'task_exec_sequence' MCP tool. It queues a job of type 'ssh_sequence', logs it to history, initiates execution via the SSH module, waits for completion (with adjusted timeout), and returns the results or background initiation message.
    async (params) => {
        const job = queue.addJob({ 
            type: 'ssh_sequence', 
            ...params, 
            status: 'pending'
        });
        history.logTask(job);
        ssh.executeCommandSequence(job.id);
    
        const finalJob = await waitForJobCompletion(job.id, config.syncTimeout * params.commands.length);
        if (finalJob) {
            return { content: [{ type: "text", text: `Résultat séquence (tâche ${finalJob.id}):\n${JSON.stringify(finalJob, null, 2)}` }] };
        } else {
            return { content: [{ type: "text", text: `Séquence de commandes ${job.id} initiée en arrière-plan.` }] };
        }
    }
  • Zod input schema validating the tool parameters: server alias, array of commands (simple strings or detailed objects with timeout and continueOnError), global continueOnError flag, and optional reminder seconds.
    inputSchema: z.object({
        alias: z.string().describe("Alias du serveur cible."),
        commands: z.array(z.union([
            z.string(),
            z.object({
                command: z.string(),
                timeout: z.number().optional(),
                continueOnError: z.boolean().optional()
            })
        ])).min(1).describe("Liste des commandes à exécuter en séquence (minimum 1)."),
        continueOnError: z.boolean().optional().default(false).describe("Continuer même si une commande échoue."),
        rappel: z.number().optional().describe("Définit un rappel en secondes.")
    })
  • server.js:580-615 (registration)
    MCP server registration of the 'task_exec_sequence' tool, specifying title, description, input schema, and the inline handler function.
    server.registerTool(
        "task_exec_sequence",
        {
            title: "Exécuter une séquence de commandes (SSH)",
            description: "Exécute plusieurs commandes SSH en séquence sur le même serveur.",
            inputSchema: z.object({
                alias: z.string().describe("Alias du serveur cible."),
                commands: z.array(z.union([
                    z.string(),
                    z.object({
                        command: z.string(),
                        timeout: z.number().optional(),
                        continueOnError: z.boolean().optional()
                    })
                ])).min(1).describe("Liste des commandes à exécuter en séquence (minimum 1)."),
                continueOnError: z.boolean().optional().default(false).describe("Continuer même si une commande échoue."),
                rappel: z.number().optional().describe("Définit un rappel en secondes.")
            })
        },
        async (params) => {
            const job = queue.addJob({ 
                type: 'ssh_sequence', 
                ...params, 
                status: 'pending'
            });
            history.logTask(job);
            ssh.executeCommandSequence(job.id);
    
            const finalJob = await waitForJobCompletion(job.id, config.syncTimeout * params.commands.length);
            if (finalJob) {
                return { content: [{ type: "text", text: `Résultat séquence (tâche ${finalJob.id}):\n${JSON.stringify(finalJob, null, 2)}` }] };
            } else {
                return { content: [{ type: "text", text: `Séquence de commandes ${job.id} initiée en arrière-plan.` }] };
            }
        }
    );
  • Supporting function that implements the sequential SSH command execution logic. Acquires a pooled connection, iterates over commands with per-command timeout/error handling, collects step results, and updates job status accordingly. Called by the tool handler.
    async function executeCommandSequence(jobId) {
        const job = queue.getJob(jobId);
        if (!job) return queue.log('error', `Tâche introuvable: ${jobId}`);
        
        const results = [];
        let connection = null;
        
        try {
            const serverConfig = await serverManager.getServer(job.alias);
            queue.updateJobStatus(jobId, 'running');
            
            // Obtenir une connexion du pool
            connection = await sshPool.getConnection(job.alias, serverConfig);
            
            // Exécuter chaque commande en séquence
            for (let i = 0; i < job.commands.length; i++) {
                const cmd = job.commands[i];
                const stepJob = {
                    ...job,
                    cmd: typeof cmd === 'string' ? cmd : cmd.command,
                    timeout: cmd.timeout || job.timeout,
                    continueOnError: cmd.continueOnError || job.continueOnError
                };
                
                try {
                    queue.log('info', `Exécution étape ${i+1}/${job.commands.length}: ${stepJob.cmd}`);
                    const result = await executeWithPooledConnection(connection, stepJob, `${jobId}_step_${i}`);
                    results.push({ 
                        step: i + 1, 
                        command: stepJob.cmd, 
                        success: true, 
                        ...result 
                    });
                } catch (err) {
                    results.push({ 
                        step: i + 1, 
                        command: stepJob.cmd, 
                        success: false, 
                        error: err.message 
                    });
                    
                    if (!stepJob.continueOnError) {
                        throw new Error(`Échec à l'étape ${i+1}: ${err.message}`);
                    }
                }
            }
            
            queue.updateJobStatus(jobId, 'completed', { results });
            
        } catch (err) {
            queue.updateJobStatus(jobId, 'failed', { 
                error: err.message, 
                results 
            });
        } finally {
            if (connection) {
                sshPool.releaseConnection(connection.id);
            }
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions sequential execution on the same server, it lacks critical details: whether commands run with specific permissions, if there are timeouts or rate limits, what happens on errors beyond the 'continueOnError' parameter, or what the output format looks like. For a tool that executes potentially destructive SSH commands, this is a significant gap in safety and operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence: 'Exécute plusieurs commandes SSH en séquence sur le même serveur.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. Every part of the sentence earns its place by specifying key aspects (multiple commands, SSH, sequential, same server).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing SSH commands, which can be destructive) and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral traits like error handling, security implications, or output format, leaving the agent with insufficient context to use the tool safely and effectively. The high schema coverage helps with parameters, but overall completeness is poor for a command-execution tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters ('alias', 'commands', 'continueOnError', 'rappel') with descriptions. The tool description adds no additional parameter semantics beyond what's in the schema—it doesn't explain parameter interactions, provide examples, or clarify ambiguous terms like 'rappel' (which might mean 'reminder' or 'timeout' in context). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Exécute plusieurs commandes SSH en séquence sur le même serveur' (Execute multiple SSH commands in sequence on the same server). It specifies the verb ('exécute'), resource ('commandes SSH'), and scope ('en séquence sur le même serveur'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'task_exec' or 'task_exec_interactive', which likely have related but different functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'task_exec' (which might execute single commands) or 'task_exec_interactive' (which might provide interactive sessions), nor does it specify prerequisites, constraints, or typical use cases. The agent must infer usage from the name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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