delete_observations
Remove specific observations from entities in a knowledge graph to maintain accurate and relevant data.
Instructions
Delete specific observations from entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deletions | Yes | An array of observation deletions |
Implementation Reference
- src/server.ts:123-128 (handler)Handler function for the delete_observations tool that calls the knowledge graph manager to perform the deletion and returns a success message.async ({ deletions }) => { await knowledgeGraphManager.deleteObservations(deletions); return { content: [{ type: "text", text: "Observations deleted successfully" }], }; }
- src/server.ts:106-129 (registration)Registration of the delete_observations MCP tool including description, input schema, and handler reference.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:109-122 (schema)Zod schema defining the input for delete_observations: array of objects with entityName and contents.{ 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/manager.ts:463-495 (helper)Core implementation of observation deletion in KnowledgeGraphManager: performs SQL deletes in transaction and updates search index.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/types.ts:60-60 (schema)Type definition for the deleteObservations method in KnowledgeGraphManagerInterface.deleteObservations(deletions: Array<Observation>): Promise<void>;