delete_observations
Remove specific observations from entities by matching exact text, enabling precise data cleanup in the Memento memory server.
Instructions
Remove specific observations from entities by matching text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deletions | Yes | List of {entityName, observations} deletion requests. |
Implementation Reference
- src/server.js:142-156 (handler)MCP tool handler and registration for 'delete_observations'. Includes input schema validation using Zod and delegates to KnowledgeGraphManager.deleteObservations.
// Tool: delete_observations this.tool( 'delete_observations', 'Remove specific observations from entities by matching text.', { deletions: z.array(z.object({ entityName: z.string().describe('Name of the entity.'), observations: z.array(z.string()).describe('Exact observation texts to delete.') })).describe('List of {entityName, observations} deletion requests.') }, async ({ deletions }) => { await this.#knowledgeGraphManager.deleteObservations(deletions); return { content: [{ type: 'text', text: 'Observations deleted' }] }; } ); - Helper method in KnowledgeGraphManager that resolves entity names to IDs and calls the repository's deleteObservations for each entry.
async deleteObservations(list) { for (const { entityName, observations } of list) { const entityId = await this.#repository.getEntityId(entityName); if (!entityId) continue; await this.#repository.deleteObservations(entityId, observations); } } - src/sqlite/graph-repo.js:177-187 (helper)SQLite repository implementation of deleteObservations: executes SQL DELETE on observations table matching entity_id and content.
async deleteObservations(entityId, observations) { if (!observations.length) { return; } const placeholders = observations.map(() => '?').join(','); await this.db.run( `DELETE FROM observations WHERE entity_id = ? AND content IN (${placeholders})`, [entityId, ...observations] ); } - src/postgres/graph-repo.js:285-297 (helper)PostgreSQL repository implementation of deleteObservations: executes SQL DELETE using ANY array for observations content.
async deleteObservations(entityId, observations) { if (!observations.length) { return; } await this.#query( `DELETE FROM observations WHERE entity_id = $1 AND content = ANY ($2)`, [ entityId, observations ] ); } - src/graph-repository.js:30-30 (schema)Interface definition (JSDoc) for the GraphRepository deleteObservations method.
* @property {(entityId: number|string, observations: string[]) => Promise<void>} deleteObservations