update_entities
Modify multiple existing entities in the knowledge graph by updating their types and observation data to maintain accurate memory storage.
Instructions
Update multiple existing entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entities | Yes |
Implementation Reference
- index.ts:205-230 (handler)The handler function in KnowledgeGraphManager that loads the graph, updates specified entities by merging properties, increments version, updates the graph in place, saves it, and returns the updated entities.async updateEntities(entities: Entity[]): Promise<Entity[]> { const graph = await this.loadGraph(); const updatedEntities = entities.map(updateEntity => { const existingEntity = graph.entities.find(e => e.name === updateEntity.name); if (!existingEntity) { throw new Error(`Entity with name ${updateEntity.name} not found`); } return { ...existingEntity, ...updateEntity, version: existingEntity.version + 1, createdAt: new Date().toISOString() }; }); // Update entities in the graph updatedEntities.forEach(updatedEntity => { const index = graph.entities.findIndex(e => e.name === updatedEntity.name); if (index !== -1) { graph.entities[index] = updatedEntity; } }); await this.saveGraph(graph); return updatedEntities; }
- index.ts:454-479 (registration)Tool registration in the ListTools response, defining name, description, and input schema for update_entities.{ name: "update_entities", description: "Update multiple existing 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 to update" }, entityType: { type: "string", description: "The updated type of the entity" }, observations: { type: "array", items: { type: "string" }, description: "The updated array of observation contents" }, }, required: ["name"], }, }, }, required: ["entities"], }, },
- index.ts:535-536 (handler)Dispatcher case in CallToolRequest handler that calls the updateEntities method on the manager instance with parsed arguments and returns JSON stringified result.case "update_entities": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.updateEntities(args.entities as Entity[]), null, 2) }] };