Skip to main content
Glama

add_node

Add functional n8n nodes to workflows by specifying file path, node configuration, and positioning for enhanced automation development.

Instructions

Add a REAL n8n node to workflow (no mock/placeholder nodes allowed)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the workflow file
nodeYesThe node to add
positionNoPosition for the new node

Implementation Reference

  • Core implementation of the add_node tool: reads workflow JSON, appends the provided node (with auto-positioning if not specified), persists changes to file, returns success message.
    export async function addNodeToWorkflow(
      workflowsPath: string,
      workflowPath: string,
      node: any,
      position?: any
    ): Promise<any> {
      try {
        const fullPath = path.join(workflowsPath, workflowPath);
        const content = await fs.readFile(fullPath, 'utf-8');
        const workflow = JSON.parse(content);
    
        if (!workflow.nodes) {
          workflow.nodes = [];
        }
    
        if (position) {
          node.position = [position.x || 250, position.y || 300];
        } else {
          const lastNode = workflow.nodes[workflow.nodes.length - 1];
          if (lastNode && lastNode.position) {
            node.position = [lastNode.position[0] + 250, lastNode.position[1]];
          } else {
            node.position = [250, 300];
          }
        }
    
        workflow.nodes.push(node);
    
        await fs.writeFile(fullPath, JSON.stringify(workflow, null, 2));
    
        return {
          content: [
            {
              type: 'text',
              text: `Node added to workflow: ${node.id}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to add node: ${error}`);
      }
    }
  • ToolHandler switch case that routes 'add_node' tool invocations to the addNodeToWorkflow implementation, passing workflowsPath and parsed arguments.
    case 'add_node':
      return await addNodeToWorkflow(
        this.workflowsPath,
        args?.path as string,
        args?.node as any,
        args?.position as any
      );
  • Registers the 'add_node' MCP tool including its name, description, and input schema validation.
    {
      name: 'add_node',
      description: 'Add a REAL n8n node to workflow (no mock/placeholder nodes allowed)',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the workflow file',
          },
          node: {
            type: 'object',
            description: 'The node to add',
          },
          position: {
            type: 'object',
            properties: {
              x: { type: 'number' },
              y: { type: 'number' },
            },
            description: 'Position for the new node',
          },
        },
        required: ['path', 'node'],
      },
    },
  • Input schema defining parameters for add_node: path (required), node (required), optional position with x/y coordinates.
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path to the workflow file',
        },
        node: {
          type: 'object',
          description: 'The node to add',
        },
        position: {
          type: 'object',
          properties: {
            x: { type: 'number' },
            y: { type: 'number' },
          },
          description: 'Position for the new node',
        },
      },
      required: ['path', 'node'],
    },

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/mckinleymedia/mcflow-mcp'

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