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
| Name | Required | Description | Default |
|---|---|---|---|
| names | Yes | An array of entity names to retrieve |
Input Schema (JSON Schema)
{
"properties": {
"names": {
"description": "An array of entity names to retrieve",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"names"
],
"type": "object"
}
Implementation Reference
- src/memory/index.ts:201-221 (handler)The core implementation of the openNodes function in KnowledgeGraphManager class that filters entities by name and returns related relationsasync 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:433-454 (registration)MCP tool registration for open_nodes including input/output schemas and handler function// Register open_nodes tool 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 } }; } );
- src/memory/index.ts:50-65 (schema)TypeScript interfaces defining the KnowledgeGraph structure including Entity and Relation types used by open_nodesexport interface Entity { name: string; entityType: string; observations: string[]; } export interface Relation { from: string; to: string; relationType: string; } export interface KnowledgeGraph { entities: Entity[]; relations: Relation[]; }
- src/memory/index.ts:227-237 (schema)Zod validation schemas for Entity and Relation used in input/output validationconst EntitySchema = z.object({ name: z.string().describe("The name of the entity"), entityType: z.string().describe("The type of the entity"), observations: z.array(z.string()).describe("An array of observation contents associated with the entity") }); const RelationSchema = z.object({ from: z.string().describe("The name of the entity where the relation starts"), to: z.string().describe("The name of the entity where the relation ends"), relationType: z.string().describe("The type of the relation") });