## Problem AI assistants were consistently connecting SplitInBatches node outputs backwards because: - Output index 0 = "done" (runs after loop completes) - Output index 1 = "loop" (processes items inside loop) This counterintuitive ordering caused incorrect workflow connections. ## Solution Enhanced the n8n-mcp system to expose and clarify output information: ### Database & Schema - Added `outputs` and `output_names` columns to nodes table - Updated NodeRepository to store/retrieve output information ### Node Parsing - Enhanced NodeParser to extract outputs and outputNames from nodes - Properly handles versioned nodes like SplitInBatchesV3 ### MCP Server - Modified getNodeInfo to return detailed output descriptions - Added connection guidance for each output - Special handling for loop nodes (SplitInBatches, IF, Switch) ### Documentation - Enhanced DocsMapper to inject critical output guidance - Added warnings about counterintuitive output ordering - Provides correct connection patterns for loop nodes ### Workflow Validation - Added validateSplitInBatchesConnection method - Detects reversed connections and provides specific errors - Added checkForLoopBack with depth limit to prevent stack overflow - Smart heuristics to identify likely connection mistakes ## Testing - Created comprehensive test suite (81 tests) - Unit tests for all modified components - Edge case handling for malformed data - Performance testing with large workflows ## Impact AI assistants will now: - See explicit output indices and names (e.g., "Output 0: done") - Receive clear connection guidance - Get validation errors when connections are reversed - Have enhanced documentation explaining the correct pattern Fixes #97 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.8 KiB
SQL
53 lines
1.8 KiB
SQL
-- Ultra-simple schema for MVP
|
|
CREATE TABLE IF NOT EXISTS nodes (
|
|
node_type TEXT PRIMARY KEY,
|
|
package_name TEXT NOT NULL,
|
|
display_name TEXT NOT NULL,
|
|
description TEXT,
|
|
category TEXT,
|
|
development_style TEXT CHECK(development_style IN ('declarative', 'programmatic')),
|
|
is_ai_tool INTEGER DEFAULT 0,
|
|
is_trigger INTEGER DEFAULT 0,
|
|
is_webhook INTEGER DEFAULT 0,
|
|
is_versioned INTEGER DEFAULT 0,
|
|
version TEXT,
|
|
documentation TEXT,
|
|
properties_schema TEXT,
|
|
operations TEXT,
|
|
credentials_required TEXT,
|
|
outputs TEXT, -- JSON array of output definitions
|
|
output_names TEXT, -- JSON array of output names
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Minimal indexes for performance
|
|
CREATE INDEX IF NOT EXISTS idx_package ON nodes(package_name);
|
|
CREATE INDEX IF NOT EXISTS idx_ai_tool ON nodes(is_ai_tool);
|
|
CREATE INDEX IF NOT EXISTS idx_category ON nodes(category);
|
|
|
|
-- Templates table for n8n workflow templates
|
|
CREATE TABLE IF NOT EXISTS templates (
|
|
id INTEGER PRIMARY KEY,
|
|
workflow_id INTEGER UNIQUE NOT NULL,
|
|
name TEXT NOT NULL,
|
|
description TEXT,
|
|
author_name TEXT,
|
|
author_username TEXT,
|
|
author_verified INTEGER DEFAULT 0,
|
|
nodes_used TEXT, -- JSON array of node types
|
|
workflow_json TEXT NOT NULL, -- Complete workflow JSON
|
|
categories TEXT, -- JSON array of categories
|
|
views INTEGER DEFAULT 0,
|
|
created_at DATETIME,
|
|
updated_at DATETIME,
|
|
url TEXT,
|
|
scraped_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Templates indexes
|
|
CREATE INDEX IF NOT EXISTS idx_template_nodes ON templates(nodes_used);
|
|
CREATE INDEX IF NOT EXISTS idx_template_updated ON templates(updated_at);
|
|
CREATE INDEX IF NOT EXISTS idx_template_name ON templates(name);
|
|
|
|
-- Note: FTS5 tables are created conditionally at runtime if FTS5 is supported
|
|
-- See template-repository.ts initializeFTS5() method |