Skip to main content
Glama
IzumiSy

MCP DuckDB Knowledge Graph Memory Server

open_nodes

Retrieve specific knowledge graph entities by name to access stored information in DuckDB for conversation memory and data queries.

Instructions

Open specific nodes in the knowledge graph by their names

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYesAn array of entity names to retrieve

Implementation Reference

  • Implementation of the openNodes method in KnowledgeGraphManager. Retrieves entities by names using SQL queries, groups observations, fetches related relations, and returns a KnowledgeGraph.
    async openNodes(names: string[]): Promise<KnowledgeGraph> {
      if (names.length === 0) {
        return { entities: [], relations: [] };
      }
    
      try {
        using conn = await this.getConn();
    
        // Create placeholders
        const placeholders = names.map(() => "?").join(",");
    
        // Retrieve entities and observations at once using LEFT JOIN
        const reader = await conn.executeAndReadAll(
          `
          SELECT e.name, e.entityType, o.content
          FROM entities e
          LEFT JOIN observations o ON e.name = o.entityName
          WHERE e.name IN (${placeholders})
        `,
          names
        );
        const rows = reader.getRows();
    
        // Group results by entity
        const entitiesMap = new Map<string, Entity>();
    
        for (const row of rows) {
          const name = row[0] as string;
          const entityType = row[1] as string;
          const content = row[2] as string | null;
    
          if (!entitiesMap.has(name)) {
            // Create a new entity
            entitiesMap.set(name, {
              name,
              entityType,
              observations: content ? [content] : [],
            });
          } else if (content) {
            // Add observation to existing entity
            entitiesMap.get(name)!.observations.push(content);
          }
        }
    
        const entities = Array.from(entitiesMap.values());
    
        // Create a set of entity names
        const entityNames = entities.map((entity) => entity.name);
    
        // Get related relations
        if (entityNames.length > 0) {
          const placeholders = entityNames.map(() => "?").join(",");
          const relationsReader = await conn.executeAndReadAll(
            `
          SELECT from_entity as "from", to_entity as "to", relationType
          FROM relations
          WHERE from_entity IN (${placeholders})
          OR to_entity IN (${placeholders})
          `,
            [...entityNames, ...entityNames]
          );
          const relationsData = relationsReader.getRows();
    
          // Convert results to an array of Relation objects
          const relations = relationsData.map((row: any) => {
            return {
              from: row[0] as string,
              to: row[1] as string,
              relationType: row[2] as string,
            };
          });
    
          return {
            entities,
            relations,
          };
        } else {
          return {
            entities,
            relations: [],
          };
        }
      } catch (error: unknown) {
        this.logger.error("Error opening nodes", extractError(error));
        return { entities: [], relations: [] };
      }
    }
  • src/server.ts:184-204 (registration)
    Registers the 'open_nodes' MCP tool with server.tool, defining input schema (array of strings for names) and delegating execution to knowledgeGraphManager.openNodes.
    server.tool(
      "open_nodes",
      "Open specific nodes in the knowledge graph by their names",
      {
        names: z
          .array(z.string())
          .describe("An array of entity names to retrieve"),
      },
      async ({ names }) => ({
        content: [
          {
            type: "text",
            text: JSON.stringify(
              await knowledgeGraphManager.openNodes(names),
              null,
              2
            ),
          },
        ],
      })
    );
  • TypeScript interface definition for the openNodes method in KnowledgeGraphManager.
    openNodes(names: string[]): Promise<KnowledgeGraph>;
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 implies a read operation ('open' suggests retrieval/access), but doesn't disclose critical behaviors: whether this requires permissions, what happens if names don't exist (error vs. partial results), if it returns full node details or just references, or any rate limits. The description adds minimal behavioral context beyond the basic action.

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 with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. Every element ('open', 'specific nodes', 'knowledge graph', 'by their names') contributes essential information without redundancy.

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 no annotations, no output schema, and a mutation-heavy sibling set (e.g., create/delete tools), the description is insufficient. It doesn't clarify if this is a safe read operation versus having side effects, what data is returned, or how errors are handled. For a tool in a knowledge graph context with potential complexity, more behavioral and output context is needed.

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%, with the schema fully documenting the 'names' parameter as an array of entity names. The description adds the semantic context that these are 'specific nodes' and 'by their names', reinforcing the schema but not providing additional syntax, format examples, or constraints. This meets the baseline for high schema coverage.

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 ('open') and target resource ('specific nodes in the knowledge graph'), with the qualifier 'by their names' adding specificity. It distinguishes from siblings like 'search_nodes' by focusing on retrieval of known entities rather than search. However, it doesn't fully differentiate from potential read operations in other contexts.

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 like 'search_nodes' or other sibling tools. There's no mention of prerequisites (e.g., needing to know exact entity names) or when-not-to-use scenarios. The agent must infer usage from the tool name and context alone.

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

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