mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 21:43: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
@@ -227,8 +227,13 @@ describe('handlers-n8n-manager', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
data: testWorkflow,
|
||||
message: 'Workflow "Test Workflow" created successfully with ID: test-workflow-id',
|
||||
data: {
|
||||
id: 'test-workflow-id',
|
||||
name: 'Test Workflow',
|
||||
active: true,
|
||||
nodeCount: 1,
|
||||
},
|
||||
message: 'Workflow "Test Workflow" created successfully with ID: test-workflow-id. Use n8n_get_workflow with mode \'structure\' to verify current state.',
|
||||
});
|
||||
|
||||
// Should send input as-is to API (n8n expects FULL form: n8n-nodes-base.*)
|
||||
@@ -732,8 +737,12 @@ describe('handlers-n8n-manager', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
data: testWorkflow,
|
||||
message: 'Workflow test-workflow-id deleted successfully',
|
||||
data: {
|
||||
id: 'test-workflow-id',
|
||||
name: 'Test Workflow',
|
||||
deleted: true,
|
||||
},
|
||||
message: 'Workflow "Test Workflow" deleted successfully.',
|
||||
});
|
||||
expect(mockApiClient.deleteWorkflow).toHaveBeenCalledWith('test-workflow-id');
|
||||
});
|
||||
|
||||
@@ -150,13 +150,15 @@ describe('handlers-workflow-diff', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
data: updatedWorkflow,
|
||||
message: 'Workflow "Test Workflow" updated successfully. Applied 1 operations.',
|
||||
details: {
|
||||
operationsApplied: 1,
|
||||
workflowId: 'test-workflow-id',
|
||||
workflowName: 'Test Workflow',
|
||||
data: {
|
||||
id: 'test-workflow-id',
|
||||
name: 'Test Workflow',
|
||||
active: true,
|
||||
nodeCount: 3,
|
||||
operationsApplied: 1,
|
||||
},
|
||||
message: 'Workflow "Test Workflow" updated successfully. Applied 1 operations. Use n8n_get_workflow with mode \'structure\' to verify current state.',
|
||||
details: {
|
||||
applied: [0],
|
||||
failed: [],
|
||||
errors: [],
|
||||
@@ -660,9 +662,15 @@ describe('handlers-workflow-diff', () => {
|
||||
}, mockRepository);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.data).toEqual(activatedWorkflow);
|
||||
expect(result.data).toEqual({
|
||||
id: 'test-workflow-id',
|
||||
name: 'Test Workflow',
|
||||
active: true,
|
||||
nodeCount: 2,
|
||||
operationsApplied: 1,
|
||||
});
|
||||
expect(result.message).toContain('Workflow activated');
|
||||
expect(result.details?.active).toBe(true);
|
||||
expect((result.data as any).active).toBe(true);
|
||||
expect(mockApiClient.activateWorkflow).toHaveBeenCalledWith('test-workflow-id');
|
||||
});
|
||||
|
||||
@@ -689,9 +697,15 @@ describe('handlers-workflow-diff', () => {
|
||||
}, mockRepository);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.data).toEqual(deactivatedWorkflow);
|
||||
expect(result.data).toEqual({
|
||||
id: 'test-workflow-id',
|
||||
name: 'Test Workflow',
|
||||
active: false,
|
||||
nodeCount: 2,
|
||||
operationsApplied: 1,
|
||||
});
|
||||
expect(result.message).toContain('Workflow deactivated');
|
||||
expect(result.details?.active).toBe(false);
|
||||
expect((result.data as any).active).toBe(false);
|
||||
expect(mockApiClient.deactivateWorkflow).toHaveBeenCalledWith('test-workflow-id');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user