Skip to content

Latest commit

 

History

History
72 lines (57 loc) · 3.36 KB

File metadata and controls

72 lines (57 loc) · 3.36 KB

Comprehensive MCP Server Fixes for n8n Workflow Builder

Overview

This PR contains comprehensive fixes for critical bugs in the MCP (Model Context Protocol) server that were preventing proper functionality with n8n workflow automation.

Critical Bug Fixes

1. Transport Mode Detection Issue

  • Problem: Server was trying to use both stdin/stdout transport and HTTP server simultaneously, causing conflicts
  • Fix: Added smart detection between standalone HTTP mode vs MCP subprocess mode using process.env.MCP_STANDALONE and process.stdin.isTTY
  • Files: src/index.ts

2. Workflow Listing Bug

  • Problem: workflows.filter is not a function error due to incorrect API response parsing
  • Fix: Corrected workflow array extraction from n8n API response structure {data: [], nextCursor: null}
  • Files: src/services/n8nApiWrapper.ts

3. API Base URL Configuration

  • Problem: Missing /api/v1 path in n8n API calls
  • Fix: Updated API base URL to include proper /api/v1 path (${envConfig.n8n_host}/api/v1)
  • Files: src/services/environmentManager.ts

Workflow Execution Research & Documentation

4. Workflow Execution Limitation Discovery

  • Research: Extensive analysis of successful executions revealed that Manual Trigger workflows are executed through n8n's web interface, not REST API
  • Evidence: Found successful executions with "mode": "manual" that occurred via web interface
  • Documentation: Added comprehensive guidance about execution limitations and alternatives
  • Files: src/services/n8nApiWrapper.ts

5. Improved User Experience

  • Enhancement: Replaced failed API attempts with helpful guidance
  • Features:
    • Clear explanation of n8n design limitations
    • Step-by-step execution instructions
    • Alternative trigger type recommendations
    • Comprehensive error handling

Testing Results

✅ Working MCP Tools

  • list_workflows: Returns all workflows correctly
  • get_workflow: Returns detailed workflow information
  • create_workflow: Creates workflows via MCP
  • update_workflow: Updates workflows via MCP
  • list_executions: Shows existing executions
  • get_execution: Returns execution details

✅ CFP Automation Workflows

  • Successfully imported 3 sophisticated CFP scraping workflows
  • Enhanced workflow with Google Gemini AI integration working
  • Workflows can be managed programmatically via MCP tools
  • Manual execution confirmed working via n8n web interface

Impact

  • Before: MCP server completely non-functional due to transport conflicts and API parsing errors
  • After: Fully functional MCP server with comprehensive workflow management capabilities
  • Benefit: Enables AI-powered CFP automation with programmatic workflow control

Files Changed

  • src/index.ts - Transport mode detection
  • src/services/n8nApiWrapper.ts - API parsing fixes and execution guidance
  • src/services/environmentManager.ts - Base URL configuration

Breaking Changes

None - all changes are backwards compatible improvements and bug fixes.

Additional Notes

  • All changes have been thoroughly tested with real n8n instance
  • Workflow execution limitation is a design choice by n8n, not a bug in our implementation
  • Users can still execute workflows manually via n8n web interface
  • Alternative trigger types (webhooks, schedules) support API-based execution