delete_relations
Remove specified relations from a knowledge graph stored in Obsidian Memory MCP by defining the entities and relation types to delete. Streamlines graph management by eliminating unwanted connections.
Instructions
Delete multiple relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete |
Implementation Reference
- index.ts:223-225 (handler)Handler for the delete_relations tool call, dispatching to storageManager.deleteRelations and returning success response.case "delete_relations": await storageManager.deleteRelations(args.relations as Relation[]); return { content: [{ type: "text", text: "Relations deleted successfully" }] };
- index.ts:145-162 (schema)Input schema defining the expected arguments: an array of relations with from, to, and relationType fields.inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, description: "An array of relations to delete" }, }, required: ["relations"],
- index.ts:142-164 (registration)Registration of the delete_relations tool in the ListTools response, including name, description, and schema.{ name: "delete_relations", description: "Delete multiple relations from the knowledge graph", inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, description: "An array of relations to delete" }, }, required: ["relations"], }, },
- Supporting method in MarkdownStorageManager that implements relation deletion by editing markdown files of source entities.async deleteRelations(relations: Relation[]): Promise<void> { for (const relation of relations) { 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) { if (error instanceof Error && 'code' in error && (error as any).code !== 'ENOENT') { throw new Error(`Failed to delete relation from ${relation.from}: ${error}`); } } } }