Skip to main content
Glama
fkom13

MCP SFTP Orchestrator

by fkom13

Vérifier la santé d'une API

check_api_health

Monitor HTTP/S endpoint availability and response time from remote servers to verify API health status.

Instructions

Vérifie la disponibilité et le temps de réponse d'un endpoint HTTP/S.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aliasYesAlias du serveur depuis lequel lancer le test.
urlYesURL complète de l'endpoint à tester.

Implementation Reference

  • The main handler function that implements the check_api_health tool. It runs a curl command via SSH on the specified server to test the API endpoint's availability and response time, parses the result using ssh.parseApiHealth, and returns formatted JSON output or error.
    async (params) => {
        try {
            const cmd = `curl -o /dev/null -s -w '%{http_code}:%{time_total}' ${params.url}`;
            const job = queue.addJob({
                type: 'ssh',
                alias: params.alias,
                cmd: cmd
            });
            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) {
            const errorPayload = {
                toolName: "check_api_health",
                errorCode: "MONITORING_ERROR",
                errorMessage: e.message
            };
            return { content: [{ type: "text", text: JSON.stringify(errorPayload, null, 2) }], isError: true };
        }
    }
  • Zod input schema defining parameters: 'alias' for server alias and 'url' for the HTTP endpoint to check.
    inputSchema: z.object({
        alias: z.string().describe("Alias du serveur depuis lequel lancer le test."),
        url: z.string().url().describe("URL complète de l'endpoint à tester.")
    })
  • server.js:303-339 (registration)
    Registration of the 'check_api_health' tool using server.registerTool, including title, description, schema, and handler function.
    server.registerTool(
        "check_api_health",
        {
            title: "Vérifier la santé d'une API",
            description: "Vérifie la disponibilité et le temps de réponse d'un endpoint HTTP/S.",
            inputSchema: z.object({
                alias: z.string().describe("Alias du serveur depuis lequel lancer le test."),
                url: z.string().url().describe("URL complète de l'endpoint à tester.")
            })
        },
        async (params) => {
            try {
                const cmd = `curl -o /dev/null -s -w '%{http_code}:%{time_total}' ${params.url}`;
                const job = queue.addJob({
                    type: 'ssh',
                    alias: params.alias,
                    cmd: cmd
                });
                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) {
                const errorPayload = {
                    toolName: "check_api_health",
                    errorCode: "MONITORING_ERROR",
                    errorMessage: e.message
                };
                return { content: [{ type: "text", text: JSON.stringify(errorPayload, null, 2) }], isError: true };
            }
        }
    );
  • Helper function parseApiHealth parses the output from the curl command to extract HTTP status code and response time in ms, determining if the API is 'UP' or 'DOWN', with comprehensive error handling.
    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 but only states what the tool does, not how it behaves. It doesn't disclose whether this is a read-only operation, what permissions are needed, if it makes network calls, what happens on failure, or typical response formats. For a tool that likely performs external HTTP requests, this is a significant gap.

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 with zero wasted words. It's appropriately sized for a simple monitoring 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.

Completeness3/5

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

For a simple health-check tool with 2 parameters and no output schema, the description covers the basic purpose adequately. However, without annotations or output schema, it should ideally provide more behavioral context about what 'disponibilité' and 'temps de réponse' mean in practice and what the tool returns.

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 both parameters thoroughly. The description adds no additional meaning about parameters beyond implying they're used for testing an endpoint. 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 with specific verbs ('vérifie la disponibilité et le temps de réponse') and identifies the resource ('un endpoint HTTP/S'). It distinguishes from siblings like 'api_check' by specifying health monitoring aspects rather than generic checking, though not explicitly contrasting them.

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 'api_check' or 'get_services_status'. It lacks context about prerequisites, typical scenarios, or exclusions, leaving the agent to infer usage from the purpose 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