Skip to main content
Glama

read_graph

Retrieve the entire knowledge graph including all entities, their observations, and relationships from the Memento MCP server for comprehensive data analysis and information retrieval.

Instructions

Retrieve the entire knowledge graph: all entities with their observations and relations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'read_graph': registers the tool with no input params, executes KnowledgeGraphManager.readGraph(), and returns the result as formatted JSON text.
    this.tool( 'read_graph', 'Retrieve the entire knowledge graph: all entities with their observations and relations.', {}, async () => ({ content: [{ type: 'text', text: JSON.stringify( await this.#knowledgeGraphManager.readGraph(), null, 2 ) }] })
  • src/server.js:159-172 (registration)
    Registration of the 'read_graph' MCP tool using McpServer.tool() method.
    this.tool( 'read_graph', 'Retrieve the entire knowledge graph: all entities with their observations and relations.', {}, async () => ({ content: [{ type: 'text', text: JSON.stringify( await this.#knowledgeGraphManager.readGraph(), null, 2 ) }] })
  • KnowledgeGraphManager.readGraph(): thin wrapper delegating to the repository implementation.
    readGraph() { return this.#repository.readGraph(); }
  • PostgreSQL-specific implementation of readGraph(): queries entities, observations, and relations from database and assembles the graph object.
    async readGraph() { /** * @type {[{entitytype:string, name:string, id}]} */ const entities = await this.#query('SELECT * FROM entities', []); const observations = await this.#query('SELECT entity_id, content FROM observations', []); /** * @type {[{from_name: string, to_name: string, relationtype: string}]} */ const relations = await this.#query( `SELECT r.from_id, r.to_id, r.relationtype, ef.name AS from_name, et.name AS to_name FROM relations r JOIN entities ef ON ef.id = r.from_id JOIN entities et ON et.id = r.to_id`, [] ); return { entities: entities.map(e => ({ name: e.name, entityType: e.entitytype, observations: observations .filter(o => o.entity_id === e.id) .map(o => o.content) })), relations: relations.map(rel => ({ from: rel.from_name, to: rel.to_name, relationType: rel.relationtype })) }; }
  • SQLite-specific implementation of readGraph(): queries entities, observations, and relations from database and assembles the graph object.
    async readGraph() { const entities = await this.db.all('SELECT * FROM entities'); const observations = await this.db.all('SELECT entity_id, content FROM observations'); /** * * @type {[{from_name, to_name, relationType}]} */ const relations = await this.db.all(` SELECT r.from_id, r.to_id, r.relationType, ef.name AS from_name, et.name AS to_name FROM relations r JOIN entities ef ON ef.id = r.from_id JOIN entities et ON et.id = r.to_id `); return { entities: entities.map(entity => ({ name: entity.name, entityType: entity.entityType, observations: observations .filter(obs => obs.entity_id === entity.id) .map(obs => obs.content) })), relations: relations.map(rel => ({ from: rel.from_name, to: rel.to_name, relationType: rel.relationType })) }; }

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/iAchilles/memento'

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