Skip to main content
Glama
IzumiSy

MCP DuckDB Knowledge Graph Memory Server

create_entities

Add multiple entities to a knowledge graph by specifying names, types, and associated observations for enhanced data organization and retrieval.

Instructions

Create multiple new entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entitiesYesAn array of entities to create

Implementation Reference

  • Core handler function in KnowledgeGraphManager that creates new entities and their observations in the DuckDB database, avoiding duplicates and updating search index.
    async createEntities(entities: Entity[]): Promise<Entity[]> {
      const createdEntities: Entity[] = [];
    
      using conn = await this.getConn();
    
      try {
        // Begin transaction
        await conn.execute("BEGIN TRANSACTION");
    
        // Get existing entity names
        const existingEntitiesReader = await conn.executeAndReadAll(
          "SELECT name FROM entities"
        );
        const existingEntitiesData = existingEntitiesReader.getRows();
        const nameColumnIndex = 0; // name column is the first column
        const existingNames = new Set(
          existingEntitiesData.map((row: any) => row[nameColumnIndex] as string)
        );
    
        // Filter new entities
        const newEntities = entities.filter(
          (entity) => !existingNames.has(entity.name)
        );
    
        // Insert new entities
        for (const entity of newEntities) {
          // Insert entity
          await conn.execute(
            "INSERT INTO entities (name, entityType) VALUES (?, ?)",
            [entity.name, entity.entityType]
          );
    
          // Insert observations
          for (const observation of entity.observations) {
            await conn.execute(
              "INSERT INTO observations (entityName, content) VALUES (?, ?)",
              [entity.name, observation]
            );
          }
    
          createdEntities.push(entity);
        }
    
        // Commit transaction
        await conn.execute("COMMIT");
    
        // Update Fuse.js index
        const allEntities = await this.getAllEntities();
        this.fuse.setCollection(allEntities);
    
        return createdEntities;
      } catch (error: unknown) {
        // Rollback in case of error
        await conn.execute("ROLLBACK");
        this.logger.error("Error creating entities", extractError(error));
        throw error;
      }
    }
  • src/server.ts:19-40 (registration)
    MCP tool registration and thin handler wrapper that validates input with Zod schema and delegates to KnowledgeGraphManager.createEntities, returning JSON response.
    // Create entities tool
    server.tool(
      "create_entities",
      "Create multiple new entities in the knowledge graph",
      {
        entities: z
          .array(EntityObject)
          .describe("An array of entities to create"),
      },
      async ({ entities }) => ({
        content: [
          {
            type: "text",
            text: JSON.stringify(
              await knowledgeGraphManager.createEntities(entities),
              null,
              2
            ),
          },
        ],
      })
    );
  • Zod schema definition for Entity type used in create_entities tool input.
    export const EntityObject = z.object({
      name: z.string().describe("The name of the entity"),
      entityType: z.string().describe("The type of the entity"),
      observations: z
        .array(z.string())
        .describe("An array of observation contents associated with the entity"),
    });
    export type Entity = z.infer<typeof EntityObject>;
  • TypeScript interface defining the createEntities method signature.
    export type KnowledgeGraphManagerInterface = {
      createEntities(entities: Entity[]): Promise<Entity[]>;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates entities, implying a write operation, but doesn't disclose critical traits like permissions required, whether creation is idempotent, error handling, or rate limits. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 purpose without unnecessary words. It's appropriately sized and front-loaded, with zero waste, 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 creating multiple entities in a knowledge graph, no annotations, and no output schema, the description is incomplete. It doesn't explain what happens on success (e.g., returns created entity IDs), error conditions, or behavioral nuances. For a mutation tool with rich sibling context, more completeness 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?

The schema description coverage is 100%, with the single parameter 'entities' well-documented in the schema as an array of objects with name, entityType, and observations. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without extra value.

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 ('create') and resource ('multiple new entities in the knowledge graph'), making the purpose evident. It distinguishes from siblings like 'create_relations' by focusing on entities rather than relationships, but doesn't explicitly differentiate from other entity-related tools like 'add_observations' or 'delete_entities' beyond the creation aspect.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites, when not to use it, or how it compares to sibling tools like 'add_observations' (which might add observations to existing entities) or 'create_relations' (for creating relationships). The description lacks context for tool selection.

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