open_nodes
Retrieve specific entity data by querying node names in the Knowledge Graph Memory Server, enabling persistent memory across interactions.
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 |
Implementation Reference
- src/memory/index.ts:201-220 (handler)Core handler function in KnowledgeGraphManager that filters the knowledge graph to retrieve only the specified entities (nodes) and the relations connecting them.async openNodes(names: string[]): Promise<KnowledgeGraph> { 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;
- src/memory/index.ts:434-453 (registration)Registers the 'open_nodes' MCP tool, including input/output schemas and a thin handler wrapper that calls KnowledgeGraphManager.openNodes and formats the response.server.registerTool( "open_nodes", { title: "Open Nodes", description: "Open specific nodes in the knowledge graph by their names", inputSchema: { names: z.array(z.string()).describe("An array of entity names to retrieve") }, outputSchema: { entities: z.array(EntitySchema), relations: z.array(RelationSchema) } }, async ({ names }) => { const graph = await knowledgeGraphManager.openNodes(names); return { content: [{ type: "text" as const, text: JSON.stringify(graph, null, 2) }], structuredContent: { ...graph } }; }