Skip to main content
Glama

open_nodes

Retrieve specific entities from a knowledge graph by providing their names. This tool enables access to structured information for semantic search and analysis within codebases.

Instructions

Open specific nodes in the knowledge graph by their names

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYesAn array of entity names to retrieve

Implementation Reference

  • The main handler for the 'open_nodes' tool. Validates the input 'names' array and calls knowledgeGraphManager.openNodes to retrieve the subgraph for specified nodes, formatting the result as a JSON string in the tool response.
    export const openNodesHandler = async (args) => { if (!args.names || !Array.isArray(args.names)) { throw new Error("The 'names' parameter is required and must be an array"); } // Valider chaque nom for (const name of args.names) { if (!name || typeof name !== 'string') { throw new Error("Each name must be a non-empty string"); } } try { const nodes = await knowledgeGraphManager.openNodes(args.names); return { content: [{ type: "text", text: JSON.stringify(nodes, null, 2) }] }; } catch (error) { console.error("Error in open_nodes tool:", error); throw error; } };
  • Tool schema definition for 'open_nodes', specifying the input schema requiring an array of node names.
    export const openNodesTool = { name: "open_nodes", description: "Open specific nodes in the knowledge graph by their names", inputSchema: { type: "object", properties: { names: { type: "array", items: { type: "string" }, description: "An array of entity names to retrieve" }, }, required: ["names"], }, };
  • Core helper method in KnowledgeGraphManager that loads the graph from file, filters entities by exact name matches, includes only relations between those entities, and returns the induced subgraph.
    async openNodes(names) { const graph = await this.loadGraph(); // Filter entities const filteredEntities = graph.entities.filter(e => names.includes(e.name)); // Create a Set of filtered entity names for quick lookup const filteredEntityNames = new Set(filteredEntities.map(e => e.name)); // Filter relations to only include those between filtered entities const filteredRelations = graph.relations.filter(r => filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to)); const filteredGraph = { entities: filteredEntities, relations: filteredRelations, }; return filteredGraph; }
  • The 'open_nodes' tool is listed among the expected tools to be automatically discovered and registered by the AutoRegistry system, which scans tool directories and registers Tool/Handler pairs.
    export function getExpectedTools() { return [ // Outils Graph (9 outils) 'create_entities', 'create_relations', 'add_observations', 'delete_entities', 'delete_observations', 'delete_relations', 'read_graph', 'search_nodes', 'open_nodes', // Outils RAG (5 outils - avec injection_rag comme outil principal) 'injection_rag', // Nouvel outil principal 'index_project', // Alias déprécié (rétrocompatibilité) 'search_code', 'manage_projects', 'update_project' ];

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