api_add
Add or update APIs in the monitoring catalog for health checks and authentication configuration within the SFTP Orchestrator server management system.
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
- server.js:119-147 (registration)Registration of the 'api_add' tool, including input schema validation using Zod and a thin handler that calls apis.addApiserver.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 }; } } );
- apis.js:46-68 (handler)Core implementation of API addition: initializes data, validates alias and URL, stores config in memory map, persists to JSON file, returns success messageasync 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.` }; }