This PR contains comprehensive fixes for critical bugs in the MCP (Model Context Protocol) server that were preventing proper functionality with n8n workflow automation.
- 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_STANDALONEandprocess.stdin.isTTY - Files:
src/index.ts
- Problem:
workflows.filter is not a functionerror due to incorrect API response parsing - Fix: Corrected workflow array extraction from n8n API response structure
{data: [], nextCursor: null} - Files:
src/services/n8nApiWrapper.ts
- Problem: Missing
/api/v1path in n8n API calls - Fix: Updated API base URL to include proper
/api/v1path (${envConfig.n8n_host}/api/v1) - Files:
src/services/environmentManager.ts
- 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
- 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
list_workflows: Returns all workflows correctlyget_workflow: Returns detailed workflow informationcreate_workflow: Creates workflows via MCPupdate_workflow: Updates workflows via MCPlist_executions: Shows existing executionsget_execution: Returns execution details
- 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
- 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
src/index.ts- Transport mode detectionsrc/services/n8nApiWrapper.ts- API parsing fixes and execution guidancesrc/services/environmentManager.ts- Base URL configuration
None - all changes are backwards compatible improvements and bug fixes.
- 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