Skip to main content
Glama

connect_nodes

Create connections between workflow nodes to establish data flow paths for testing and validation in n8n workflows.

Instructions

Create a main connection between two nodes in an existing workflow.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflowIdYes
sourceYes
targetYes
sourceIndexNo
targetIndexNo

Implementation Reference

  • MCP request handler for 'connect_nodes' tool - validates input parameters using Zod schema and calls the connectNodes function
    if (name === 'connect_nodes') {
      const { workflowId, source, target, sourceIndex, targetIndex } = z.object({
        workflowId: z.string(),
        source: z.string(),
        target: z.string(),
        sourceIndex: z.number().optional(),
        targetIndex: z.number().optional(),
      }).parse(args);
      const updated = await connectNodes(workflowId, source, target, sourceIndex ?? 0, targetIndex ?? 0);
      return { content: [{ type: 'text', text: JSON.stringify(updated, null, 2) }] };
    }
  • Core implementation of connectNodes - fetches workflow, manages connections array structure, adds new connection between source and target nodes, and updates the workflow via n8n API
    export async function connectNodes(workflowId: string, source: string, target: string, sourceIndex = 0, targetIndex = 0) {
      const workflow = await getWorkflow(workflowId);
      const connections = workflow.connections && typeof workflow.connections === 'object' ? workflow.connections : {};
      const existing = (connections[source] && connections[source].main) ? connections[source].main : [];
      const next = [...existing];
      while (next.length <= sourceIndex) next.push([]);
      next[sourceIndex] = [
        ...(Array.isArray(next[sourceIndex]) ? next[sourceIndex] : []),
        { node: target, type: 'main', index: targetIndex },
      ];
      workflow.connections = { ...connections, [source]: { main: next } };
      return await updateWorkflow(workflowId, workflow);
    }
  • src/index.ts:85-99 (registration)
    Tool registration defining the 'connect_nodes' tool metadata and input schema with workflowId, source, target (required) and sourceIndex, targetIndex (optional) parameters
    {
      name: 'connect_nodes',
      description: 'Create a main connection between two nodes in an existing workflow.',
      inputSchema: {
        type: 'object',
        properties: {
          workflowId: { type: 'string' },
          source: { type: 'string' },
          target: { type: 'string' },
          sourceIndex: { type: 'number' },
          targetIndex: { type: 'number' }
        },
        required: ['workflowId', 'source', 'target'],
      },
    },
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 'Create a main connection', implying a write operation, but lacks details on permissions, side effects (e.g., if connections are reversible), error handling, or rate limits. This is a significant gap for a mutation tool, making it only marginally transparent.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized, making it easy to parse quickly, which is ideal for conciseness.

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 complexity of a 5-parameter mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain the parameters, behavioral traits, or return values, leaving critical gaps for an AI agent to understand how to invoke and interpret the tool correctly in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, meaning all 5 parameters are undocumented in the schema. The description adds no information about what 'workflowId', 'source', 'target', 'sourceIndex', or 'targetIndex' mean or how they should be used. It fails to compensate for the schema's lack of descriptions, leaving parameters semantically unclear.

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 ('Create a main connection') and resource ('between two nodes in an existing workflow'), making the purpose understandable. However, it doesn't explicitly distinguish this from sibling tools like 'add_node_to_workflow' or 'update_workflow', which might also involve workflow modifications, so it falls short of a perfect score.

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 minimal guidance by mentioning 'in an existing workflow', implying a prerequisite, but offers no explicit advice on when to use this tool versus alternatives like 'add_node_to_workflow' or 'update_workflow'. There's no mention of specific scenarios, exclusions, or comparisons with siblings, leaving usage unclear.

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/Souzix76/n8n-workflow-tester-safe'

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