Skip to main content
Glama

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'], }, },

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