Skip to main content
Glama
fkom13

MCP SFTP Orchestrator

by fkom13

Vérifier la santé d'une API via son alias

api_check

Test API health status from the catalog to verify connectivity and functionality using the MCP SFTP Orchestrator server.

Instructions

Lance un test de santé sur une API du catalogue.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aliasYesAlias de l'API à tester.
server_aliasYesAlias du serveur depuis lequel lancer le test.

Implementation Reference

  • The handler function for the 'api_check' tool. It retrieves the API configuration, builds a customized curl command for the health check endpoint (supporting GET/POST, htpasswd, API key auth), executes it remotely via SSH on the specified server using the queue system, parses the HTTP code and response time, and returns a structured result.
    async (params) => {
        try {
            const apiConfig = await apis.getApi(params.alias);
            const endpoint = apiConfig.health_check_endpoint || '';
            const url = `${apiConfig.url}${endpoint}`;
            const method = apiConfig.health_check_method || 'GET';
            
            let curlCmd = `curl -X ${method} -o /dev/null -s -w '%{http_code}:%{time_total}'`;
    
            // Gérer l'authentification htpasswd
            if ((apiConfig.auth_method === 'htpasswd' || apiConfig.auth_method === 'both') && apiConfig.htpasswd_user && apiConfig.htpasswd_pass) {
                curlCmd += ` -u ${apiConfig.htpasswd_user}:${apiConfig.htpasswd_pass}`;
            }
    
            // Gérer l'authentification par clé API
            if ((apiConfig.auth_method === 'api_key' || apiConfig.auth_method === 'both') && apiConfig.api_key) {
                const scheme = apiConfig.auth_scheme ? `${apiConfig.auth_scheme} ` : '';
                curlCmd += ` -H '${apiConfig.auth_header_name || 'Authorization'}: ${scheme}${apiConfig.api_key}'`;
            }
            
            curlCmd += ` ${url}`;
    
            const job = queue.addJob({ type: 'ssh', alias: params.server_alias, cmd: curlCmd });
            ssh.executeCommand(job.id);
            const result = await waitForJobCompletion(job.id, config.syncTimeout);
    
            if (!result || result.status !== 'completed') {
                throw new Error(result ? result.error : `Timeout de la commande de monitoring pour ${params.alias}`);
            }
    
            const parsedOutput = ssh.parseApiHealth(result.output);
            return { content: [{ type: "text", text: JSON.stringify(parsedOutput, null, 2) }] };
        } catch (e) {
            return { content: [{ type: "text", text: `ERREUR: ${e.message}` }], isError: true };
        }
    }
  • Zod schema defining the input parameters: 'alias' (string, API alias to test) and 'server_alias' (string, server alias from which to run the curl command).
    inputSchema: z.object({
        alias: z.string().describe("Alias de l'API à tester."),
        server_alias: z.string().describe("Alias du serveur depuis lequel lancer le test.")
    })
  • server.js:181-227 (registration)
    The server.registerTool call that registers the 'api_check' tool with the MCP server, including name, metadata (title, description), input schema, and inline handler function.
    server.registerTool(
        "api_check",
        {
            title: "Vérifier la santé d'une API via son alias",
            description: "Lance un test de santé sur une API du catalogue.",
            inputSchema: z.object({
                alias: z.string().describe("Alias de l'API à tester."),
                server_alias: z.string().describe("Alias du serveur depuis lequel lancer le test.")
            })
        },
        async (params) => {
            try {
                const apiConfig = await apis.getApi(params.alias);
                const endpoint = apiConfig.health_check_endpoint || '';
                const url = `${apiConfig.url}${endpoint}`;
                const method = apiConfig.health_check_method || 'GET';
                
                let curlCmd = `curl -X ${method} -o /dev/null -s -w '%{http_code}:%{time_total}'`;
    
                // Gérer l'authentification htpasswd
                if ((apiConfig.auth_method === 'htpasswd' || apiConfig.auth_method === 'both') && apiConfig.htpasswd_user && apiConfig.htpasswd_pass) {
                    curlCmd += ` -u ${apiConfig.htpasswd_user}:${apiConfig.htpasswd_pass}`;
                }
    
                // Gérer l'authentification par clé API
                if ((apiConfig.auth_method === 'api_key' || apiConfig.auth_method === 'both') && apiConfig.api_key) {
                    const scheme = apiConfig.auth_scheme ? `${apiConfig.auth_scheme} ` : '';
                    curlCmd += ` -H '${apiConfig.auth_header_name || 'Authorization'}: ${scheme}${apiConfig.api_key}'`;
                }
                
                curlCmd += ` ${url}`;
    
                const job = queue.addJob({ type: 'ssh', alias: params.server_alias, cmd: curlCmd });
                ssh.executeCommand(job.id);
                const result = await waitForJobCompletion(job.id, config.syncTimeout);
    
                if (!result || result.status !== 'completed') {
                    throw new Error(result ? result.error : `Timeout de la commande de monitoring pour ${params.alias}`);
                }
    
                const parsedOutput = ssh.parseApiHealth(result.output);
                return { content: [{ type: "text", text: JSON.stringify(parsedOutput, null, 2) }] };
            } catch (e) {
                return { content: [{ type: "text", text: `ERREUR: ${e.message}` }], isError: true };
            }
        }
    );
  • Helper function ssh.parseApiHealth parses the curl output (format 'HTTP_CODE:time_total') into a structured object with status ('UP'/'DOWN'/'ERROR'), http_code, response_time_ms, handling errors gracefully. Exported from ssh.js and used in the api_check handler.
    function parseApiHealth(output) {
        if (!output || typeof output !== 'string') {
            return { 
                status: 'ERROR', 
                http_code: 0, 
                response_time_ms: 0, 
                error: 'Sortie invalide ou vide' 
            };
        }
        
        try {
            const parts = output.trim().split(':');
            if (parts.length !== 2) {
                return {
                    status: 'ERROR',
                    http_code: 0,
                    response_time_ms: 0,
                    error: 'Format de réponse invalide',
                    raw_output: output
                };
            }
            
            const [codeStr, timeStr] = parts;
            const http_code = parseInt(codeStr, 10);
            const response_time_ms = parseFloat(timeStr) * 1000;
            
            if (isNaN(http_code) || isNaN(response_time_ms)) {
                return {
                    status: 'ERROR',
                    http_code: 0,
                    response_time_ms: 0,
                    error: 'Valeurs non numériques',
                    raw_output: output
                };
            }
    
            return {
                status: http_code >= 200 && http_code < 300 ? 'UP' : 'DOWN',
                http_code: http_code,
                response_time_ms: Math.round(response_time_ms)
            };
        } catch (e) {
            return { 
                status: 'ERROR', 
                http_code: 0, 
                response_time_ms: 0, 
                error: e.message, 
                raw_output: output 
            };
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions launching a health test but doesn't describe what the test entails, what kind of response to expect, whether it's read-only or has side effects, or any performance characteristics. This leaves significant gaps for an agent to understand the tool's behavior.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple tool and front-loads the essential information.

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?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the health test involves, what results to expect, or how this differs from similar tools. Given the complexity of API health checking and the lack of structured metadata, more context is needed for effective use.

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?

The input schema has 100% description coverage, clearly documenting both required parameters. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline expectation but doesn't provide extra value like explaining parameter relationships or usage examples.

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 action ('Lance un test de santé') and target ('sur une API du catalogue'), which is specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'check_api_health' which appears to serve a similar purpose, leaving some ambiguity about tool selection.

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 like 'check_api_health' or other monitoring tools in the sibling list. It states what the tool does but offers no context about appropriate use cases or prerequisites.

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