Skip to main content
Glama
YuNaga224

Obsidian Memory MCP

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"],
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but lacks critical behavioral details. It implies a destructive operation ('Delete') but doesn't specify if deletions are permanent, require permissions, have side effects, or provide confirmation. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words, clearly front-loading the core action. It's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens upon deletion, error conditions, or return values, leaving significant gaps in understanding the tool's behavior and outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the 'relations' parameter and its nested properties. The description adds no additional meaning beyond stating it deletes 'multiple relations', which is implied by the schema. Baseline 3 is appropriate as the schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and resource ('multiple relations from the knowledge graph'), making the purpose understandable. It distinguishes from siblings like 'delete_entities' and 'delete_observations' by specifying relations, though it doesn't explicitly contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'delete_entities' or 'create_relations', nor does it mention prerequisites such as existing relations. The description only states what it does without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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