Skip to main content
Glama

open_nodes

Expand entities to retrieve full details, observations, and relations from Memento's offline memory storage.

Instructions

Expand specified entities: return their full details including observations and relations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYesNames of entities to expand.

Implementation Reference

  • src/server.js:202-219 (registration)
    MCP tool registration for 'open_nodes', including input schema using Zod, description, and handler function that calls knowledgeGraphManager.openNodes and returns JSON response.
    // Tool: open_nodes
    this.tool(
        'open_nodes',
        'Expand specified entities: return their full details including observations and relations.',
        {
            names: z.array(z.string()).describe('Names of entities to expand.')
        },
        async ({ names }) => ({
            content: [{
                type: 'text',
                text: JSON.stringify(
                    await this.#knowledgeGraphManager.openNodes(names),
                    null,
                    2
                )
            }]
        })
    );
  • Zod input schema for the open_nodes tool: array of entity names.
        names: z.array(z.string()).describe('Names of entities to expand.')
    },
  • Knowledge graph manager method that delegates openNodes call to the underlying repository implementation.
    async openNodes(names) {
        return this.#repository.openNodes(names);
    }
  • PostgreSQL repository implementation of openNodes: queries entities by names, their observations, and relations between them, formats into {entities, relations} structure.
    async openNodes(names) {
        if (!names.length) {
            return { entities: [], relations: [] };
        }
    
        /**
         * @type {[{entitytype, id, name}]}
         */
        const entities = await this.#query(
            `SELECT *
             FROM entities
             WHERE name = ANY ($1)`,
            [ names ]
        );
    
        if (!entities.length) {
            return { entities: [], relations: [] };
        }
    
        const ids = entities.map(e => e.id);
    
        const observations = await this.#query(
            `SELECT entity_id, content
             FROM observations
             WHERE entity_id = ANY ($1)`,
            [ ids ]
        );
    
        /**
         * @type {[{name, from_name, to_name, relationtype}]}
         */
        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
             WHERE r.from_id = ANY ($1)
               AND r.to_id = ANY ($1)`,
            [ ids ]
        );
    
        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 repository implementation of openNodes: similar to Postgres, queries entities by names, observations, and mutual relations using parameterized queries.
    async openNodes(names) {
        if (!names.length) {
            return { entities: [], relations: [] };
        }
    
        const placeholders = names.map(() => '?').join(',');
        const entities = await this.db.all(
            `SELECT * FROM entities WHERE name IN (${placeholders})`,
            names
        );
    
        if (!entities.length) {
            return { entities: [], relations: [] };
        }
    
        const ids = entities.map(e => e.id);
        const idPlaceholders = ids.map(() => '?').join(',');
        const observations = await this.db.all(
            `SELECT entity_id, content FROM observations WHERE entity_id IN (${idPlaceholders})`,
            ids
        );
        /**
         *
         * @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
             WHERE r.from_id IN (${idPlaceholders}) AND r.to_id IN (${idPlaceholders})`,
            [...ids, ...ids]
        );
    
        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(relation => ({
                from: relation.from_name,
                to: relation.to_name,
                relationType: relation.relationType
            }))
        };
  • JSDoc type definition specifying the input (string[] names) and output structure for the openNodes method.
    * @property {(names: string[]) => Promise<{ entities: Array<{ name: string, entityType: string, observations: string[] }>, relations: Array<{ from: string, to: string, relationType: string }> }>} openNodes
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions returning 'full details including observations and relations', which hints at read-only behavior, but doesn't clarify if this is a safe operation, if it requires permissions, or how it handles errors (e.g., invalid names). More behavioral context is needed for a mutation-free tool.

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 directly states the tool's function and output. It's front-loaded with the action and result, with no wasted words, making it highly concise and well-structured.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain the return format (e.g., structure of details, observations, relations), error handling, or prerequisites. For a tool that likely returns complex data, more context is needed to guide effective use.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents the 'names' parameter as an array of strings. The description implies that these names refer to 'entities to expand', adding minimal context about what entities are, but doesn't provide additional syntax or format details beyond what the schema offers.

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

Purpose4/5

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

The description clearly states the action ('Expand') and what it returns ('full details including observations and relations'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'read_graph' or 'search_nodes', which might also retrieve entity details, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'read_graph' and 'search_nodes' that likely handle entity data, there's no indication of when 'open_nodes' is preferred, such as for specific expansion needs or in contrast to broader queries.

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