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
            }))
        };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions retrieval but lacks details on behavioral traits like performance implications (e.g., large data returns, pagination), error handling, or authentication needs. This is a significant gap for a tool that fetches 'all' data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action and resource. Every word earns its place, with no redundancy or fluff, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of retrieving 'all' data and no annotations or output schema, the description is incomplete. It lacks crucial context like return format, size limits, or potential performance issues, which are essential for an agent to use this tool effectively without risk.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately adds no parameter details, maintaining focus on the tool's purpose. Baseline is 4 for zero parameters, as it avoids unnecessary repetition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('retrieve') and resource ('entire knowledge graph: all entities with their observations and relations'), distinguishing it from siblings like search_nodes (which likely filters) or tools that modify the graph (e.g., add_observations). It precisely defines scope without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'entire knowledge graph,' suggesting this tool is for bulk retrieval rather than filtered queries (contrasted with search_nodes). However, it does not explicitly state when not to use it or name alternatives, leaving some inference required.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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