Skip to main content
Glama

connect

Create connections between workflow nodes to establish data flow and automate processes in McFlow's n8n workflow management system.

Instructions

Create a connection between two nodes in a workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the workflow file
sourceNodeYesID of the source node
targetNodeYesID of the target node
sourceOutputNoOutput type from source node (default: main)
targetInputNoInput type for target node (default: main)

Implementation Reference

  • Core handler function that implements the connect tool logic: reads workflow JSON, adds connection from sourceNode to targetNode, writes back the file, and returns success message.
    export async function connectNodes(
      workflowsPath: string,
      workflowPath: string,
      sourceNode: string,
      targetNode: string,
      sourceOutput: string = 'main',
      targetInput: string = 'main'
    ): Promise<any> {
      try {
        const fullPath = path.join(workflowsPath, workflowPath);
        const content = await fs.readFile(fullPath, 'utf-8');
        const workflow = JSON.parse(content);
    
        if (!workflow.connections) {
          workflow.connections = {};
        }
    
        if (!workflow.connections[sourceNode]) {
          workflow.connections[sourceNode] = {};
        }
    
        if (!workflow.connections[sourceNode][sourceOutput]) {
          workflow.connections[sourceNode][sourceOutput] = [];
        }
    
        const outputIndex = 0;
        if (!workflow.connections[sourceNode][sourceOutput][outputIndex]) {
          workflow.connections[sourceNode][sourceOutput][outputIndex] = [];
        }
    
        workflow.connections[sourceNode][sourceOutput][outputIndex].push({
          node: targetNode,
          type: targetInput,
          index: 0,
        });
    
        await fs.writeFile(fullPath, JSON.stringify(workflow, null, 2));
    
        return {
          content: [
            {
              type: 'text',
              text: `Connected ${sourceNode} -> ${targetNode}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to connect nodes: ${error}`);
      }
    }
  • Schema definition for the 'connect' tool, including input parameters and requirements.
    {
      name: 'connect',
      description: 'Create a connection between two nodes in a workflow',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the workflow file',
          },
          sourceNode: {
            type: 'string',
            description: 'ID of the source node',
          },
          targetNode: {
            type: 'string',
            description: 'ID of the target node',
          },
          sourceOutput: {
            type: 'string',
            description: 'Output type from source node (default: main)',
          },
          targetInput: {
            type: 'string',
            description: 'Input type for target node (default: main)',
          },
        },
        required: ['path', 'sourceNode', 'targetNode'],
      },
    },
  • MCP server registration: sets handlers for listing tools (schemas via getToolDefinitions()) and calling tools (dispatches to ToolHandler.handleTool).
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: getToolDefinitions(),
    }));
    
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      return await this.toolHandler.handleTool(
        request.params.name,
        request.params.arguments
      );
    });
  • ToolHandler switch case that handles 'connect' tool calls by invoking the connectNodes function.
    case 'connect':
      return await connectNodes(
        this.workflowsPath,
        args?.path as string,
        args?.sourceNode as string,
        args?.targetNode as string,
        args?.sourceOutput as string,
        args?.targetInput as string
      );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Create a connection', implying a write/mutation operation, but doesn't cover aspects like permissions needed, whether it modifies existing workflows, error handling, or side effects. This is inadequate for a tool that likely alters workflow state.

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, clear sentence with no wasted words, efficiently conveying the core purpose. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 (creating connections in workflows with 5 parameters), lack of annotations, and no output schema, the description is insufficient. It doesn't explain what a 'connection' entails, the format of node IDs, or the result of the operation, leaving gaps for proper tool invocation.

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?

The description mentions 'two nodes' and 'workflow', which loosely relates to parameters like sourceNode, targetNode, and path, but adds minimal semantic value beyond the schema's 100% coverage. With high schema coverage, the baseline is 3, as the description doesn't significantly enhance parameter understanding.

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 connection') and resource ('between two nodes in a workflow'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from siblings like 'add_node' or 'configure_tracking', which might also relate to workflow modification, so it doesn't fully distinguish from alternatives.

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 no guidance on when to use this tool versus alternatives. With many sibling tools like 'add_node', 'configure_tracking', and 'update', there's no indication of prerequisites, context, or exclusions for using 'connect', leaving the agent without usage direction.

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

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