mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-23 19:03:07 +00:00
fix: improve n8n_list_workflows pagination clarity and performance (Issue #54)
- Changed misleading 'total' field to 'returned' to clarify it's the count in current page - Added 'hasMore' boolean flag for clear pagination indication - Added '_note' guidance when more data is available - Applied same improvements to n8n_list_executions for consistency Performance improvements: - Tool now returns only minimal metadata instead of full workflow structure - Reduced response size by ~95% (from thousands to ~10 tokens per workflow) - Eliminated token limit errors when listing workflows with many nodes - Updated descriptions and documentation to clarify minimal response 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
@@ -22,6 +22,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Now correctly uses `/healthz` endpoint which is available on all n8n instances
|
- Now correctly uses `/healthz` endpoint which is available on all n8n instances
|
||||||
- Improved error handling with proper fallback to workflow list endpoint
|
- Improved error handling with proper fallback to workflow list endpoint
|
||||||
- Fixed axios import for healthz endpoint access
|
- Fixed axios import for healthz endpoint access
|
||||||
|
- **n8n_list_workflows pagination clarity** (Issue #54)
|
||||||
|
- Changed misleading `total` field to `returned` to clarify it's the count of items in current page
|
||||||
|
- Added `hasMore` boolean flag for clear pagination indication
|
||||||
|
- Added `_note` field with guidance when more data is available ("More workflows available. Use cursor to get next page.")
|
||||||
|
- Applied same improvements to `n8n_list_executions` for consistency
|
||||||
|
- AI agents now correctly understand they need to use pagination instead of assuming limited total workflows
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- **Node type utilities** in `src/utils/node-utils.ts`
|
- **Node type utilities** in `src/utils/node-utils.ts`
|
||||||
@@ -39,6 +45,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Includes instructions for AI agents to inform users about version compatibility
|
- Includes instructions for AI agents to inform users about version compatibility
|
||||||
- Note: n8n API currently doesn't expose instance version, so manual verification is required
|
- Note: n8n API currently doesn't expose instance version, so manual verification is required
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
- **n8n_list_workflows response size optimization**
|
||||||
|
- Tool now returns only minimal metadata (id, name, active, dates, tags, nodeCount) instead of full workflow structure
|
||||||
|
- Reduced response size by ~95% - from potentially thousands of tokens per workflow to ~10 tokens
|
||||||
|
- Eliminated token limit errors when listing workflows with many nodes
|
||||||
|
- Updated tool description to clarify it returns "minimal metadata only"
|
||||||
|
- Users should use `n8n_get_workflow` to fetch full workflow details when needed
|
||||||
|
|
||||||
## [2.7.17] - 2025-07-17
|
## [2.7.17] - 2025-07-17
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -465,12 +465,27 @@ export async function handleListWorkflows(args: unknown): Promise<McpToolRespons
|
|||||||
excludePinnedData: input.excludePinnedData ?? true
|
excludePinnedData: input.excludePinnedData ?? true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Strip down workflows to only essential metadata
|
||||||
|
const minimalWorkflows = response.data.map(workflow => ({
|
||||||
|
id: workflow.id,
|
||||||
|
name: workflow.name,
|
||||||
|
active: workflow.active,
|
||||||
|
createdAt: workflow.createdAt,
|
||||||
|
updatedAt: workflow.updatedAt,
|
||||||
|
tags: workflow.tags || [],
|
||||||
|
nodeCount: workflow.nodes?.length || 0
|
||||||
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
workflows: response.data,
|
workflows: minimalWorkflows,
|
||||||
|
returned: minimalWorkflows.length,
|
||||||
nextCursor: response.nextCursor,
|
nextCursor: response.nextCursor,
|
||||||
total: response.data.length
|
hasMore: !!response.nextCursor,
|
||||||
|
...(response.nextCursor ? {
|
||||||
|
_note: "More workflows available. Use cursor to get next page."
|
||||||
|
} : {})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -688,8 +703,12 @@ export async function handleListExecutions(args: unknown): Promise<McpToolRespon
|
|||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
executions: response.data,
|
executions: response.data,
|
||||||
|
returned: response.data.length,
|
||||||
nextCursor: response.nextCursor,
|
nextCursor: response.nextCursor,
|
||||||
total: response.data.length
|
hasMore: !!response.nextCursor,
|
||||||
|
...(response.nextCursor ? {
|
||||||
|
_note: "More executions available. Use cursor to get next page."
|
||||||
|
} : {})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export const n8nListWorkflowsDoc: ToolDocumentation = {
|
|||||||
name: 'n8n_list_workflows',
|
name: 'n8n_list_workflows',
|
||||||
category: 'workflow_management',
|
category: 'workflow_management',
|
||||||
essentials: {
|
essentials: {
|
||||||
description: 'List workflows with optional filters. Supports pagination via cursor.',
|
description: 'List workflows (minimal metadata only - no nodes/connections). Supports pagination via cursor.',
|
||||||
keyParameters: ['limit', 'active', 'tags'],
|
keyParameters: ['limit', 'active', 'tags'],
|
||||||
example: 'n8n_list_workflows({limit: 20, active: true})',
|
example: 'n8n_list_workflows({limit: 20, active: true})',
|
||||||
performance: 'Fast (100-300ms)',
|
performance: 'Fast (100-300ms)',
|
||||||
@@ -15,7 +15,7 @@ export const n8nListWorkflowsDoc: ToolDocumentation = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
full: {
|
full: {
|
||||||
description: 'Lists workflows from n8n with powerful filtering options including active status, tags, and project assignment. Supports cursor-based pagination for large workflow collections. Returns minimal workflow information by default for performance.',
|
description: 'Lists workflows from n8n with powerful filtering options. Returns ONLY minimal metadata (id, name, active, dates, tags, nodeCount) - no workflow structure, nodes, or connections. Use n8n_get_workflow to fetch full workflow details.',
|
||||||
parameters: {
|
parameters: {
|
||||||
limit: { type: 'number', description: 'Number of workflows to return (1-100, default: 100)' },
|
limit: { type: 'number', description: 'Number of workflows to return (1-100, default: 100)' },
|
||||||
cursor: { type: 'string', description: 'Pagination cursor from previous response for next page' },
|
cursor: { type: 'string', description: 'Pagination cursor from previous response for next page' },
|
||||||
@@ -24,7 +24,7 @@ export const n8nListWorkflowsDoc: ToolDocumentation = {
|
|||||||
projectId: { type: 'string', description: 'Filter by project ID (enterprise feature)' },
|
projectId: { type: 'string', description: 'Filter by project ID (enterprise feature)' },
|
||||||
excludePinnedData: { type: 'boolean', description: 'Exclude pinned data from response (default: true)' }
|
excludePinnedData: { type: 'boolean', description: 'Exclude pinned data from response (default: true)' }
|
||||||
},
|
},
|
||||||
returns: 'Object with: data array (workflows with id, name, active, tags, dates), nextCursor (for pagination), and metadata (total count if available)',
|
returns: 'Object with: workflows array (minimal fields: id, name, active, createdAt, updatedAt, tags, nodeCount), returned (count in this response), hasMore (boolean), nextCursor (for pagination), and _note (guidance when more data exists)',
|
||||||
examples: [
|
examples: [
|
||||||
'n8n_list_workflows({limit: 20}) - First 20 workflows',
|
'n8n_list_workflows({limit: 20}) - First 20 workflows',
|
||||||
'n8n_list_workflows({active: true, tags: ["production"]}) - Active production workflows',
|
'n8n_list_workflows({active: true, tags: ["production"]}) - Active production workflows',
|
||||||
@@ -37,18 +37,18 @@ export const n8nListWorkflowsDoc: ToolDocumentation = {
|
|||||||
'Bulk workflow operations',
|
'Bulk workflow operations',
|
||||||
'Generate workflow reports'
|
'Generate workflow reports'
|
||||||
],
|
],
|
||||||
performance: 'Fast listing - typically 100-300ms for standard page sizes. Excludes workflow content for speed.',
|
performance: 'Very fast - typically 50-200ms. Returns only minimal metadata without workflow structure.',
|
||||||
bestPractices: [
|
bestPractices: [
|
||||||
'Use pagination for large instances',
|
'Always check hasMore flag to determine if pagination is needed',
|
||||||
'Cache results for UI responsiveness',
|
'Use cursor from previous response to get next page',
|
||||||
'Filter to reduce result set',
|
'The returned count is NOT the total in the system',
|
||||||
'Combine with get_workflow_minimal for details'
|
'Iterate with cursor until hasMore is false for complete list'
|
||||||
],
|
],
|
||||||
pitfalls: [
|
pitfalls: [
|
||||||
'Requires N8N_API_URL and N8N_API_KEY configured',
|
'Requires N8N_API_URL and N8N_API_KEY configured',
|
||||||
'Maximum 100 workflows per request',
|
'Maximum 100 workflows per request',
|
||||||
'Tags must match exactly (case-sensitive)',
|
'Server may return fewer than requested limit',
|
||||||
'No workflow content in results'
|
'returned field is count of current page only, not system total'
|
||||||
],
|
],
|
||||||
relatedTools: ['n8n_get_workflow_minimal', 'n8n_get_workflow', 'n8n_update_partial_workflow', 'n8n_list_executions']
|
relatedTools: ['n8n_get_workflow_minimal', 'n8n_get_workflow', 'n8n_update_partial_workflow', 'n8n_list_executions']
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ export const n8nManagementTools: ToolDefinition[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'n8n_list_workflows',
|
name: 'n8n_list_workflows',
|
||||||
description: `List workflows with optional filters. Supports pagination via cursor.`,
|
description: `List workflows (minimal metadata only). Returns id/name/active/dates/tags. Check hasMore/nextCursor for pagination.`,
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@@ -323,7 +323,7 @@ export const n8nManagementTools: ToolDefinition[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'n8n_list_executions',
|
name: 'n8n_list_executions',
|
||||||
description: `List workflow executions with optional filters. Supports pagination.`,
|
description: `List workflow executions (returns up to limit). Check hasMore/nextCursor for pagination.`,
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
|||||||
Reference in New Issue
Block a user