Skip to main content
Glama

get_template

Retrieve and export complete workflow JSON by template ID for immediate import into n8n. Use IDs from list_node_templates or search_templates to ensure accurate workflow retrieval.

Instructions

Get complete workflow JSON by ID. Ready to import. IDs from list_node_templates or search_templates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateIdYesThe template ID to retrieve

Implementation Reference

  • Core handler function for the get_template tool. Retrieves template by ID from repository, processes based on mode (nodes_only, structure, full), returns formatted response with workflow JSON.
    async getTemplate(templateId, mode = 'full') { const template = this.repository.getTemplate(templateId); if (!template) { return null; } const workflow = JSON.parse(template.workflow_json || '{}'); if (mode === 'nodes_only') { return { id: template.id, name: template.name, nodes: workflow.nodes?.map((n) => ({ type: n.type, name: n.name })) || [] }; } if (mode === 'structure') { return { id: template.id, name: template.name, nodes: workflow.nodes?.map((n) => ({ id: n.id, type: n.type, name: n.name, position: n.position })) || [], connections: workflow.connections || {} }; } return { ...this.formatTemplateInfo(template), workflow }; }
  • Database retrieval helper. Queries templates table by ID and decompresses the stored workflow JSON.
    getTemplate(templateId) { const row = this.db.prepare(` SELECT * FROM templates WHERE id = ? `).get(templateId); if (!row) return null; if (row.workflow_json_compressed && !row.workflow_json) { try { const compressed = Buffer.from(row.workflow_json_compressed, 'base64'); const decompressed = zlib.gunzipSync(compressed); row.workflow_json = decompressed.toString(); } catch (error) { logger_1.logger.error(`Failed to decompress workflow for template ${templateId}:`, error); return null; } } return row; }
  • Tool registration entry defining name, description, and input schema for MCP tool system.
    name: 'get_template', description: `Get template by ID. Use mode to control response size: nodes_only (minimal), structure (nodes+connections), full (complete workflow).`, inputSchema: { type: 'object', properties: { templateId: { type: 'number', description: 'The template ID to retrieve', }, mode: { type: 'string', enum: ['nodes_only', 'structure', 'full'], description: 'Response detail level. nodes_only: just node list, structure: nodes+connections, full: complete workflow JSON.', default: 'full', }, }, required: ['templateId'], }, },
  • Detailed tool documentation including parameters, returns, examples, performance, best practices.
    exports.getTemplateDoc = { name: 'get_template', category: 'templates', essentials: { description: 'Get workflow template by ID with configurable detail level. Ready to import. IDs from search_templates.', keyParameters: ['templateId', 'mode'], example: 'get_template({templateId: 1234, mode: "full"})', performance: 'Fast (<100ms) - single database lookup', tips: [ 'Get template IDs from search_templates first', 'Use mode="nodes_only" for quick overview, "structure" for topology, "full" for import', 'Returns complete workflow JSON ready for import into n8n' ] }, full: { description: `Retrieves the complete workflow JSON for a specific template by its ID. The returned workflow can be directly imported into n8n through the UI or API. This tool fetches pre-built workflows from the community template library containing 2,700+ curated workflows.`, parameters: { templateId: { type: 'number', required: true, description: 'The numeric ID of the template to retrieve. Get IDs from search_templates' }, mode: { type: 'string', required: false, description: 'Response detail level: "nodes_only" (minimal - just node list), "structure" (nodes + connections), "full" (complete workflow JSON, default)', default: 'full', enum: ['nodes_only', 'structure', 'full'] } }, returns: `Returns an object containing: - template: Complete template information including workflow JSON - id: Template ID - name: Template name - description: What the workflow does - author: Creator information (name, username, verified status) - nodes: Array of node types used - views: Number of times viewed - created: Creation date - url: Link to template on n8n.io - workflow: Complete workflow JSON with structure: - nodes: Array of node objects (id, name, type, typeVersion, position, parameters) - connections: Object mapping source nodes to targets - settings: Workflow configuration (timezone, error handling, etc.) - usage: Instructions for using the workflow`, examples: [ 'get_template({templateId: 1234}) - Get complete workflow (default mode="full")', 'get_template({templateId: 1234, mode: "nodes_only"}) - Get just the node list', 'get_template({templateId: 1234, mode: "structure"}) - Get nodes and connections', 'get_template({templateId: 5678, mode: "full"}) - Get complete workflow JSON for import' ], useCases: [ 'Download workflows for direct import into n8n', 'Study workflow patterns and best practices', 'Get complete workflow JSON for customization', 'Clone popular workflows for your use case', 'Learn how complex automations are built' ], performance: `Fast performance with single database lookup: - Query time: <10ms for template retrieval - Workflow JSON parsing: <50ms - Total response time: <100ms - No network calls (uses local cache)`, bestPractices: [ 'Always check if template exists before attempting modifications', 'Review workflow nodes before importing to ensure compatibility', 'Save template JSON locally if planning multiple customizations', 'Check template creation date for most recent patterns', 'Verify all required credentials are configured before import' ], pitfalls: [ 'Template IDs change when database is refreshed', 'Some templates may use deprecated node versions', 'Credentials in templates are placeholders - configure your own', 'Not all templates work with all n8n versions', 'Template may reference external services you don\'t have access to' ], relatedTools: ['search_templates', 'n8n_create_workflow'] } };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/czlonkowski/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server