Skip to main content
Glama
fkom13

MCP SFTP Orchestrator

by fkom13

tail_file

Display the last lines of a remote file on an SFTP server to monitor logs or check recent file content changes.

Instructions

Équivalent de tail -n pour afficher les dernières lignes d'un fichier distant.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aliasYesAlias du serveur cible.
filepathYesChemin absolu du fichier à lire.
linesNoNombre de lignes à afficher.

Implementation Reference

  • The handler function for the 'tail_file' tool. It constructs a 'tail -n' command using the provided parameters and executes it via SSH on the specified server alias, queuing the job and waiting for completion.
    async (params) => {
        const cmd = `tail -n ${params.lines} ${params.filepath}`;
        const job = queue.addJob({ type: 'ssh', alias: params.alias, cmd: cmd, streaming: false });
        history.logTask(job);
        ssh.executeCommand(job.id);
    
        const finalJob = await waitForJobCompletion(job.id, config.syncTimeout);
        if (finalJob) {
            return { content: [{ type: "text", text: `📄 Contenu de ${params.filepath} (${finalJob.lineCount || 0} lignes):\n\n${finalJob.output || '(vide)'}` }] };
        } else {
            return { content: [{ type: "text", text: `Tâche ${job.id} initiée en arrière-plan.` }] };
        }
    }
  • Zod schema defining the input parameters for the 'tail_file' tool: server alias, file path, and optional number of lines (default 50).
    inputSchema: z.object({
        alias: z.string().describe("Alias du serveur cible."),
        filepath: z.string().describe("Chemin absolu du fichier à lire."),
        lines: z.number().optional().default(50).describe("Nombre de lignes à afficher.")
    })
  • server.js:768-792 (registration)
    Registration of the 'tail_file' tool on the MCP server, including title, description, input schema, and inline handler function.
    server.registerTool(
        "tail_file",
        {
            title: "Afficher les dernières lignes d'un fichier",
            description: "Équivalent de tail -n pour afficher les dernières lignes d'un fichier distant.",
            inputSchema: z.object({
                alias: z.string().describe("Alias du serveur cible."),
                filepath: z.string().describe("Chemin absolu du fichier à lire."),
                lines: z.number().optional().default(50).describe("Nombre de lignes à afficher.")
            })
        },
        async (params) => {
            const cmd = `tail -n ${params.lines} ${params.filepath}`;
            const job = queue.addJob({ type: 'ssh', alias: params.alias, cmd: cmd, streaming: false });
            history.logTask(job);
            ssh.executeCommand(job.id);
    
            const finalJob = await waitForJobCompletion(job.id, config.syncTimeout);
            if (finalJob) {
                return { content: [{ type: "text", text: `📄 Contenu de ${params.filepath} (${finalJob.lineCount || 0} lignes):\n\n${finalJob.output || '(vide)'}` }] };
            } else {
                return { content: [{ type: "text", text: `Tâche ${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