get_templates_for_task
Retrieve pre-configured templates for specific automation tasks such as AI workflows, data synchronization, API integration, and scheduling to streamline workflow setup on n8n-MCP.
Instructions
Curated templates by task: ai_automation, data_sync, webhooks, email, slack, data_transform, files, scheduling, api, database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | The type of task to get templates for |
Implementation Reference
- Handler function in TemplateService that executes getTemplatesForTask logic: calls repository, adds pagination metadata, and formats response for API/tool use.async getTemplatesForTask(task: string, limit: number = 10, offset: number = 0): Promise<PaginatedResponse<TemplateInfo>> { const templates = this.repository.getTemplatesForTask(task, limit, offset); const total = this.repository.getTaskTemplatesCount(task); return { items: templates.map(this.formatTemplateInfo), total, limit, offset, hasMore: offset + limit < total }; }
- Core helper implementing the task-to-template mapping: predefined taskNodeMap translates task names to node type arrays, then fetches matching templates via getTemplatesByNodes.getTemplatesForTask(task: string, limit: number = 10, offset: number = 0): StoredTemplate[] { // Map tasks to relevant node combinations const taskNodeMap: Record<string, string[]> = { 'ai_automation': ['@n8n/n8n-nodes-langchain.openAi', '@n8n/n8n-nodes-langchain.agent', 'n8n-nodes-base.openAi'], 'data_sync': ['n8n-nodes-base.googleSheets', 'n8n-nodes-base.postgres', 'n8n-nodes-base.mysql'], 'webhook_processing': ['n8n-nodes-base.webhook', 'n8n-nodes-base.httpRequest'], 'email_automation': ['n8n-nodes-base.gmail', 'n8n-nodes-base.emailSend', 'n8n-nodes-base.emailReadImap'], 'slack_integration': ['n8n-nodes-base.slack', 'n8n-nodes-base.slackTrigger'], 'data_transformation': ['n8n-nodes-base.code', 'n8n-nodes-base.set', 'n8n-nodes-base.merge'], 'file_processing': ['n8n-nodes-base.readBinaryFile', 'n8n-nodes-base.writeBinaryFile', 'n8n-nodes-base.googleDrive'], 'scheduling': ['n8n-nodes-base.scheduleTrigger', 'n8n-nodes-base.cron'], 'api_integration': ['n8n-nodes-base.httpRequest', 'n8n-nodes-base.graphql'], 'database_operations': ['n8n-nodes-base.postgres', 'n8n-nodes-base.mysql', 'n8n-nodes-base.mongodb'] }; const nodes = taskNodeMap[task]; if (!nodes) { return []; } return this.getTemplatesByNodes(nodes, limit, offset); }
- src/mcp/tools-n8n-friendly.ts:56-56 (helper)Documentation comment noting that get_templates_for_task functionality has been consolidated into search_templates tool with searchMode="by_task".// Consolidated template search (replaces search_templates, list_node_templates, search_templates_by_metadata, get_templates_for_task)
- src/mcp/tools.ts:244-306 (schema)Input schema for equivalent functionality now in search_templates tool: defines 'task' parameter with exact enum matching the taskNodeMap keys.task: { type: 'string', enum: [ 'ai_automation', 'data_sync', 'webhook_processing', 'email_automation', 'slack_integration', 'data_transformation', 'file_processing', 'scheduling', 'api_integration', 'database_operations' ], description: 'For searchMode=by_task: the type of task', }, // For searchMode='by_metadata' category: { type: 'string', description: 'For searchMode=by_metadata: filter by category (e.g., "automation", "integration")', }, complexity: { type: 'string', enum: ['simple', 'medium', 'complex'], description: 'For searchMode=by_metadata: filter by complexity level', }, maxSetupMinutes: { type: 'number', description: 'For searchMode=by_metadata: maximum setup time in minutes', minimum: 5, maximum: 480, }, minSetupMinutes: { type: 'number', description: 'For searchMode=by_metadata: minimum setup time in minutes', minimum: 5, maximum: 480, }, requiredService: { type: 'string', description: 'For searchMode=by_metadata: filter by required service (e.g., "openai", "slack")', }, targetAudience: { type: 'string', description: 'For searchMode=by_metadata: filter by target audience (e.g., "developers", "marketers")', }, // Common pagination limit: { type: 'number', description: 'Maximum number of results. Default 20.', default: 20, minimum: 1, maximum: 100, }, offset: { type: 'number', description: 'Pagination offset. Default 0.', default: 0, minimum: 0, }, }, }, },