open_nodes
Retrieve specific entities from a knowledge graph by their names to access stored information and relationships.
Instructions
Open specific nodes in the knowledge graph by their names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| names | Yes | An array of entity names to retrieve | |
| memoryFilePath | Yes | The path to the memory file |
Implementation Reference
- index.ts:259-282 (handler)Core implementation of the 'open_nodes' tool: loads the knowledge graph, filters to include only specified entity names and relations between them, returns the subgraph.async openNodes(names: string[], filepath: string): Promise<KnowledgeGraph> { await this.setMemoryFilePath(filepath); 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: KnowledgeGraph = { entities: filteredEntities, relations: filteredRelations, }; return filteredGraph; }
- index.ts:559-578 (registration)Registers the 'open_nodes' tool in the ListTools response, including name, description, and input schema.{ 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", }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["names", "memoryFilePath"], }, },
- index.ts:708-723 (handler)Dispatches CallToolRequest for 'open_nodes' by calling the openNodes method on KnowledgeGraphManager and serializing the result.case "open_nodes": return { content: [ { type: "text", text: JSON.stringify( await knowledgeGraphManager.openNodes( args.names as string[], args.memoryFilePath as string ), null, 2 ), }, ], };