create_entities
Add and initialize entities in Memento's knowledge graph, ensuring uniqueness and optionally attaching initial observations for each entity.
Instructions
Create entities in the knowledge graph. Inserts each entity if not exists and optionally seeds it with observations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entities | Yes | Array of entities to create. |
Implementation Reference
- src/knowledge-graph-manager.js:41-54 (handler)The core handler function that implements the create_entities tool logic: creates entities if they do not exist and adds observations if provided.async createEntities(entities) { const created = []; for (const entity of entities) { const existingId = await this.#repository.getEntityId(entity.name); if (!existingId) { await this.#repository.createEntity(entity.name, entity.entityType); created.push(entity); } if (entity.observations?.length) { await this.addObservations([{ entityName: entity.name, contents: entity.observations }]); } } return created; }
- src/server.js:44-65 (registration)Registers the 'create_entities' tool with the MCP server, defining its description, input schema using Zod, and handler that delegates to KnowledgeGraphManager.createEntities.this.tool( 'create_entities', 'Create entities in the knowledge graph. Inserts each entity if not exists and optionally seeds it with observations.', { entities: z.array(z.object({ name: z.string().describe('Unique name of the entity.'), entityType: z.string().describe('Type or category of the entity.'), observations: z.array(z.string()).optional() .describe('Initial list of observations to attach to the entity.') })).describe('Array of entities to create.') }, async ({ entities }) => ({ content: [{ type: 'text', text: JSON.stringify( await this.#knowledgeGraphManager.createEntities(entities), null, 2 ) }] }) );
- src/server.js:47-54 (schema)Zod schema defining the input parameters for the create_entities tool: an array of entities with name, entityType, and optional observations.{ entities: z.array(z.object({ name: z.string().describe('Unique name of the entity.'), entityType: z.string().describe('Type or category of the entity.'), observations: z.array(z.string()).optional() .describe('Initial list of observations to attach to the entity.') })).describe('Array of entities to create.') },