feat: n8n_deploy_template deploy-first with auto-fix (v2.27.2) (#457)

* feat: n8n_deploy_template deploy-first with auto-fix (v2.27.2)

Improved template deployment to deploy first, then automatically fix common
issues. This dramatically improves deployment success rates for templates
with expression format issues.

Key Changes:
- Deploy-first behavior: templates deployed before validation
- Auto-fix runs automatically after deployment (configurable via `autoFix`)
- Returns `fixesApplied` array showing all corrections made
- Fixed expression validator "nested expressions" false positive
- Fixed Zod schema missing `typeversion-upgrade` and `version-migration` fix types

Testing: 87% deployment success rate across 15 diverse templates

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

Co-Authored-By: Claude <noreply@anthropic.com>

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

* fix: address code review findings for deploy template

Code review fixes:
- CRITICAL: Update test schema to use `autoFix` instead of old `validate` parameter
- WARNING: Add `AppliedFix` and `AutofixResultData` interfaces for type safety
- WARNING: Add `autoFixStatus` field to response (success/failed/skipped)
- WARNING: Report auto-fix failure in response message

Changes:
- tests/unit/mcp/handlers-deploy-template.test.ts: Fixed schema and test cases
- src/mcp/handlers-n8n-manager.ts: Added type definitions, autoFixStatus tracking
- src/mcp/tool-docs/workflow_management/n8n-deploy-template.ts: Updated docs

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

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Romuald Członkowski
2025-11-29 16:10:14 +01:00
committed by GitHub
parent 7d9b456887
commit ddf9556759
9 changed files with 173 additions and 61 deletions

View File

@@ -4,39 +4,39 @@ export const n8nDeployTemplateDoc: ToolDocumentation = {
name: 'n8n_deploy_template',
category: 'workflow_management',
essentials: {
description: 'Deploy a workflow template from n8n.io directly to your n8n instance. Fetches template, optionally upgrades node versions and validates, then creates workflow.',
keyParameters: ['templateId', 'name', 'autoUpgradeVersions', 'validate', 'stripCredentials'],
description: 'Deploy a workflow template from n8n.io directly to your n8n instance. Deploys first, then auto-fixes common issues (expression format, typeVersions).',
keyParameters: ['templateId', 'name', 'autoUpgradeVersions', 'autoFix', 'stripCredentials'],
example: 'n8n_deploy_template({templateId: 2776, name: "My Deployed Template"})',
performance: 'Network-dependent',
tips: [
'Auto-fixes expression format issues after deployment',
'Workflow created inactive - configure credentials in n8n UI first',
'Returns list of required credentials',
'Use search_templates to find template IDs',
'Templates are upgraded to latest node versions by default'
'Returns list of required credentials and fixes applied',
'Use search_templates to find template IDs'
]
},
full: {
description: 'Deploys a workflow template from n8n.io directly to your n8n instance. This tool combines fetching a template and creating a workflow in a single operation. Templates are stored locally and fetched from the database. The workflow is always created in an inactive state, allowing you to configure credentials before activation.',
description: 'Deploys a workflow template from n8n.io directly to your n8n instance. This tool deploys first, then automatically fixes common issues like missing expression prefixes (=) and outdated typeVersions. Templates are stored locally and fetched from the database. The workflow is always created in an inactive state, allowing you to configure credentials before activation.',
parameters: {
templateId: { type: 'number', required: true, description: 'Template ID from n8n.io (find via search_templates)' },
name: { type: 'string', description: 'Custom workflow name (default: template name)' },
autoUpgradeVersions: { type: 'boolean', description: 'Upgrade node typeVersions to latest supported (default: true)' },
validate: { type: 'boolean', description: 'Validate workflow before deployment (default: true)' },
autoFix: { type: 'boolean', description: 'Auto-apply fixes after deployment for expression format issues, missing = prefix, etc. (default: true)' },
stripCredentials: { type: 'boolean', description: 'Remove credential references - user configures in n8n UI (default: true)' }
},
returns: 'Object with workflowId, name, nodeCount, triggerType, requiredCredentials array, url, templateId, templateUrl',
returns: 'Object with workflowId, name, nodeCount, triggerType, requiredCredentials array, url, templateId, templateUrl, autoFixStatus (success/failed/skipped), and fixesApplied array',
examples: [
`// Deploy template with default settings
`// Deploy template with default settings (auto-fix enabled)
n8n_deploy_template({templateId: 2776})`,
`// Deploy with custom name
n8n_deploy_template({
templateId: 2776,
name: "My Google Drive to Airtable Sync"
})`,
`// Deploy without validation (faster, use for trusted templates)
`// Deploy without auto-fix (not recommended)
n8n_deploy_template({
templateId: 2776,
validate: false
autoFix: false
})`,
`// Keep original node versions (useful for compatibility)
n8n_deploy_template({
@@ -50,10 +50,12 @@ n8n_deploy_template({
'Bootstrap new projects with proven workflows',
'Deploy templates found via search_templates'
],
performance: 'Network-dependent - Typically 200-500ms (template fetch + workflow creation)',
performance: 'Network-dependent - Typically 300-800ms (template fetch + workflow creation + autofix)',
bestPractices: [
'Use search_templates to find templates by use case',
'Review required credentials in the response',
'Check autoFixStatus in response - "success", "failed", or "skipped"',
'Check fixesApplied in response to see what was automatically corrected',
'Configure credentials in n8n UI before activating',
'Test workflow before connecting to production systems'
],
@@ -62,8 +64,8 @@ n8n_deploy_template({
'Workflows created in INACTIVE state - must configure credentials and activate in n8n',
'Templates may reference services you do not have (Slack, Google, etc.)',
'Template database must be populated - run npm run fetch:templates if templates not found',
'Validation may fail for templates with outdated node configurations'
'Some issues may not be auto-fixable (e.g., missing required fields that need user input)'
],
relatedTools: ['search_templates', 'get_template', 'n8n_create_workflow', 'n8n_validate_workflow']
relatedTools: ['search_templates', 'get_template', 'n8n_create_workflow', 'n8n_autofix_workflow']
}
};