Skip to main content
Glama

Knowledge Graph Memory Server

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

NameRequiredDescriptionDefault
entitiesYes

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

  • 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; }
  • 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"], }, },
  • 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) }] };
  • 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; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/itseasy21/mcp-knowledge-graph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server