Skip to main content
Glama
YuNaga224
by YuNaga224

delete_relations

Remove multiple connections between entities in the Obsidian knowledge graph to maintain accurate relationship data.

Instructions

Delete multiple relations from the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYesAn array of relations to delete

Implementation Reference

  • The primary handler implementing the deletion logic by updating source entity Markdown files.
    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}`); } } } }
  • Core utility that removes the specific relation wiki-link from Markdown content using regex.
    export function removeRelationFromContent(content: string, relation: Relation): string { const linkPattern = new RegExp( `^[\\s\\-\\*]*\\[\\[${escapeRegExp(relation.relationType)}::${escapeRegExp(relation.to)}\\]\\]\\s*$`, 'gm' ); return content.replace(linkPattern, ''); }
  • MCP server-side tool handler dispatching to storage manager.
    case "delete_relations": await storageManager.deleteRelations(args.relations as Relation[]); return { content: [{ type: "text", text: "Relations deleted successfully" }] };
  • index.ts:142-164 (registration)
    Registers the tool in the MCP server's tool list with description and input 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"], }, },
  • Defines the input schema for the delete_relations tool, specifying the structure of relations array.
    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"],

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/YuNaga224/obsidian-memory-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server