Skip to main content
Glama

create_entities

Add multiple new entities to a knowledge graph, specifying names, types, and associated observations for semantic indexing and search.

Instructions

Create multiple new entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entitiesYes

Implementation Reference

  • The main handler function for the 'create_entities' tool. It validates the input entities array, calls knowledgeGraphManager.createEntities, and returns a formatted text response.
    export const createEntitiesHandler: ToolHandler = async (args) => {
      if (!args.entities || !Array.isArray(args.entities)) {
        throw new Error("The 'entities' parameter is required and must be an array");
      }
    
      // Valider chaque entité
      for (const entity of args.entities) {
        if (!entity.name || typeof entity.name !== 'string') {
          throw new Error("Each entity must have a 'name' string property");
        }
        if (!entity.entityType || typeof entity.entityType !== 'string') {
          throw new Error("Each entity must have an 'entityType' string property");
        }
        if (!entity.observations || !Array.isArray(entity.observations)) {
          throw new Error("Each entity must have an 'observations' array property");
        }
      }
    
      try {
        const result = await knowledgeGraphManager.createEntities(args.entities);
        return { 
          content: [{ 
            type: "text", 
            text: JSON.stringify(result, null, 2) 
          }] 
        };
      } catch (error) {
        console.error("Error in create_entities tool:", error);
        throw error;
      }
    };
  • The tool definition including name, description, and input schema for validating the entities parameter.
    export const createEntitiesTool: ToolDefinition = {
      name: "create_entities",
      description: "Create multiple new entities in the knowledge graph",
      inputSchema: {
        type: "object",
        properties: {
          entities: {
            type: "array",
            items: {
              type: "object",
              properties: {
                name: { 
                  type: "string", 
                  description: "The name of the entity" 
                },
                entityType: { 
                  type: "string", 
                  description: "The type of the entity" 
                },
                observations: {
                  type: "array",
                  items: { type: "string" },
                  description: "An array of observation contents associated with the entity"
                },
              },
              required: ["name", "entityType", "observations"],
            },
          },
        },
        required: ["entities"],
      },
    };
  • Core helper function in KnowledgeGraphManager that loads the graph from memory.json, filters out existing entities by name, adds new ones, saves the graph, and returns the added entities.
    async createEntities(entities: EntityInput[]): Promise<EntityInput[]> {
      const graph = await this.loadGraph();
      const newEntities = entities.filter(e => !graph.entities.some(existingEntity => existingEntity.name === e.name));
      graph.entities.push(...newEntities);
      await this.saveGraph(graph);
      return newEntities;
    }
  • The getExpectedTools function lists 'create_entities' as one of the expected tools to be automatically registered by the AutoRegistry system.
    export function getExpectedTools(): string[] {
      return [
        // Outils Graph (9 outils)
        'create_entities',
        'create_relations',
        'add_observations',
        'delete_entities',
        'delete_observations',
        'delete_relations',
        'read_graph',
        'search_nodes',
        'open_nodes',
    
        // Outils RAG (5 outils - avec injection_rag comme outil principal)
        'injection_rag',      // Nouvel outil principal
        'index_project',      // Alias déprécié (rétrocompatibilité)
        'search_code',
        'manage_projects',
        'update_project'
      ];
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 of behavioral disclosure. It states this is a creation operation, implying mutation, but doesn't cover critical aspects like permissions needed, whether creation is idempotent, error handling for duplicates, or rate limits. For a batch creation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 without unnecessary words. It's front-loaded with the core action ('create multiple new entities') and specifies the context ('in the knowledge graph'), making it easy to parse quickly. Every word earns its place, with no redundancy or fluff.

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 batch creation in a knowledge graph, no annotations, and no output schema, the description is insufficient. It doesn't address return values, error conditions, or interactions with sibling tools like 'read_graph' or 'delete_entities'. For a mutation tool with multiple parameters and siblings, more context is needed to ensure proper usage.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the schema provides no descriptions for parameters. The description mentions 'multiple new entities' but doesn't explain what 'entities' entail beyond the schema's structure. It fails to add meaningful context about the 'entities' array, such as format examples, constraints on entity types, or how observations are used, leaving parameters largely undocumented.

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 verb ('create') and resource ('multiple new entities in the knowledge graph'), making the purpose unambiguous. It distinguishes from siblings like 'create_relations' or 'add_observations' by focusing on entity creation rather than relationships or observations. However, it doesn't specify what constitutes an 'entity' beyond the schema, leaving some ambiguity.

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. It doesn't mention prerequisites, such as whether entities must be unique or if there are limits on batch size. With siblings like 'create_relations' and 'add_observations', there's no indication of how this tool interacts with them or when to choose one over another.

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/ali-48/rag-mcp-server'

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