Skip to main content
Glama
T1nker-1220

Knowledge Graph Memory Server

read_graph

Retrieve the complete knowledge graph to access stored information, enabling seamless continuity and enhanced interaction in chat systems using persistent memory.

Instructions

Read the entire knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'read_graph' tool. Simply delegates to loadGraph() to retrieve the entire knowledge graph.
    async readGraph(): Promise<KnowledgeGraph> { return this.loadGraph(); }
  • Core helper function that implements the graph loading logic: reads from memory and lesson files, parses JSON lines, merges entities and relations, handles caching and missing files gracefully.
    private async loadGraph(): Promise<KnowledgeGraph> { const cacheKey = this.getCacheKey('loadGraph'); const cached = this.cache.get<KnowledgeGraph>(cacheKey); if (cached) return cached; try { const graph: KnowledgeGraph = { entities: [], relations: [] }; const memoryFiles = await this.fileManager.getFilesForEntityType('memory'); const lessonFiles = await this.fileManager.getFilesForEntityType('lesson'); const allFiles = [...memoryFiles, ...lessonFiles]; for (const filePath of allFiles) { const data = await fs.readFile(filePath, 'utf-8'); const lines = data.split('\n').filter(line => line.trim() !== ''); for (const line of lines) { 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); } } this.cache.set(cacheKey, graph); return graph; } catch (error) { if (error instanceof Error && 'code' in error && (error as any).code === 'ENOENT') { const emptyGraph = { entities: [], relations: [] }; this.cache.set(cacheKey, emptyGraph); return emptyGraph; } throw error; }
  • index.ts:1062-1069 (registration)
    Tool registration in ListTools response, defining name, description, and empty input schema (no parameters required).
    { name: "read_graph", description: "Read the entire knowledge graph", inputSchema: { type: "object", properties: {}, }, },
  • index.ts:1238-1239 (registration)
    Dispatch handler in CallToolRequestSchema that executes the tool by calling knowledgeGraphManager.readGraph() and formatting the JSON response.
    case "read_graph": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.readGraph(), null, 2) }] };

Other Tools

Related Tools

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/T1nker-1220/memories-with-lessons-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server