add_observations
Enhance entities in the MCP Memory Server's knowledge graph by adding new observations, enabling LLMs to store and utilize updated information across conversations and sessions.
Instructions
Add new observations to existing entities in the knowledge graph
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| observations | Yes |
Input Schema (JSON Schema)
{
"properties": {
"observations": {
"items": {
"properties": {
"contents": {
"description": "An array of observation contents to add",
"items": {
"type": "string"
},
"type": "array"
},
"entityName": {
"description": "The name of the entity to add the observations to",
"type": "string"
}
},
"required": [
"entityName",
"contents"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"observations"
],
"type": "object"
}
Implementation Reference
- src/index.ts:89-102 (handler)Core implementation of the add_observations tool: loads the knowledge graph, adds new non-duplicate observations to specified entities, persists changes, and 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; }
- src/index.ts:388-389 (registration)Dispatcher in CallToolRequestSchema handler that routes 'add_observations' calls to the KnowledgeGraphManager.addObservations method.case "add_observations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.addObservations(args.observations as { entityName: string; contents: string[] }[]), null, 2) }] };
- src/index.ts:253-273 (schema)Input schema for validating parameters of the add_observations tool.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"], },
- src/index.ts:250-274 (registration)Tool registration entry in ListToolsRequestSchema response, 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"], }, },