update_entities
Modify multiple entities in a knowledge graph by updating their names, types, or observations to enhance AI memory and user interaction accuracy.
Instructions
Update multiple existing entities in the knowledge graph
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entities | Yes |
Input Schema (JSON Schema)
{
"properties": {
"entities": {
"items": {
"properties": {
"entityType": {
"description": "The updated type of the entity",
"type": "string"
},
"name": {
"description": "The name of the entity to update",
"type": "string"
},
"observations": {
"description": "The updated array of observation contents",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"entities"
],
"type": "object"
}
Implementation Reference
- index.ts:205-230 (handler)Core handler function in KnowledgeGraphManager that loads the graph from file, updates specified entities by merging fields, increments version, updates createdAt, replaces in graph, saves back to file, and returns 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:457-478 (schema)Input schema definition for the update_entities tool, specifying an array of entities with required 'name' and optional 'entityType' and 'observations'.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:454-479 (registration)Tool registration in the listTools response, defining name, description, and inputSchema 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 CallToolRequestHandler that invokes the updateEntities method on the manager instance with tool arguments and formats response as JSON.case "update_entities": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.updateEntities(args.entities as Entity[]), null, 2) }] };
- index.ts:31-37 (helper)Entity interface type definition used by updateEntities for typing inputs and graph data.interface Entity { name: string; entityType: string; observations: string[]; createdAt: string; version: number; }