api_remove
Remove an API from the catalog using its alias to manage and clean up API endpoints in the SFTP Orchestrator server.
Instructions
Supprime une API du catalogue en utilisant son alias.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | Alias de l'API à supprimer. |
Implementation Reference
- server.js:162-179 (registration)Registration of the 'api_remove' MCP tool, including title, description, input schema (alias string), and handler that calls apis.removeApiserver.registerTool( "api_remove", { title: "Supprimer une API du catalogue", description: "Supprime une API du catalogue en utilisant son alias.", inputSchema: z.object({ alias: z.string().describe("Alias de l'API à supprimer.") }) }, async (params) => { try { const result = await apis.removeApi(params.alias); return { content: [{ type: "text", text: result.message }] }; } catch (e) { return { content: [{ type: "text", text: `ERREUR: ${e.message}` }], isError: true }; } } );
- apis.js:87-95 (handler)Core implementation of API removal: checks existence, deletes from in-memory store, persists to apis.json file, returns success messageasync function removeApi(alias) { await ensureInitialized(); if (!apis[alias]) { throw new Error(`L'alias d'API '${alias}' est inconnu.`); } delete apis[alias]; await saveApis(); return { success: true, message: `API '${alias}' supprimée avec succès.` }; }
- server.js:164-170 (schema)Input schema validation using Zod: requires 'alias' as string with description{ title: "Supprimer une API du catalogue", description: "Supprime une API du catalogue en utilisant son alias.", inputSchema: z.object({ alias: z.string().describe("Alias de l'API à supprimer.") }) },
- apis.js:36-43 (helper)Helper function to persist the APIs object to JSON file, called after removalasync function saveApis() { await ensureInitialized(); try { await fs.writeFile(APIS_FILE, JSON.stringify(apis, null, 2)); } catch (err) { console.error("Erreur lors de la sauvegarde de apis.json:", err); } }
- apis.js:27-33 (helper)Initialization helper ensuring APIs are loaded from file before operations like removeApiasync function ensureInitialized() { if (isInitialized) return; if (!initPromise) { initPromise = loadApis().then(() => { isInitialized = true; }); } return initPromise; }