create_entities
Add multiple entities to a knowledge graph, specifying names, types, and associated observations, to enhance memory integration in chat applications.
Instructions
Create multiple new entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entities | Yes |
Implementation Reference
- index.ts:136-156 (handler)The core handler function that executes the create_entities tool logic: loads the knowledge graph from file, deduplicates new entities by name, adds them to the graph, persists the changes, and returns the newly added entities.async createEntities(entities: Entity[]): Promise<Entity[]> { console.error(`[Debug] Creating entities:`, entities); const graph = await this.loadGraph(); console.error(`[Debug] Current graph:`, graph); const newEntities = entities.filter(e => !graph.entities.some(existingEntity => existingEntity.name === e.name)); console.error(`[Debug] New entities to add:`, newEntities); if (newEntities.length > 0) { graph.entities.push(...newEntities.map(e => ({ name: e.name, entityType: e.entityType, observations: e.observations, subdomain: e.subdomain }))); await this.saveGraph(graph); } console.error(`[Debug] Final graph:`, graph); return newEntities; }
- index.ts:363-388 (schema)Input schema for the create_entities tool, specifying an object with an 'entities' array, where each entity has required 'name', 'entityType', 'observations', and optional 'subdomain'.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" }, subdomain: { type: "string", description: "The loglass subdomain this knowledge belongs to (e.g., 'allocation', 'report', 'accounts', 'plans', 'actual' etc.). Can be omitted if the knowledge spans multiple domains.", }, observations: { type: "array", items: { type: "string" }, description: "An array of observation contents associated with the entity" }, }, required: ["name", "entityType", "observations"], }, }, }, required: ["entities"], },
- index.ts:361-389 (registration)Registration of the 'create_entities' tool in the ListToolsRequestSchema handler, including name, description, and input schema.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" }, subdomain: { type: "string", description: "The loglass subdomain this knowledge belongs to (e.g., 'allocation', 'report', 'accounts', 'plans', 'actual' etc.). Can be omitted if the knowledge spans multiple domains.", }, observations: { type: "array", items: { type: "string" }, description: "An array of observation contents associated with the entity" }, }, required: ["name", "entityType", "observations"], }, }, }, required: ["entities"], }, },
- index.ts:29-35 (schema)TypeScript interface defining the Entity type used by the create_entities tool.interface Entity { name: string; entityType: string; observations: string[]; /** The loglass subdomain this knowledge belongs to. Optional for knowledge spanning multiple domains. */ subdomain?: string; }
- index.ts:553-554 (helper)Dispatch case in the CallToolRequestSchema handler that invokes the createEntities handler with parsed arguments and formats the response.case "create_entities": return createResponse(JSON.stringify(await knowledgeGraphManager.createEntities(args.entities as Entity[]), null, 2));