add_observations
Add new observations to existing entities in a knowledge graph to maintain updated information across interactions.
Instructions
Add new observations to existing entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| observations | Yes |
Implementation Reference
- index.ts:623-636 (handler)Core handler function in KnowledgeGraphManager that loads the graph, finds target entities, filters and appends new unique observations, saves the graph, and returns results.async addObservations(observations: { entityName: string; contents: string[] }[]): Promise<{ entityName: string; addedObservations: string[] }[]> { 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:977-997 (schema)Input schema definition for the add_observations tool, specifying structure for observations array with entityName and contents.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"], }, }, }, required: ["observations"], },
- index.ts:974-998 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and input schema for add_observations.{ 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"], }, }, }, required: ["observations"], }, },
- index.ts:1227-1228 (handler)Dispatch handler in CallToolRequestHandler switch statement that invokes the KnowledgeGraphManager.addObservations method and formats the response.case "add_observations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.addObservations(args.observations as { entityName: string; contents: string[] }[]), null, 2) }] };