Skip to main content
Glama
register-graph-tools-batch3.js‱6.68 kB
// src/tools/graph/register-graph-tools-batch3.ts // Enregistrement des outils graph Batch 3 dans le ToolRegistry import { toolRegistry } from "../../core/tool-registry.js"; import { openNodesHandler, openNodesTool } from "./open-nodes.js"; import { readGraphHandler, readGraphTool } from "./read-graph.js"; import { searchNodesHandler, searchNodesTool } from "./search-nodes.js"; /** * Enregistre tous les outils graph Batch 3 dans le ToolRegistry */ export function registerGraphToolsBatch3() { console.log("📝 Enregistrement des outils graph Batch 3..."); // Enregistrer read_graph try { toolRegistry.register(readGraphTool, readGraphHandler); console.log(`✅ Outil enregistrĂ©: ${readGraphTool.name}`); } catch (error) { console.error(`❌ Erreur lors de l'enregistrement de ${readGraphTool.name}:`, error); } // Enregistrer search_nodes try { toolRegistry.register(searchNodesTool, searchNodesHandler); console.log(`✅ Outil enregistrĂ©: ${searchNodesTool.name}`); } catch (error) { console.error(`❌ Erreur lors de l'enregistrement de ${searchNodesTool.name}:`, error); } // Enregistrer open_nodes try { toolRegistry.register(openNodesTool, openNodesHandler); console.log(`✅ Outil enregistrĂ©: ${openNodesTool.name}`); } catch (error) { console.error(`❌ Erreur lors de l'enregistrement de ${openNodesTool.name}:`, error); } console.log(`🎉 Batch 3 terminĂ©. Outils enregistrĂ©s au total: ${toolRegistry.size()}`); } /** * VĂ©rifie que tous les outils Batch 3 sont correctement enregistrĂ©s */ export function verifyGraphToolsBatch3() { const expectedTools = [ "read_graph", "search_nodes", "open_nodes" ]; console.log("🔍 VĂ©rification des outils graph Batch 3..."); let allRegistered = true; for (const toolName of expectedTools) { if (toolRegistry.hasTool(toolName)) { console.log(`✅ ${toolName} est enregistrĂ©`); } else { console.log(`❌ ${toolName} n'est PAS enregistrĂ©`); allRegistered = false; } } if (allRegistered) { console.log("🎉 Tous les outils Batch 3 sont correctement enregistrĂ©s !"); } else { console.log("⚠ Certains outils Batch 3 ne sont pas enregistrĂ©s"); } return allRegistered; } /** * Test d'intĂ©gration des outils Batch 3 */ export async function testGraphToolsBatch3() { console.log("đŸ§Ș Test d'intĂ©gration des outils graph Batch 3..."); // PrĂ©parer des donnĂ©es de test const testEntity1 = "Test Entity for Batch 3 Read"; const testEntity2 = "Test Entity for Batch 3 Search"; try { // CrĂ©er des entitĂ©s pour les tests console.log("PrĂ©paration: CrĂ©ation des entitĂ©s de test..."); await toolRegistry.execute("create_entities", { entities: [ { name: testEntity1, entityType: "Test", observations: ["Entity for read_graph test"] }, { name: testEntity2, entityType: "SearchTest", observations: ["Entity for search_nodes test"] } ] }); console.log("✅ DonnĂ©es de test prĂ©parĂ©es"); } catch (error) { console.error("❌ Échec de la prĂ©paration des donnĂ©es de test:", error instanceof Error ? error.message : String(error)); return false; } // Test 1: read_graph try { console.log("\nTest 1: read_graph"); const result = await toolRegistry.execute("read_graph", {}); console.log("✅ read_graph fonctionne:", result ? "Oui" : "Non"); } catch (error) { console.error("❌ read_graph a Ă©chouĂ©:", error instanceof Error ? error.message : String(error)); return false; } // Test 2: search_nodes try { console.log("\nTest 2: search_nodes"); const result = await toolRegistry.execute("search_nodes", { query: "SearchTest" }); console.log("✅ search_nodes fonctionne:", result ? "Oui" : "Non"); } catch (error) { console.error("❌ search_nodes a Ă©chouĂ©:", error instanceof Error ? error.message : String(error)); return false; } // Test 3: open_nodes try { console.log("\nTest 3: open_nodes"); const result = await toolRegistry.execute("open_nodes", { names: [testEntity1] }); console.log("✅ open_nodes fonctionne:", result ? "Oui" : "Non"); } catch (error) { console.error("❌ open_nodes a Ă©chouĂ©:", error instanceof Error ? error.message : String(error)); return false; } // Nettoyer les donnĂ©es de test try { console.log("\nNettoyage: Suppression des entitĂ©s de test..."); await toolRegistry.execute("delete_entities", { entityNames: [testEntity1, testEntity2] }); console.log("✅ DonnĂ©es de test nettoyĂ©es"); } catch (error) { console.warn("⚠ Échec du nettoyage des donnĂ©es de test:", error instanceof Error ? error.message : String(error)); } console.log("\n🎉 Tous les tests d'intĂ©gration Batch 3 ont rĂ©ussi !"); return true; } /** * Fonction principale pour initialiser les outils graph Batch 3 */ export function initializeGraphToolsBatch3() { console.log("🚀 Initialisation des outils graph Batch 3..."); // Enregistrer les outils registerGraphToolsBatch3(); // VĂ©rifier l'enregistrement const registered = verifyGraphToolsBatch3(); if (registered) { console.log("✅ Initialisation Batch 3 terminĂ©e avec succĂšs"); console.log(`📊 Outils disponibles: ${toolRegistry.getToolNames().join(', ')}`); console.log(`📈 Total d'outils: ${toolRegistry.size()}`); } else { console.error("❌ Échec de l'initialisation Batch 3"); } } // ExĂ©cution automatique si ce fichier est exĂ©cutĂ© directement if (import.meta.url === `file://${process.argv[1]}`) { initializeGraphToolsBatch3(); // ExĂ©cuter les tests si demandĂ© if (process.argv.includes("--test")) { testGraphToolsBatch3().then(success => { if (success) { console.log("🎉 Tous les tests Batch 3 ont rĂ©ussi !"); process.exit(0); } else { console.error("❌ Certains tests Batch 3 ont Ă©chouĂ©"); process.exit(1); } }); } }

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/ali-48/rag-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server