delete_observations
Remove specific observations from entities in the knowledge graph to maintain accurate and up-to-date data within the MCP DuckDB Knowledge Graph Memory Server.
Instructions
Delete specific observations from entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deletions | Yes |
Implementation Reference
- src/manager.ts:463-495 (handler)Core handler function that performs the actual deletion of observations from the SQLite database using transactions, processes each deletion by entity and content, commits changes, updates the Fuse.js search index, and handles errors with rollback.async deleteObservations(deletions: Array<Observation>): Promise<void> { using conn = await this.getConn(); try { // Begin transaction await conn.execute("BEGIN TRANSACTION"); // Process each deletion for (const deletion of deletions) { // If there are observations to delete if (deletion.contents.length > 0) { for (const content of deletion.contents) { await conn.execute( "DELETE FROM observations WHERE entityName = ? AND content = ?", [deletion.entityName, content] ); } } } // Commit transaction await conn.execute("COMMIT"); // Update Fuse.js index const allEntities = await this.getAllEntities(); this.fuse.setCollection(allEntities); } catch (error: unknown) { // Rollback in case of error await conn.execute("ROLLBACK"); this.logger.error("Error deleting observations", extractError(error)); throw error; } }
- src/server.ts:106-129 (registration)MCP server.tool registration for the 'delete_observations' tool, including description, Zod input schema, and thin async handler that delegates to knowledgeGraphManager.deleteObservations and returns success message.server.tool( "delete_observations", "Delete specific observations from entities in the knowledge graph", { deletions: z .array( z.object({ entityName: z .string() .describe("The name of the entity containing the observations"), contents: z .array(z.string()) .describe("An array of observations to delete"), }) ) .describe("An array of observation deletions"), }, async ({ deletions }) => { await knowledgeGraphManager.deleteObservations(deletions); return { content: [{ type: "text", text: "Observations deleted successfully" }], }; } );
- src/server.ts:110-122 (schema)Zod schema defining the input structure: an array of objects each with entityName (string) and contents (array of strings).deletions: z .array( z.object({ entityName: z .string() .describe("The name of the entity containing the observations"), contents: z .array(z.string()) .describe("An array of observations to delete"), }) ) .describe("An array of observation deletions"), },
- src/types.ts:55-64 (schema)TypeScript interface defining the KnowledgeGraphManager methods, including deleteObservations signature.export type KnowledgeGraphManagerInterface = { createEntities(entities: Entity[]): Promise<Entity[]>; createRelations(relations: Relation[]): Promise<Relation[]>; addObservations(observations: Array<Observation>): Promise<Observation[]>; deleteEntities(entityNames: string[]): Promise<void>; deleteObservations(deletions: Array<Observation>): Promise<void>; deleteRelations(relations: Relation[]): Promise<void>; searchNodes(query: string): Promise<KnowledgeGraph>; openNodes(names: string[]): Promise<KnowledgeGraph>; };