feat: rename n8n_trigger_webhook_workflow to n8n_test_workflow with multi-trigger support (#460)

* feat: rename n8n_trigger_webhook_workflow to n8n_test_workflow with multi-trigger support

- Rename tool from n8n_trigger_webhook_workflow to n8n_test_workflow
- Add support for webhook, form, and chat triggers (auto-detection)
- Implement modular trigger system with registry pattern
- Add trigger detector for automatic trigger type inference
- Remove execute trigger type (n8n public API limitation)
- Add comprehensive tests for trigger detection and handlers

The tool now auto-detects trigger type from workflow structure and
supports all externally-triggerable workflows via n8n's public API.

Note: Direct workflow execution (Schedule/Manual triggers) requires
n8n's instance-level MCP access, not available via REST API.

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: add SSRF protection to webhook handler and update tests

- Add SSRF URL validation to webhook-handler.ts (critical security fix)
  Aligns with existing SSRF protection in form-handler.ts and chat-handler.ts
- Update parameter-validation.test.ts to use new n8n_test_workflow tool name

Conceived by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: n8n_test_workflow unified trigger tool (v2.28.0)

Added new `n8n_test_workflow` tool replacing `n8n_trigger_webhook_workflow`:

Features:
- Auto-detects trigger type (webhook/form/chat) from workflow
- Supports multiple trigger types with type-specific parameters
- SSRF protection for all trigger handlers
- Extensible handler architecture with registry pattern

Changes:
- Fixed Zod schema to remove invalid 'execute' trigger type
- Updated README.md tool documentation
- Added CHANGELOG entry for v2.28.0
- Bumped version to 2.28.0

Conceived by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add comprehensive unit tests for trigger handlers

Added 87 unit tests across 4 test files to improve code coverage:

- base-handler.test.ts (19 tests) - 100% coverage
- webhook-handler.test.ts (22 tests) - 100% coverage
- chat-handler.test.ts (23 tests) - 100% coverage
- form-handler.test.ts (23 tests) - 100% coverage

Tests cover:
- Input validation and parameter handling
- SSRF protection integration
- HTTP method handling and URL building
- Error response formatting
- Execution paths for all trigger types

Conceived by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Romuald Członkowski
2025-12-01 15:55:14 +01:00
committed by GitHub
parent ddf9556759
commit 33690c5650
30 changed files with 4131 additions and 197 deletions

View File

@@ -7,6 +7,92 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [2.28.0] - 2025-12-01
### ✨ Features
**n8n_test_workflow: Unified Workflow Trigger Tool**
Replaced `n8n_trigger_webhook_workflow` with a new unified `n8n_test_workflow` tool that supports multiple trigger types with auto-detection.
#### Key Features
1. **Auto-Detection of Trigger Type**
- Automatically analyzes workflow to detect trigger type (webhook, form, or chat)
- No need to specify triggerType unless you want to override detection
2. **Multi-Trigger Support**
- **Webhook**: HTTP-based triggers (GET/POST/PUT/DELETE) with custom headers and data
- **Form**: Form submission triggers with form field data
- **Chat**: AI chat triggers with message and session continuity
3. **SSRF Protection**
- All trigger handlers include SSRF URL validation
- Blocks requests to private networks, cloud metadata endpoints
- Configurable security modes (strict/moderate/permissive)
4. **Extensible Handler Architecture**
- Plugin-based trigger handler system
- Registry pattern for easy extension
- Clean separation of concerns
#### Usage
```javascript
// Auto-detect trigger type (recommended)
n8n_test_workflow({workflowId: "123"})
// Webhook with data
n8n_test_workflow({
workflowId: "123",
triggerType: "webhook",
httpMethod: "POST",
data: {name: "John", email: "john@example.com"}
})
// Chat trigger
n8n_test_workflow({
workflowId: "123",
triggerType: "chat",
message: "Hello AI assistant",
sessionId: "conversation-123"
})
// Form submission
n8n_test_workflow({
workflowId: "123",
triggerType: "form",
data: {email: "test@example.com", name: "Test User"}
})
```
#### Breaking Changes
- **Removed**: `n8n_trigger_webhook_workflow` tool
- **Replaced by**: `n8n_test_workflow` with enhanced capabilities
- **Migration**: Change tool name and add `workflowId` parameter (previously `webhookUrl`)
#### Technical Details
**New Files:**
- `src/triggers/` - Complete trigger system module
- `types.ts` - Type definitions for all trigger types
- `trigger-detector.ts` - Auto-detection logic
- `trigger-registry.ts` - Handler registration
- `handlers/` - Individual handler implementations
**Modified Files:**
- `src/mcp/handlers-n8n-manager.ts` - New `handleTestWorkflow` function
- `src/mcp/tools-n8n-manager.ts` - Updated tool definition
- `src/mcp/tool-docs/workflow_management/` - New documentation
**Test Coverage:**
- 32 unit tests for trigger detection and registry
- 30 unit tests for SSRF protection
- All parameter validation tests updated
**Conceived by Romuald Członkowski - [AiAdvisors](https://www.aiadvisors.pl/en)**
## [2.27.2] - 2025-11-29
### ✨ Enhanced Features