read_graph
Retrieve the complete knowledge graph to access stored user information and conversation history for persistent memory across sessions.
Instructions
Read the entire knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:152-154 (handler)Core handler function that executes the logic for the 'read_graph' tool by loading the knowledge graph from the memory file.async readGraph(): Promise<KnowledgeGraph> { return this.loadGraph(); }
- index.ts:420-427 (registration)Registration of the 'read_graph' tool in the MCP server's tool list, including name, description, and input schema (no parameters required).{ name: "read_graph", description: "Read the entire knowledge graph", inputSchema: { type: "object", properties: {}, }, },
- index.ts:529-530 (handler)MCP CallToolRequest handler case that invokes the readGraph method and returns the result as formatted JSON text content.case "read_graph": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.readGraph(), null, 2) }] };
- index.ts:423-426 (schema)Input schema for the 'read_graph' tool, defining an empty object (no input parameters).inputSchema: { type: "object", properties: {}, },
- index.ts:54-70 (helper)Helper method loadGraph() called by readGraph(), responsible for parsing the JSONL memory file into the KnowledgeGraph structure.private async loadGraph(): Promise<KnowledgeGraph> { try { const data = await fs.readFile(MEMORY_FILE_PATH, "utf-8"); const lines = data.split("\n").filter(line => line.trim() !== ""); return lines.reduce((graph: KnowledgeGraph, line) => { const item = JSON.parse(line); if (item.type === "entity") graph.entities.push(item as Entity); if (item.type === "relation") graph.relations.push(item as Relation); return graph; }, { entities: [], relations: [] }); } catch (error) { if (error instanceof Error && 'code' in error && (error as any).code === "ENOENT") { return { entities: [], relations: [] }; } throw error; } }