add_observations
Add new observations to existing entities in a knowledge graph by specifying entity names and observation contents with a memory file path.
Instructions
Add new observations to existing entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| observations | Yes | ||
| memoryFilePath | Yes | The path to the memory file |
Implementation Reference
- index.ts:155-174 (handler)Core handler logic in KnowledgeGraphManager.addObservations: loads graph from file, finds entities, adds unique observations, saves updated graph, returns added observations per entity.async addObservations( observations: { entityName: string; contents: string[] }[], filepath: string ): Promise<{ entityName: string; addedObservations: string[] }[]> { await this.setMemoryFilePath(filepath); const graph = await this.loadGraph(); const results = observations.map((o) => { const entity = graph.entities.find((e) => e.name === o.entityName); if (!entity) { throw new Error(`Entity with name ${o.entityName} not found`); } const newObservations = o.contents.filter( (content) => !entity.observations.includes(content) ); entity.observations.push(...newObservations); return { entityName: o.entityName, addedObservations: newObservations }; }); await this.saveGraph(graph); return results; }
- index.ts:400-433 (schema)Input schema definition for the add_observations tool, specifying structure for observations array (with entityName and contents) and memoryFilePath.{ name: "add_observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { type: "object", properties: { observations: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity to add the observations to", }, contents: { type: "array", items: { type: "string" }, description: "An array of observation contents to add", }, }, required: ["entityName", "contents"], }, }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["observations", "memoryFilePath"], }, },
- index.ts:634-652 (registration)Registration in the tool dispatcher switch statement: handles CallToolRequest for add_observations by calling the KnowledgeGraphManager method and returning JSON-formatted result.case "add_observations": return { content: [ { type: "text", text: JSON.stringify( await knowledgeGraphManager.addObservations( args.observations as { entityName: string; contents: string[]; }[], args.memoryFilePath as string ), null, 2 ), }, ], };