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

@@ -276,34 +276,58 @@ export const n8nManagementTools: ToolDefinition[] = [
// Execution Management Tools
{
name: 'n8n_trigger_webhook_workflow',
description: `Trigger workflow via webhook. Must be ACTIVE with Webhook node. Method must match config.`,
name: 'n8n_test_workflow',
description: `Test/trigger workflow execution. Auto-detects trigger type (webhook/form/chat). Supports: webhook (HTTP), form (fields), chat (message). Note: Only workflows with these trigger types can be executed externally.`,
inputSchema: {
type: 'object',
properties: {
webhookUrl: {
type: 'string',
description: 'Full webhook URL from n8n workflow (e.g., https://n8n.example.com/webhook/abc-def-ghi)'
workflowId: {
type: 'string',
description: 'Workflow ID to execute (required)'
},
httpMethod: {
type: 'string',
triggerType: {
type: 'string',
enum: ['webhook', 'form', 'chat'],
description: 'Trigger type. Auto-detected if not specified. Workflow must have a matching trigger node.'
},
// Webhook options
httpMethod: {
type: 'string',
enum: ['GET', 'POST', 'PUT', 'DELETE'],
description: 'HTTP method (must match webhook configuration, often GET)'
description: 'For webhook: HTTP method (default: from workflow config or POST)'
},
data: {
type: 'object',
description: 'Data to send with the webhook request'
webhookPath: {
type: 'string',
description: 'For webhook: override the webhook path'
},
headers: {
type: 'object',
description: 'Additional HTTP headers'
// Chat options
message: {
type: 'string',
description: 'For chat: message to send (required for chat triggers)'
},
waitForResponse: {
type: 'boolean',
description: 'Wait for workflow completion (default: true)'
sessionId: {
type: 'string',
description: 'For chat: session ID for conversation continuity'
},
// Common options
data: {
type: 'object',
description: 'Input data/payload for webhook, form fields, or execution data'
},
headers: {
type: 'object',
description: 'Custom HTTP headers'
},
timeout: {
type: 'number',
description: 'Timeout in ms (default: 120000)'
},
waitForResponse: {
type: 'boolean',
description: 'Wait for workflow completion (default: true)'
}
},
required: ['webhookUrl']
required: ['workflowId']
}
},
{