feat: integrate n8n management tools from n8n-manager-for-ai-agents (v2.6.0)

- Added 14 n8n management tools for workflow CRUD and execution management
- Integrated n8n API client with full error handling and validation
- Added conditional tool registration (only when N8N_API_URL configured)
- Complete workflow lifecycle: discover → build → validate → deploy → execute
- Updated documentation and added integration tests
- Maintains backward compatibility - existing functionality unchanged

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-26 11:09:09 +02:00
parent 150de3d1c2
commit 74f05e937f
13 changed files with 2409 additions and 6 deletions

View File

@@ -0,0 +1,322 @@
import { ToolDefinition } from '../types';
/**
* n8n Management Tools
*
* These tools enable AI agents to manage n8n workflows through the n8n API.
* They require N8N_API_URL and N8N_API_KEY to be configured.
*/
export const n8nManagementTools: ToolDefinition[] = [
// Workflow Management Tools
{
name: 'n8n_create_workflow',
description: `Create a new workflow in n8n. Requires workflow name, nodes array, and connections object. The workflow will be created in inactive state and must be manually activated in the UI. Returns the created workflow with its ID.`,
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'Workflow name (required)'
},
nodes: {
type: 'array',
description: 'Array of workflow nodes. Each node must have: id, name, type, typeVersion, position, and parameters',
items: {
type: 'object',
required: ['id', 'name', 'type', 'typeVersion', 'position', 'parameters'],
properties: {
id: { type: 'string' },
name: { type: 'string' },
type: { type: 'string' },
typeVersion: { type: 'number' },
position: {
type: 'array',
items: { type: 'number' },
minItems: 2,
maxItems: 2
},
parameters: { type: 'object' },
credentials: { type: 'object' },
disabled: { type: 'boolean' },
notes: { type: 'string' },
continueOnFail: { type: 'boolean' },
retryOnFail: { type: 'boolean' },
maxTries: { type: 'number' },
waitBetweenTries: { type: 'number' }
}
}
},
connections: {
type: 'object',
description: 'Workflow connections object. Keys are source node IDs, values define output connections'
},
settings: {
type: 'object',
description: 'Optional workflow settings (execution order, timezone, error handling)',
properties: {
executionOrder: { type: 'string', enum: ['v0', 'v1'] },
timezone: { type: 'string' },
saveDataErrorExecution: { type: 'string', enum: ['all', 'none'] },
saveDataSuccessExecution: { type: 'string', enum: ['all', 'none'] },
saveManualExecutions: { type: 'boolean' },
saveExecutionProgress: { type: 'boolean' },
executionTimeout: { type: 'number' },
errorWorkflow: { type: 'string' }
}
}
},
required: ['name', 'nodes', 'connections']
}
},
{
name: 'n8n_get_workflow',
description: `Get a workflow by ID. Returns the complete workflow including nodes, connections, and settings.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID'
}
},
required: ['id']
}
},
{
name: 'n8n_get_workflow_details',
description: `Get detailed workflow information including metadata, version, and execution statistics. More comprehensive than get_workflow.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID'
}
},
required: ['id']
}
},
{
name: 'n8n_get_workflow_structure',
description: `Get simplified workflow structure showing only nodes and their connections. Useful for understanding workflow flow without parameter details.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID'
}
},
required: ['id']
}
},
{
name: 'n8n_get_workflow_minimal',
description: `Get minimal workflow information (ID, name, active status, tags). Fast and lightweight for listing purposes.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID'
}
},
required: ['id']
}
},
{
name: 'n8n_update_workflow',
description: `Update an existing workflow. Requires the full nodes array when modifying nodes/connections. Cannot activate workflows via API - use UI instead.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID to update'
},
name: {
type: 'string',
description: 'New workflow name'
},
nodes: {
type: 'array',
description: 'Complete array of workflow nodes (required if modifying workflow structure)'
},
connections: {
type: 'object',
description: 'Complete connections object (required if modifying workflow structure)'
},
settings: {
type: 'object',
description: 'Workflow settings to update'
}
},
required: ['id']
}
},
{
name: 'n8n_delete_workflow',
description: `Permanently delete a workflow. This action cannot be undone.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Workflow ID to delete'
}
},
required: ['id']
}
},
{
name: 'n8n_list_workflows',
description: `List workflows with optional filters. Supports pagination via cursor.`,
inputSchema: {
type: 'object',
properties: {
limit: {
type: 'number',
description: 'Number of workflows to return (1-100, default: 100)'
},
cursor: {
type: 'string',
description: 'Pagination cursor from previous response'
},
active: {
type: 'boolean',
description: 'Filter by active status'
},
tags: {
type: 'array',
items: { type: 'string' },
description: 'Filter by tags (exact match)'
},
projectId: {
type: 'string',
description: 'Filter by project ID (enterprise feature)'
},
excludePinnedData: {
type: 'boolean',
description: 'Exclude pinned data from response (default: true)'
}
}
}
},
// Execution Management Tools
{
name: 'n8n_trigger_webhook_workflow',
description: `Trigger a workflow via webhook. Workflow must be ACTIVE and have a Webhook trigger node. HTTP method must match webhook configuration.`,
inputSchema: {
type: 'object',
properties: {
webhookUrl: {
type: 'string',
description: 'Full webhook URL from n8n workflow (e.g., https://n8n.example.com/webhook/abc-def-ghi)'
},
httpMethod: {
type: 'string',
enum: ['GET', 'POST', 'PUT', 'DELETE'],
description: 'HTTP method (must match webhook configuration, often GET)'
},
data: {
type: 'object',
description: 'Data to send with the webhook request'
},
headers: {
type: 'object',
description: 'Additional HTTP headers'
},
waitForResponse: {
type: 'boolean',
description: 'Wait for workflow completion (default: true)'
}
},
required: ['webhookUrl']
}
},
{
name: 'n8n_get_execution',
description: `Get details of a specific execution by ID.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Execution ID'
},
includeData: {
type: 'boolean',
description: 'Include full execution data (default: false)'
}
},
required: ['id']
}
},
{
name: 'n8n_list_executions',
description: `List workflow executions with optional filters. Supports pagination.`,
inputSchema: {
type: 'object',
properties: {
limit: {
type: 'number',
description: 'Number of executions to return (1-100, default: 100)'
},
cursor: {
type: 'string',
description: 'Pagination cursor from previous response'
},
workflowId: {
type: 'string',
description: 'Filter by workflow ID'
},
projectId: {
type: 'string',
description: 'Filter by project ID (enterprise feature)'
},
status: {
type: 'string',
enum: ['success', 'error', 'waiting'],
description: 'Filter by execution status'
},
includeData: {
type: 'boolean',
description: 'Include execution data (default: false)'
}
}
}
},
{
name: 'n8n_delete_execution',
description: `Delete an execution record. This only removes the execution history, not any data processed.`,
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Execution ID to delete'
}
},
required: ['id']
}
},
// System Tools
{
name: 'n8n_health_check',
description: `Check n8n instance health and API connectivity. Returns status and available features.`,
inputSchema: {
type: 'object',
properties: {}
}
},
{
name: 'n8n_list_available_tools',
description: `List all available n8n management tools and their capabilities. Useful for understanding what operations are possible.`,
inputSchema: {
type: 'object',
properties: {}
}
}
];