create_entities
Add multiple entities to the knowledge graph, specifying name, type, and associated observations, to enhance memory storage in the Knowledge Graph Memory Server.
Instructions
Create multiple new entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entities | Yes |
Implementation Reference
- src/memory/index.ts:246-265 (registration)Registers the 'create_entities' MCP tool, defining input/output schemas (using EntitySchema) and a thin handler that delegates to KnowledgeGraphManager.createEntities.server.registerTool( "create_entities", { title: "Create Entities", description: "Create multiple new entities in the knowledge graph", inputSchema: { entities: z.array(EntitySchema) }, outputSchema: { entities: z.array(EntitySchema) } }, async ({ entities }) => { const result = await knowledgeGraphManager.createEntities(entities); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], structuredContent: { entities: result } }; } );
- src/memory/index.ts:107-113 (handler)Executes the core logic for creating entities: loads the knowledge graph from JSONL, filters out duplicates by name, appends new entities, saves back to file, returns created entities.async createEntities(entities: Entity[]): Promise<Entity[]> { 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; }
- src/memory/index.ts:227-231 (schema)Zod schema for validating Entity objects used in the create_entities tool input and output.const EntitySchema = 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") });
- src/memory/index.ts:50-54 (schema)TypeScript interface defining the structure of an Entity, used throughout the knowledge graph and tool.export interface Entity { name: string; entityType: string; observations: string[]; }