Canvas Node Connections
canvas.connectionsReturn the incoming and outgoing edges of a single canvas node to traverse the graph step by step without loading the full document.
Instructions
Return the incoming and outgoing edges of a single canvas node. Use this to walk the canvas graph one node at a time without loading the full document. Read-only. For full-graph parsing, use canvas.parse.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Vault-relative path to an Obsidian `.canvas` file. | |
| nodeId | Yes | Id of the node whose edges to return. | |
| vaultPath | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | ||
| nodeId | Yes | ||
| incoming | Yes | ||
| outgoing | Yes |
Implementation Reference
- src/domain/canvas.ts:162-186 (handler)Core handler function for 'canvas.connections'. Loads the canvas file, validates the node exists, and returns incoming/outgoing edge connections.
export async function getCanvasNodeConnections( context: DomainContext, args: { filePath: string; nodeId: string; vaultPath?: string }, ) { const vaultRoot = requireVaultPath(context, args.vaultPath); const absolutePath = resolveVaultPath(vaultRoot, args.filePath); const canvas = await loadCanvas(absolutePath); if (!canvas.nodes.some((node) => node.id === args.nodeId)) { throw new AppError("not_found", `Node not found: ${args.nodeId}`); } const incoming = canvas.edges .filter((edge) => edge.toNode === args.nodeId) .map((edge) => edge.fromNode); const outgoing = canvas.edges .filter((edge) => edge.fromNode === args.nodeId) .map((edge) => edge.toNode); return { filePath: args.filePath, nodeId: args.nodeId, incoming, outgoing, incomingCount: incoming.length, outgoingCount: outgoing.length, }; } - src/schema/canvas.ts:29-36 (schema)Input schema for canvas.connections. Accepts filePath, nodeId, and optional vaultPath.
export const canvasConnectionsArgsSchema = z .object({ filePath: canvasFilePathSchema, nodeId: z.string().min(1).describe("Id of the node whose edges to return."), vaultPath: z.string().optional(), }) .strict(); export type CanvasConnectionsArgs = z.input<typeof canvasConnectionsArgsSchema>; - src/schema/canvas.ts:91-98 (schema)Output schema for canvas.connections. Returns filePath, nodeId, incoming/outgoing arrays and counts.
export const canvasConnectionsOutputSchema = z .object({ filePath: z.string(), nodeId: z.string(), incoming: z.array(z.record(z.string(), z.unknown())), outgoing: z.array(z.record(z.string(), z.unknown())), }) .passthrough(); - src/server/tools/canvas.ts:51-63 (registration)Tool registration for 'canvas.connections'. Defines name, title, description, input/output schemas, annotations, and wraps the handler that calls getCanvasNodeConnections.
{ name: "canvas.connections", title: "Canvas Node Connections", description: "Return the incoming and outgoing edges of a single canvas node. Use this to walk the canvas graph one node at a time without loading the full document. Read-only. For full-graph parsing, use `canvas.parse`.", inputSchema: canvasConnectionsArgsSchema, outputSchema: canvasConnectionsOutputSchema, annotations: READ_ONLY, handler: async (context, rawArgs) => { const args = canvasConnectionsArgsSchema.parse(rawArgs) as CanvasConnectionsArgs; return getCanvasNodeConnections(context, args); }, }, - src/server/registry.ts:18-34 (registration)Top-level tool registry that collects all tools including canvasTools into a single array for server registration.
export const toolRegistry: ToolDefinition[] = [ ...vaultTools, ...noteTools, ...tagTools, ...linkTools, ...analyticsTools, ...taskTools, ...dataviewTools, ...blocksTools, ...marpTools, ...kanbanTools, ...canvasTools, ...templateTools, ...apiTools, ...wikiTools, ...systemTools, ];