Skip to main content
Glama

add_canvas_edge

Connect two nodes in an Obsidian canvas by adding an edge between them with customizable labels and connection sides.

Instructions

Add an edge (connection) between two nodes in a canvas

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasPathYesRelative path to the .canvas file
fromNodeYesSource node ID
toNodeYesTarget node ID
labelNoEdge label
fromSideNoSide of source node
toSideNoSide of target node

Implementation Reference

  • Registration of the add_canvas_edge tool and its input schema.
    server.registerTool(
      "add_canvas_edge",
      {
        description: "Add an edge (connection) between two nodes in a canvas",
        inputSchema: {
          canvasPath: z.string().min(1).describe("Relative path to the .canvas file"),
          fromNode: z.string().describe("Source node ID"),
          toNode: z.string().describe("Target node ID"),
          label: z.string().optional().describe("Edge label"),
          fromSide: z.enum(["top", "right", "bottom", "left"]).optional().describe("Side of source node"),
          toSide: z.enum(["top", "right", "bottom", "left"]).optional().describe("Side of target node"),
        },
      },
  • The handler function for adding a canvas edge, which performs validation and updates the canvas file.
    async ({ canvasPath, fromNode, toNode, label, fromSide, toSide }) => {
      try {
        const data = await readCanvasFile(vaultPath, canvasPath);
    
        const fromExists = data.nodes.some((n) => n.id === fromNode);
        const toExists = data.nodes.some((n) => n.id === toNode);
    
        if (!fromExists) {
          return errorResult(`Error: source node '${fromNode}' not found in canvas.`);
        }
        if (!toExists) {
          return errorResult(`Error: target node '${toNode}' not found in canvas.`);
        }
    
        const id = randomUUID();
        const edge: CanvasData["edges"][number] = {
          id,
          fromNode,
          toNode,
        };
    
        if (label) edge.label = label;
        if (fromSide) edge.fromSide = fromSide;
        if (toSide) edge.toSide = toSide;
    
        data.edges.push(edge);
        await writeCanvasFile(vaultPath, canvasPath, data);
    
        return {
          content: [{ type: "text" as const, text: `Edge added successfully.\nID: ${id}\nFrom: ${fromNode} -> To: ${toNode}${label ? `\nLabel: ${label}` : ""}` }],
        };
      } catch (err) {
        console.error("Failed to add canvas edge:", err);
        return errorResult(`Error adding edge: ${err instanceof Error ? err.message : String(err)}`);
      }
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Add an edge') which implies a write/mutation operation, but doesn't disclose any behavioral traits such as permissions needed, whether the operation is idempotent, error conditions, or what happens on success/failure. The description is minimal and lacks crucial context for safe invocation.

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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. Every word earns its place in conveying the essential purpose.

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 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects (permissions, side effects), provide usage context, or explain what happens after edge creation. The high parameter count and mutation nature require more guidance than provided.

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 already documents all 6 parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema (e.g., it doesn't explain edge creation semantics, label usage, or side selection implications). The baseline of 3 is appropriate when the schema does all the work.

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 an edge') and the resource ('between two nodes in a canvas'), making the purpose immediately understandable. It distinguishes from sibling tools like 'add_canvas_node' by focusing on edges rather than nodes, though it doesn't explicitly contrast with other canvas-related tools like 'read_canvas' or 'list_canvases'.

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. It doesn't mention prerequisites (e.g., existing nodes or canvas files), when not to use it, or how it relates to sibling tools like 'add_canvas_node' or 'read_canvas'. Usage is implied but not explicitly stated.

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/rps321321/obsidian-mcp-pro'

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