delete_observations
Remove specific observations from entities in your Memento MCP knowledge graph memory to maintain accurate and current data.
Instructions
Delete specific observations from entities in your Memento MCP knowledge graph memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deletions | Yes |
Implementation Reference
- The main handler for the 'delete_observations' MCP tool. It extracts the 'deletions' argument and calls KnowledgeGraphManager.deleteObservations, returning a success message.case 'delete_observations': await knowledgeGraphManager.deleteObservations(args.deletions); return { content: [{ type: 'text', text: 'Observations deleted successfully' }] };
- src/server/handlers/listToolsHandler.ts:177-205 (registration)Registration of the 'delete_observations' tool in the MCP tools list, including description and full input schema.{ name: 'delete_observations', description: 'Delete specific observations from entities in your Memento MCP knowledge graph memory', inputSchema: { type: 'object', properties: { deletions: { type: 'array', items: { type: 'object', properties: { entityName: { type: 'string', description: 'The name of the entity containing the observations', }, observations: { type: 'array', items: { type: 'string' }, description: 'An array of observations to delete', }, }, required: ['entityName', 'observations'], }, }, }, required: ['deletions'], }, },
- src/KnowledgeGraphManager.ts:614-655 (helper)Helper method in KnowledgeGraphManager that handles deleteObservations by delegating to the storage provider (or file fallback) and scheduling re-embedding jobs for affected entities.async deleteObservations( deletions: { entityName: string; observations: string[] }[] ): Promise<void> { if (!deletions || deletions.length === 0) { return; } if (this.storageProvider) { // Use storage provider for deleting observations await this.storageProvider.deleteObservations(deletions); // Schedule re-embedding for affected entities if manager is provided if (this.embeddingJobManager) { for (const deletion of deletions) { await this.embeddingJobManager.scheduleEntityEmbedding(deletion.entityName, 1); } } } else { // Fallback to file-based implementation const graph = await this.loadGraph(); // Process each deletion for (const deletion of deletions) { const entity = graph.entities.find((e) => e.name === deletion.entityName); if (entity) { // Remove the observations entity.observations = entity.observations.filter( (obs) => !deletion.observations.includes(obs) ); } } await this.saveGraph(graph); // Schedule re-embedding for affected entities if manager is provided if (this.embeddingJobManager) { for (const deletion of deletions) { await this.embeddingJobManager.scheduleEntityEmbedding(deletion.entityName, 1); } } } }
- src/storage/StorageProvider.ts:97-97 (schema)Type definition (interface method signature) for deleteObservations in the StorageProvider interface.* @param relations Array of relations to delete
- File-based implementation of deleteObservations in FileStorageProvider (deprecated), which loads the graph, filters out specified observations from entities, and saves the graph.async deleteObservations( deletions: { entityName: string; observations: string[] }[] ): Promise<void> { if (!deletions || deletions.length === 0) { return; } const graph = await this.loadGraph(); // Process each deletion request deletions.forEach((deletion) => { const entity = graph.entities.find((e) => e.name === deletion.entityName); if (entity) { // Filter out the observations that should be deleted entity.observations = entity.observations.filter( (obs) => !deletion.observations.includes(obs) ); } }); // Save the updated graph await this.saveGraph(graph); }