api_add
Add or update APIs in the monitoring catalog for health checks and authentication configuration within the SFTP Orchestrator server.
Instructions
Ajoute ou met à jour une API dans le catalogue de monitoring.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | Alias unique pour l'API. | |
| url | Yes | URL de base de l'API, incluant le port si nécessaire. | |
| health_check_endpoint | No | Endpoint spécifique pour le test de santé (ex: /health). | |
| health_check_method | No | Méthode HTTP pour le test de santé. | GET |
| auth_method | No | Méthode d'authentification. | none |
| api_key | No | Clé API si nécessaire. | |
| auth_header_name | No | Nom du header pour la clé API. | Authorization |
| auth_scheme | No | Schéma d'authentification (ex: Bearer). Mettre à '' si non applicable. | Bearer |
| htpasswd_user | No | Nom d'utilisateur pour l'authentification Basic (htpasswd). | |
| htpasswd_pass | No | Mot de passe pour l'authentification Basic (htpasswd). | |
| notes | No | Notes additionnelles. |
Implementation Reference
- apis.js:46-68 (handler)Core handler logic for adding or updating an API entry in the JSON store with validation.async function addApi(alias, apiConfig) { await ensureInitialized(); // Validation if (!alias || typeof alias !== 'string') { throw new Error("L'alias doit être une chaîne non vide."); } if (!apiConfig.url) { throw new Error("L'URL de l'API est obligatoire."); } // Valider l'URL try { new URL(apiConfig.url); } catch (e) { throw new Error(`URL invalide: ${apiConfig.url}`); } apis[alias] = apiConfig; await saveApis(); return { success: true, message: `API '${alias}' ajoutée/mise à jour avec succès.` }; }
- server.js:122-136 (schema)Input schema definition for the api_add tool using Zod validation.title: "Ajouter une API au catalogue", description: "Ajoute ou met à jour une API dans le catalogue de monitoring.", inputSchema: z.object({ alias: z.string().describe("Alias unique pour l'API."), url: z.string().url().describe("URL de base de l'API, incluant le port si nécessaire."), health_check_endpoint: z.string().optional().describe("Endpoint spécifique pour le test de santé (ex: /health)."), health_check_method: z.enum(['GET', 'POST']).optional().default('GET').describe("Méthode HTTP pour le test de santé."), auth_method: z.enum(['api_key', 'htpasswd', 'both', 'none']).optional().default('none').describe("Méthode d'authentification."), api_key: z.string().optional().describe("Clé API si nécessaire."), auth_header_name: z.string().optional().default('Authorization').describe("Nom du header pour la clé API."), auth_scheme: z.string().optional().default('Bearer').describe("Schéma d'authentification (ex: Bearer). Mettre à '' si non applicable."), htpasswd_user: z.string().optional().describe("Nom d'utilisateur pour l'authentification Basic (htpasswd)."), htpasswd_pass: z.string().optional().describe("Mot de passe pour l'authentification Basic (htpasswd)."), notes: z.string().optional().describe("Notes additionnelles.") })
- server.js:119-147 (registration)MCP tool registration for 'api_add' with schema and wrapper handler.server.registerTool( "api_add", { title: "Ajouter une API au catalogue", description: "Ajoute ou met à jour une API dans le catalogue de monitoring.", inputSchema: z.object({ alias: z.string().describe("Alias unique pour l'API."), url: z.string().url().describe("URL de base de l'API, incluant le port si nécessaire."), health_check_endpoint: z.string().optional().describe("Endpoint spécifique pour le test de santé (ex: /health)."), health_check_method: z.enum(['GET', 'POST']).optional().default('GET').describe("Méthode HTTP pour le test de santé."), auth_method: z.enum(['api_key', 'htpasswd', 'both', 'none']).optional().default('none').describe("Méthode d'authentification."), api_key: z.string().optional().describe("Clé API si nécessaire."), auth_header_name: z.string().optional().default('Authorization').describe("Nom du header pour la clé API."), auth_scheme: z.string().optional().default('Bearer').describe("Schéma d'authentification (ex: Bearer). Mettre à '' si non applicable."), htpasswd_user: z.string().optional().describe("Nom d'utilisateur pour l'authentification Basic (htpasswd)."), htpasswd_pass: z.string().optional().describe("Mot de passe pour l'authentification Basic (htpasswd)."), notes: z.string().optional().describe("Notes additionnelles.") }) }, async (params) => { try { const { alias, ...apiConfig } = params; const result = await apis.addApi(alias, apiConfig); return { content: [{ type: "text", text: result.message }] }; } catch (e) { return { content: [{ type: "text", text: `ERREUR: ${e.message}` }], isError: true }; } } );
- server.js:138-146 (handler)Wrapper handler for the api_add tool that delegates to apis.addApi and formats MCP response.async (params) => { try { const { alias, ...apiConfig } = params; const result = await apis.addApi(alias, apiConfig); return { content: [{ type: "text", text: result.message }] }; } catch (e) { return { content: [{ type: "text", text: `ERREUR: ${e.message}` }], isError: true }; } }