Skip to main content
Glama

read_graph

Retrieve the complete knowledge graph from the MCP Memory Server to enable LLMs to access and reason over stored information across sessions and conversations.

Instructions

Read the entire knowledge graph

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • MCP tool dispatch handler for 'read_graph' that calls the readGraph method and returns formatted JSON response.
    case "read_graph": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.readGraph(), null, 2) }] };
  • Handler function in KnowledgeGraphManager that executes the core logic for reading the entire knowledge graph by delegating to loadGraph.
    async readGraph(): Promise<KnowledgeGraph> { return this.loadGraph(); }
  • Type definition/schema for the KnowledgeGraph object returned by the read_graph tool.
    interface KnowledgeGraph { entities: Entity[]; relations: Relation[]; }
  • src/index.ts:338-346 (registration)
    Registration of the read_graph tool in the ListTools response, including name, description, and empty input schema.
    { name: "read_graph", description: "Read the entire knowledge graph", inputSchema: { type: "object", properties: {}, }, }, {
  • Private helper method that loads the knowledge graph from the memory JSON lines file, handling file not found gracefully.
    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; }

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/StevenWangler/mcp-memory-server'

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