Skip to main content
Glama
bazylhorsey
by bazylhorsey

add_canvas_edge

Connect nodes in Obsidian canvas files by creating edges between them, allowing you to build relationships and visualize connections within your knowledge graph.

Instructions

Add an edge between nodes in canvas

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasPathYesPath to canvas file
colorNoEdge color (1-6)
fromNodeYesSource node ID
labelNoEdge label
toNodeYesTarget node ID
vaultYesVault name

Implementation Reference

  • Core implementation of adding an edge to a canvas file: reads the canvas JSON, creates a new CanvasEdge object with provided options, appends it to the edges array, and writes the updated canvas back to disk.
    async addEdge(
      vaultPath: string,
      canvasPath: string,
      options: CreateEdgeOptions
    ): Promise<VaultOperationResult<CanvasEdge>> {
      const canvasResult = await this.readCanvas(vaultPath, canvasPath);
      if (!canvasResult.success || !canvasResult.data) {
        return { success: false, error: canvasResult.error };
      }
    
      const edge: CanvasEdge = {
        id: options.id || this.generateId(),
        fromNode: options.fromNode,
        fromSide: options.fromSide || 'right',
        fromEnd: options.fromEnd,
        toNode: options.toNode,
        toSide: options.toSide || 'left',
        toEnd: options.toEnd || 'arrow',
        color: options.color,
        label: options.label
      };
    
      canvasResult.data.edges.push(edge);
    
      const writeResult = await this.writeCanvas(vaultPath, canvasPath, canvasResult.data);
      if (!writeResult.success) {
        return { success: false, error: writeResult.error };
      }
    
      return { success: true, data: edge };
    }
  • MCP tool handler dispatch for 'add_canvas_edge': validates local vault connector, extracts arguments, calls CanvasService.addEdge, and returns the result as JSON.
    case 'add_canvas_edge': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector || !connector.vaultPath) {
        throw new Error(`Vault "${args?.vault}" not found or not a local vault`);
      }
    
      const result = await this.canvasService.addEdge(connector.vaultPath, args?.canvasPath as string, {
        fromNode: args?.fromNode as string,
        toNode: args?.toNode as string,
        label: args?.label as string | undefined,
        color: args?.color as any,
      });
    
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Tool registration and input schema definition for 'add_canvas_edge' in the ListTools response, specifying required parameters and their types.
    {
      name: 'add_canvas_edge',
      description: 'Add an edge between nodes in canvas',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          canvasPath: { type: 'string', description: 'Path to canvas file' },
          fromNode: { type: 'string', description: 'Source node ID' },
          toNode: { type: 'string', description: 'Target node ID' },
          label: { type: 'string', description: 'Edge label' },
          color: { type: 'string', description: 'Edge color (1-6)' },
        },
        required: ['vault', 'canvasPath', 'fromNode', 'toNode'],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't mention whether this is a mutation (implied by 'Add'), what permissions are needed, if edges are reversible, or any side effects—critical gaps for a tool that modifies data.

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 zero waste—front-loaded and perfectly sized for its purpose. Every word earns its place without redundancy or unnecessary elaboration.

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 mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after adding an edge (e.g., success response, error cases), behavioral constraints, or how it fits with siblings like 'add_canvas_node', leaving significant gaps in context.

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 parameters are well-documented in the schema. The description adds no additional meaning beyond implying 'canvas' context, which is already clear from parameter names like 'canvasPath'. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Add') and resource ('edge between nodes in canvas'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'add_canvas_node' beyond the resource type, missing explicit comparison that would warrant a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'add_canvas_node' or 'analyze_graph'. It lacks context about prerequisites (e.g., needing existing nodes or canvas) or exclusions, leaving usage entirely to inference.

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/bazylhorsey/obsidian-mcp-server'

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