delete_entities
Remove entities and their connections from a knowledge graph in Obsidian Memory MCP to maintain organized data structures.
Instructions
Delete multiple entities and their associated relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityNames | Yes | An array of entity names to delete |
Implementation Reference
- Core handler function that deletes entity Markdown files and cleans up incoming relations from remaining entities.async deleteEntities(entityNames: string[]): Promise<void> { for (const name of entityNames) { const filePath = getEntityPath(name); try { await fs.unlink(filePath); } catch (error) { if (error instanceof Error && 'code' in error && (error as any).code !== 'ENOENT') { throw new Error(`Failed to delete entity ${name}: ${error}`); } } } // Remove relations pointing to deleted entities const remainingRelations = await this.loadAllRelations(); const relationsToRemove = remainingRelations.filter( r => entityNames.includes(r.to) ); for (const relation of relationsToRemove) { const fromPath = getEntityPath(relation.from); try { const content = await fs.readFile(fromPath, 'utf-8'); const updatedContent = removeRelationFromContent(content, relation); await fs.writeFile(fromPath, updatedContent, 'utf-8'); } catch (error) { // Entity might have been deleted } } }
- index.ts:217-219 (handler)Dispatch handler in the main CallToolRequestSchema handler that invokes the storage manager's deleteEntities method.case "delete_entities": await storageManager.deleteEntities(args.entityNames as string[]); return { content: [{ type: "text", text: "Entities deleted successfully" }] };
- index.ts:102-116 (registration)Tool registration in ListToolsRequestSchema response, defining the name, description, and input schema for delete_entities.{ name: "delete_entities", description: "Delete multiple entities and their associated relations from the knowledge graph", inputSchema: { type: "object", properties: { entityNames: { type: "array", items: { type: "string" }, description: "An array of entity names to delete" }, }, required: ["entityNames"], }, },
- index.ts:105-116 (schema)Input schema definition for the delete_entities tool.inputSchema: { type: "object", properties: { entityNames: { type: "array", items: { type: "string" }, description: "An array of entity names to delete" }, }, required: ["entityNames"], }, },