Skip to main content
Glama
bazylhorsey
by bazylhorsey

add_canvas_node

Add nodes to Obsidian canvases including files, text, links, or groups with specified position and dimensions to organize visual knowledge structures.

Instructions

Add a node to canvas (file, text, link, or group)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasPathYesPath to canvas file
colorNoNode color (1-6)
fileNoFile path (for file nodes)
heightYesNode height
labelNoLabel (for group nodes)
nodeTypeYesType of node
textNoText content (for text nodes)
urlNoURL (for link nodes)
vaultYesVault name
widthYesNode width
xYesX coordinate
yYesY coordinate

Implementation Reference

  • src/index.ts:239-260 (registration)
    Registration of the 'add_canvas_node' tool in the ListTools handler, including full input schema definition.
    {
      name: 'add_canvas_node',
      description: 'Add a node to canvas (file, text, link, or group)',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          canvasPath: { type: 'string', description: 'Path to canvas file' },
          nodeType: { type: 'string', enum: ['file', 'text', 'link', 'group'], description: 'Type of node' },
          x: { type: 'number', description: 'X coordinate' },
          y: { type: 'number', description: 'Y coordinate' },
          width: { type: 'number', description: 'Node width' },
          height: { type: 'number', description: 'Node height' },
          file: { type: 'string', description: 'File path (for file nodes)' },
          text: { type: 'string', description: 'Text content (for text nodes)' },
          url: { type: 'string', description: 'URL (for link nodes)' },
          label: { type: 'string', description: 'Label (for group nodes)' },
          color: { type: 'string', description: 'Node color (1-6)' },
        },
        required: ['vault', 'canvasPath', 'nodeType', 'x', 'y', 'width', 'height'],
      },
    },
  • Handler for 'add_canvas_node' tool call in the main switch statement, dispatching to CanvasService based on nodeType.
    case 'add_canvas_node': {
      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 nodeType = args?.nodeType as string;
      const canvasPath = args?.canvasPath as string;
      const commonOpts = {
        x: args?.x as number,
        y: args?.y as number,
        width: args?.width as number,
        height: args?.height as number,
        color: args?.color as any,
      };
    
      let result;
      switch (nodeType) {
        case 'file':
          result = await this.canvasService.addFileNode(connector.vaultPath, canvasPath, {
            ...commonOpts,
            file: args?.file as string,
            subpath: args?.subpath as string | undefined,
          });
          break;
        case 'text':
          result = await this.canvasService.addTextNode(connector.vaultPath, canvasPath, {
            ...commonOpts,
            text: args?.text as string,
          });
          break;
        case 'link':
          result = await this.canvasService.addLinkNode(connector.vaultPath, canvasPath, {
            ...commonOpts,
            url: args?.url as string,
          });
          break;
        case 'group':
          result = await this.canvasService.addGroupNode(connector.vaultPath, canvasPath, {
            ...commonOpts,
            label: args?.label as string | undefined,
          });
          break;
        default:
          throw new Error(`Unknown node type: ${nodeType}`);
      }
    
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Core implementation for adding file nodes to canvas (one of four node types). Reads canvas, adds node, writes back.
    async addFileNode(
      vaultPath: string,
      canvasPath: string,
      options: CreateFileNodeOptions
    ): Promise<VaultOperationResult<CanvasFileNode>> {
      const canvasResult = await this.readCanvas(vaultPath, canvasPath);
      if (!canvasResult.success || !canvasResult.data) {
        return { success: false, error: canvasResult.error };
      }
    
      const node: CanvasFileNode = {
        id: options.id || this.generateId(),
        type: 'file',
        file: options.file,
        subpath: options.subpath,
        x: options.x,
        y: options.y,
        width: options.width,
        height: options.height,
        color: options.color
      };
    
      canvasResult.data.nodes.push(node);
    
      const writeResult = await this.writeCanvas(vaultPath, canvasPath, canvasResult.data);
      if (!writeResult.success) {
        return { success: false, error: writeResult.error };
      }
    
      return { success: true, data: node };
    }
  • Core implementation for adding text nodes to canvas.
    async addTextNode(
      vaultPath: string,
      canvasPath: string,
      options: CreateTextNodeOptions
    ): Promise<VaultOperationResult<CanvasTextNode>> {
      const canvasResult = await this.readCanvas(vaultPath, canvasPath);
      if (!canvasResult.success || !canvasResult.data) {
        return { success: false, error: canvasResult.error };
      }
    
      const node: CanvasTextNode = {
        id: options.id || this.generateId(),
        type: 'text',
        text: options.text,
        x: options.x,
        y: options.y,
        width: options.width,
        height: options.height,
        color: options.color
      };
    
      canvasResult.data.nodes.push(node);
    
      const writeResult = await this.writeCanvas(vaultPath, canvasPath, canvasResult.data);
      if (!writeResult.success) {
        return { success: false, error: writeResult.error };
      }
    
      return { success: true, data: node };
    }
  • Core implementation for adding link nodes to canvas.
    async addLinkNode(
      vaultPath: string,
      canvasPath: string,
      options: CreateLinkNodeOptions
    ): Promise<VaultOperationResult<CanvasLinkNode>> {
      const canvasResult = await this.readCanvas(vaultPath, canvasPath);
      if (!canvasResult.success || !canvasResult.data) {
        return { success: false, error: canvasResult.error };
      }
    
      const node: CanvasLinkNode = {
        id: options.id || this.generateId(),
        type: 'link',
        url: options.url,
        x: options.x,
        y: options.y,
        width: options.width,
        height: options.height,
        color: options.color
      };
    
      canvasResult.data.nodes.push(node);
    
      const writeResult = await this.writeCanvas(vaultPath, canvasPath, canvasResult.data);
      if (!writeResult.success) {
        return { success: false, error: writeResult.error };
      }
    
      return { success: true, data: node };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool adds nodes but doesn't disclose behavioral traits: whether this is a write operation (implied but not confirmed), what happens on failure, if nodes can be overwritten, or any side effects. The description is minimal and lacks critical context for a mutation tool.

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?

Extremely concise and front-loaded: a single sentence that states the core purpose with no wasted words. Every part of the description earns its place by specifying the action, resource, and node types.

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?

Given the tool's complexity (12 parameters, mutation operation) and lack of annotations or output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral constraints. For a tool that modifies data with many parameters, more context is needed to guide effective use.

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 12 parameters with descriptions. The description adds minimal value by listing node types ('file, text, link, or group'), which partially explains the 'nodeType' enum, but doesn't provide additional semantics beyond what's in the schema. Baseline 3 is appropriate given high schema coverage.

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 ('node to canvas') with specific node types enumerated. It distinguishes from siblings like 'add_canvas_edge' (edges vs nodes) and 'create_canvas' (creating canvas vs adding nodes), though not explicitly. Purpose is specific but sibling differentiation is implicit rather than explicit.

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 on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., canvas must exist), when to choose different node types, or relationships with sibling tools like 'create_canvas' (for creating the canvas first) or 'get_canvas' (for checking existing nodes). Usage context is implied but not 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/bazylhorsey/obsidian-mcp-server'

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