create_entities
Add entities to a knowledge graph, inserting new entries and optionally attaching initial observations for data organization.
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)Core handler function that creates entities in the knowledge graph if they do not already exist, optionally adds observations, and returns the list of newly created entities.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:47-54 (schema)Zod schema defining the input parameters for the create_entities tool: an array of entities each 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.') },
- src/server.js:44-65 (registration)Registers the 'create_entities' MCP tool with name, description, input schema using Zod, and async handler that delegates to KnowledgeGraphManager.createEntities and returns JSON response.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 ) }] }) );