mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-07 05:53:07 +00:00
perf: optimize workflow tool responses for token efficiency (v2.29.0) (#479)
* perf: optimize workflow tool responses for token efficiency (v2.29.0)
Reduce response sizes by 75-90% for 4 workflow management tools:
- n8n_update_partial_workflow: Returns {id, name, active, operationsApplied}
- n8n_create_workflow: Returns {id, name, active, nodeCount}
- n8n_update_full_workflow: Returns {id, name, active, nodeCount}
- n8n_delete_workflow: Returns {id, name, deleted: true}
AI agents can use n8n_get_workflow with mode 'structure' if they need
to verify the current workflow state after operations.
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: update tests and add nodeCount to partial update response
- Fix handleCreateWorkflow test to expect minimal response
- Fix handleDeleteWorkflow test to expect minimal response
- Add nodeCount to n8n_update_partial_workflow response for consistency
- Update documentation and CHANGELOG
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: update handlers-workflow-diff tests for minimal response
Update 3 more tests that expected full workflow in response:
- should apply diff operations successfully
- should activate workflow after successful update
- should deactivate workflow after successful update
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update integration tests to use minimal response format
Integration tests now verify minimal response format and use
client.getWorkflow() to fetch actual workflow state for verification.
Conceived by Romuald Czlonkowski - www.aiadvisors.pl/en
* fix: update create/update workflow integration tests for minimal response
Integration tests now verify minimal response and use client.getWorkflow()
to fetch actual workflow state for detailed verification.
Conceived by Romuald Czlonkowski - www.aiadvisors.pl/en
* fix: add type assertions to fix TypeScript errors in tests
Conceived by Romuald Czlonkowski - www.aiadvisors.pl/en
---------
Co-authored-by: Romuald Członkowski <romualdczlonkowski@MacBook-Pro-Romuald.local>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
130dd44ea5
commit
b92e511463
@@ -75,14 +75,18 @@ describe('Integration: handleUpdateWorkflow', () => {
|
||||
mcpContext
|
||||
);
|
||||
|
||||
// Verify MCP response
|
||||
// Verify MCP response - now returns minimal data
|
||||
expect(response.success).toBe(true);
|
||||
expect(response.data).toBeDefined();
|
||||
|
||||
const updated = response.data as any;
|
||||
expect(updated.id).toBe(created.id);
|
||||
expect(updated.name).toBe(replacement.name);
|
||||
expect(updated.nodes).toHaveLength(2); // HTTP workflow has 2 nodes
|
||||
expect(updated.nodeCount).toBe(2); // HTTP workflow has 2 nodes
|
||||
|
||||
// Fetch actual workflow to verify
|
||||
const actual = await client.getWorkflow(created.id);
|
||||
expect(actual.nodes).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -147,9 +151,14 @@ describe('Integration: handleUpdateWorkflow', () => {
|
||||
);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
// Response now returns minimal data
|
||||
const updated = response.data as any;
|
||||
expect(updated.nodes).toHaveLength(2);
|
||||
expect(updated.nodes.find((n: any) => n.name === 'Set')).toBeDefined();
|
||||
expect(updated.nodeCount).toBe(2);
|
||||
|
||||
// Fetch actual workflow to verify
|
||||
const actual = await client.getWorkflow(created.id);
|
||||
expect(actual.nodes).toHaveLength(2);
|
||||
expect(actual.nodes.find((n: any) => n.name === 'Set')).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -193,9 +202,13 @@ describe('Integration: handleUpdateWorkflow', () => {
|
||||
);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
// Response now returns minimal data
|
||||
const updated = response.data as any;
|
||||
// Note: n8n API may not return settings in response
|
||||
expect(updated.nodes).toHaveLength(1); // Nodes unchanged
|
||||
expect(updated.nodeCount).toBe(1); // Nodes unchanged
|
||||
|
||||
// Fetch actual workflow to verify
|
||||
const actual = await client.getWorkflow(created.id);
|
||||
expect(actual.nodes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -294,9 +307,14 @@ describe('Integration: handleUpdateWorkflow', () => {
|
||||
);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
// Response now returns minimal data
|
||||
const updated = response.data as any;
|
||||
expect(updated.name).toBe(newName);
|
||||
expect(updated.nodes).toHaveLength(1); // Structure unchanged
|
||||
expect(updated.nodeCount).toBe(1); // Structure unchanged
|
||||
|
||||
// Fetch actual workflow to verify
|
||||
const actual = await client.getWorkflow(created.id);
|
||||
expect(actual.nodes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -340,9 +358,13 @@ describe('Integration: handleUpdateWorkflow', () => {
|
||||
);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
// Response now returns minimal data
|
||||
const updated = response.data as any;
|
||||
expect(updated.name).toBe(newName);
|
||||
expect(updated.settings?.timezone).toBe('America/New_York');
|
||||
|
||||
// Fetch actual workflow to verify settings
|
||||
const actual = await client.getWorkflow(created.id);
|
||||
expect(actual.settings?.timezone).toBe('America/New_York');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user