add_observations
Add new observations to existing entities in the knowledge graph to maintain updated user information across chat 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:170-183 (handler)Core handler function in KnowledgeGraphManager that executes the add_observations logic: loads graph, finds entities, deduplicates and appends new observations, saves graph, returns added observations per entity.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:415-436 (schema)Input schema for the add_observations tool, defining the expected structure: array of objects with entityName (string) and contents (array of strings).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:412-437 (registration)Registration of the add_observations tool in the ListTools response, including name, description, and full input schema.{ 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:557-558 (handler)MCP dispatch handler in CallToolRequestSchema that calls the KnowledgeGraphManager.addObservations method with parsed arguments and formats response.case "add_observations": return createResponse(JSON.stringify(await knowledgeGraphManager.addObservations(args.observations as { entityName: string; contents: string[] }[]), null, 2));