MCPcopy
hub / github.com/modelcontextprotocol/servers / addObservations

Method addObservations

src/memory/index.ts:139–152  ·  view source on GitHub ↗
(observations: { entityName: string; contents: string[] }[])

Source from the content-addressed store, hash-verified

137 }
138
139 async addObservations(observations: { entityName: string; contents: string[] }[]): Promise<{ entityName: string; addedObservations: string[] }[]> {
140 const graph = await this.loadGraph();
141 const results = observations.map(o => {
142 const entity = graph.entities.find(e => e.name === o.entityName);
143 if (!entity) {
144 throw new Error(`Entity with name ${o.entityName} not found`);
145 }
146 const newObservations = o.contents.filter(content => !entity.observations.includes(content));
147 entity.observations.push(...newObservations);
148 return { entityName: o.entityName, addedObservations: newObservations };
149 });
150 await this.saveGraph(graph);
151 return results;
152 }
153
154 async deleteEntities(entityNames: string[]): Promise<void> {
155 const graph = await this.loadGraph();

Callers 2

index.tsFile · 0.80

Calls 2

loadGraphMethod · 0.95
saveGraphMethod · 0.95

Tested by

no test coverage detected