How the n8n-mcp Example Generator Creates Real-World Configurations from Templates

The n8n-mcp ExampleGenerator service transforms abstract node schemas into ready-to-run n8n configurations by combining a curated template library with intelligent, metadata-driven generation.

The czlonkowski/n8n-mcp repository provides a Model Context Protocol (MCP) server that bridges AI assistants with n8n workflow automation. At its core, the n8n-mcp example generator converts technical node definitions into practical, executable configurations that users can deploy immediately without manual drafting.

Understanding the ExampleGenerator Architecture

Located in src/services/example-generator.ts, the ExampleGenerator service operates through a dual-mode system. It first consults a static library of hand-crafted templates, then falls back to dynamic generation when curated examples are unavailable. This architecture ensures comprehensive coverage across both popular n8n nodes and obscure custom integrations.

The service integrates with src/parsers/property-extractor.ts to obtain node metadata and exposes its functionality through src/mcp/tools.ts, enabling AI assistants to deliver production-ready configurations on demand.

Curated Templates vs. Dynamic Generation

The NODE_EXAMPLES Library

The static NODE_EXAMPLES map (lines 19-78) stores production-ready configurations for common n8n nodes like httpRequest, webhook, and code. Each entry organizes examples into three tiers: minimal, common, and advanced.

When you request an HTTP Request node example, the generator returns pre-built configurations such as POST requests to https://api.example.com/users with proper JSON body structures and authentication headers already configured.

import { ExampleGenerator } from 'n8n-mcp';

// Returns the full set (minimal / common / advanced) for the HTTP Request node
const httpExamples = ExampleGenerator.getExamples('nodes-base.httpRequest');

console.log(httpExamples.common);
// → {
//   method: 'POST',
//   url: 'https://api.example.com/users',
//   sendBody: true,
//   contentType: 'json',
//   jsonBody: '{\n  "name": "John Doe",\n  "email": "john@example.com"\n}'
// }

Automatic Fallback with generateBasicExamples

For node types absent from the curated library, the generator invokes generateBasicExamples() (lines 96-112). This method inspects the node's essentials—required and common properties extracted by the property parser—and constructs minimal working configurations.

The system derives sensible defaults from property metadata, ensuring that even undocumented or brand-new node types receive functional starter configurations.

// Suppose we have a brand‑new node type "nodes-custom.fooBar"
const essentials = {
  required: [{ name: 'url', type: 'string' }],
  common: [{ name: 'timeout', type: 'number' }]
};

const generated = ExampleGenerator.getExamples('nodes-custom.fooBar', essentials);

console.log(generated.minimal);
// → { url: 'https://api.example.com', timeout: 30000 }

The Default Value Engine

Type-Aware Value Resolution

The getDefaultValue() method (lines 118-150) determines appropriate placeholder values based on property types and metadata. It handles booleans, numbers, arrays, and objects with type-specific logic that mirrors real-world usage patterns.

String Pattern Recognition

For string properties, the generator delegates to getStringDefault() (lines 154-190), which recognizes semantic patterns in property names. It automatically supplies https://api.example.com for URL fields, user@example.com for email parameters, and realistic file paths for directory inputs.

Public API Methods

Retrieving Examples by Node Type

The getExamples(nodeType, essentials?) method serves as the primary entry point. When called with a curated node type like nodes-base.httpRequest, it returns the complete example set. For unknown nodes, it accepts an essentials parameter containing required and common properties to trigger on-the-fly generation.

Task-Based Example Selection

The getTaskExample(nodeType, task) method (lines 78-105) maps high-level descriptors to specific complexity tiers. It translates human-readable tasks like "simple", "complex", or "full" into the appropriate minimal, common, or advanced configuration levels.

const codeExample = ExampleGenerator.getTaskExample(
  'nodes-base.code',
  'complex'   // maps to the "advanced" tier
);

console.log(codeExample?.language); // → 'javaScript'
console.log(codeExample?.jsCode?.slice(0, 60)); // first 60 chars of the advanced script

Integration with MCP Tools

The generator exposes its functionality through MCP tools defined in src/mcp/tools.ts. When an AI assistant calls the tool with parameters like getNodeExample('nodes-base.slack', 'full'), the system returns the advanced Slack configuration ready for immediate workflow integration.

// Inside src/mcp/tools.ts (simplified)
export async function getNodeExample(nodeType: string, task = 'basic') {
  const example = ExampleGenerator.getTaskExample(nodeType, task);
  return { nodeType, example };
}

The property metadata required for dynamic generation originates from src/parsers/property-extractor.ts, which analyzes n8n node schemas to identify required fields and common parameters.

Summary

  • The ExampleGenerator combines curated templates in NODE_EXAMPLES with dynamic generation via generateBasicExamples()
  • getDefaultValue() and getStringDefault() provide intelligent defaults based on property types and naming patterns
  • The getExamples() and getTaskExample() APIs offer both direct node lookup and task-based complexity selection
  • Integration with src/mcp/tools.ts enables AI assistants to deliver production-ready n8n configurations without manual drafting

Frequently Asked Questions

How does the n8n-mcp example generator handle unsupported node types?

When a node type lacks a curated entry in NODE_EXAMPLES, the generator falls back to generateBasicExamples() in src/services/example-generator.ts. This method analyzes the node's essential properties and constructs a minimal configuration using getDefaultValue() to populate sensible defaults based on property metadata.

What is the difference between minimal, common, and advanced example tiers?

The three tiers represent progressive complexity levels stored in the static NODE_EXAMPLES map (lines 19-78). Minimal configurations contain only required parameters, common examples add standard optional fields, and advanced tiers include complex features like error handling, pagination, and authentication flows.

How does the generator determine default values for string properties?

The getStringDefault() method (lines 154-190) analyzes property names for semantic patterns. It recognizes URLs, email addresses, file paths, and API endpoints, then returns realistic placeholders like https://api.example.com or user@example.com that match the expected data format.

Can AI assistants request specific complexity levels for node examples?

Yes, through the getTaskExample() method which accepts task descriptors like "simple", "complex", or "full". This method maps human-readable complexity indicators to the appropriate tier in the example set, allowing AI systems to request configurations matching the user's technical expertise level.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →