diff --git a/src/mcp/handlers-workflow-diff.ts b/src/mcp/handlers-workflow-diff.ts index b6f541e..ece328e 100644 --- a/src/mcp/handlers-workflow-diff.ts +++ b/src/mcp/handlers-workflow-diff.ts @@ -21,7 +21,7 @@ const workflowDiffSchema = z.object({ node: z.any().optional(), nodeId: z.string().optional(), nodeName: z.string().optional(), - changes: z.any().optional(), + updates: z.any().optional(), position: z.tuple([z.number(), z.number()]).optional(), // Connection operations source: z.string().optional(), diff --git a/src/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.ts b/src/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.ts index 4d393ed..b5b99dd 100644 --- a/src/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.ts +++ b/src/mcp/tool-docs/workflow_management/n8n-update-partial-workflow.ts @@ -48,7 +48,7 @@ export const n8nUpdatePartialWorkflowDoc: ToolDocumentation = { }, returns: 'Updated workflow object or validation results if validateOnly=true', examples: [ - '// Update node parameter\nn8n_update_partial_workflow({id: "abc", operations: [{type: "updateNode", nodeName: "HTTP Request", changes: {"parameters.url": "https://api.example.com"}}]})', + '// Update node parameter\nn8n_update_partial_workflow({id: "abc", operations: [{type: "updateNode", nodeName: "HTTP Request", updates: {"parameters.url": "https://api.example.com"}}]})', '// Add connection between nodes\nn8n_update_partial_workflow({id: "xyz", operations: [{type: "addConnection", source: "Webhook", target: "Slack", sourceOutput: "main", targetInput: "main"}]})', '// Multiple operations in one call\nn8n_update_partial_workflow({id: "123", operations: [\n {type: "addNode", node: {name: "Transform", type: "n8n-nodes-base.code", position: [400, 300]}},\n {type: "addConnection", source: "Webhook", target: "Transform"},\n {type: "updateSettings", settings: {timezone: "America/New_York"}}\n]})', '// Validate before applying\nn8n_update_partial_workflow({id: "456", operations: [{type: "removeNode", nodeName: "Old Process"}], validateOnly: true})' @@ -73,7 +73,7 @@ export const n8nUpdatePartialWorkflowDoc: ToolDocumentation = { 'Operations validated together - all must be valid', 'Order matters for dependent operations (e.g., must add node before connecting to it)', 'Node references accept ID or name, but name must be unique', - 'Dot notation for nested updates: use "parameters.url" not nested objects' + 'Use "updates" property for updateNode operations: {type: "updateNode", updates: {...}}' ], relatedTools: ['n8n_update_full_workflow', 'n8n_get_workflow', 'validate_workflow', 'tools_documentation'] } diff --git a/src/services/workflow-diff-engine.ts b/src/services/workflow-diff-engine.ts index b6ef852..6475942 100644 --- a/src/services/workflow-diff-engine.ts +++ b/src/services/workflow-diff-engine.ts @@ -453,8 +453,8 @@ export class WorkflowDiffEngine { const node = this.findNode(workflow, operation.nodeId, operation.nodeName); if (!node) return; - // Apply changes using dot notation - Object.entries(operation.changes).forEach(([path, value]) => { + // Apply updates using dot notation + Object.entries(operation.updates).forEach(([path, value]) => { this.setNestedProperty(node, path, value); }); } @@ -545,18 +545,18 @@ export class WorkflowDiffEngine { type: 'removeConnection', source: operation.source, target: operation.target, - sourceOutput: operation.changes.sourceOutput, - targetInput: operation.changes.targetInput + sourceOutput: operation.updates.sourceOutput, + targetInput: operation.updates.targetInput }); this.applyAddConnection(workflow, { type: 'addConnection', source: operation.source, target: operation.target, - sourceOutput: operation.changes.sourceOutput, - targetInput: operation.changes.targetInput, - sourceIndex: operation.changes.sourceIndex, - targetIndex: operation.changes.targetIndex + sourceOutput: operation.updates.sourceOutput, + targetInput: operation.updates.targetInput, + sourceIndex: operation.updates.sourceIndex, + targetIndex: operation.updates.targetIndex }); } diff --git a/src/types/workflow-diff.ts b/src/types/workflow-diff.ts index 62c32c2..c74ca0b 100644 --- a/src/types/workflow-diff.ts +++ b/src/types/workflow-diff.ts @@ -31,7 +31,7 @@ export interface UpdateNodeOperation extends DiffOperation { type: 'updateNode'; nodeId?: string; // Can use either ID or name nodeName?: string; - changes: { + updates: { [path: string]: any; // Dot notation paths like 'parameters.url' }; } @@ -78,7 +78,7 @@ export interface UpdateConnectionOperation extends DiffOperation { type: 'updateConnection'; source: string; target: string; - changes: { + updates: { sourceOutput?: string; targetInput?: string; sourceIndex?: number; diff --git a/tests/unit/services/workflow-diff-engine.test.ts b/tests/unit/services/workflow-diff-engine.test.ts index f63fa2d..ff2d91f 100644 --- a/tests/unit/services/workflow-diff-engine.test.ts +++ b/tests/unit/services/workflow-diff-engine.test.ts @@ -281,7 +281,7 @@ describe('WorkflowDiffEngine', () => { const operation: UpdateNodeOperation = { type: 'updateNode', nodeId: 'http-1', - changes: { + updates: { 'parameters.method': 'POST', 'parameters.url': 'https://new-api.example.com' } @@ -304,7 +304,7 @@ describe('WorkflowDiffEngine', () => { const operation: UpdateNodeOperation = { type: 'updateNode', nodeName: 'Slack', - changes: { + updates: { 'parameters.resource': 'channel', 'parameters.operation': 'create', 'credentials.slackApi.name': 'New Slack Account' @@ -329,7 +329,7 @@ describe('WorkflowDiffEngine', () => { const operation: UpdateNodeOperation = { type: 'updateNode', nodeId: 'non-existent', - changes: { + updates: { 'parameters.test': 'value' } }; @@ -617,7 +617,7 @@ describe('WorkflowDiffEngine', () => { type: 'updateConnection', source: 'IF', target: 'slack-1', - changes: { + updates: { sourceOutput: 'false', sourceIndex: 0, targetIndex: 0 @@ -1039,7 +1039,7 @@ describe('WorkflowDiffEngine', () => { const operation: UpdateNodeOperation = { type: 'updateNode', nodeId: 'Webhook', // Using name as ID - changes: { + updates: { 'parameters.path': 'new-webhook-path' } };