Overview
The n8n-MCP server (by czlonkowski) connects Claude Code to your n8n instance, allowing you to build, modify, validate, and deploy n8n workflows directly from the CLI.
GitHub: https://github.com/czlonkowski/n8n-mcp
Prerequisites
- A running n8n instance with API access enabled
- Node.js / npm installed (for
npx) - Claude Code installed
Step 1: Generate n8n API Key
- Open your n8n instance (e.g.
https://n8n.adventuretube.net) - Go to Settings > API
- Click Create API Key
- Copy the generated JWT token — you’ll need it in Step 2
Note: The API key is a JWT token that expires. You’ll need to regenerate it when it expires.
Step 2: Create .mcp.json in Project Root
In your project directory, create a .mcp.json file:
{
"mcpServers": {
"n8n-mcp": {
"command": "npx",
"args": ["n8n-mcp"],
"env": {
"MCP_MODE": "stdio",
"LOG_LEVEL": "error",
"DISABLE_CONSOLE_OUTPUT": "true",
"N8N_API_URL": "https://your-n8n-instance.com",
"N8N_API_KEY": "your-n8n-api-key-here"
}
}
}
}
Key environment variables:
MCP_MODE: Must bestdiofor Claude Code integrationLOG_LEVEL: Set toerrorto suppress noisy logsDISABLE_CONSOLE_OUTPUT: Prevents stdout pollution that breaks MCP protocolN8N_API_URL: Your n8n instance URL (no trailing slash)N8N_API_KEY: The JWT token from Step 1
Step 3: Create .claude/settings.local.json for Tool Permissions
Create .claude/settings.local.json in your project directory to auto-approve all n8n-MCP tools:
{
"permissions": {
"allow": [
"mcp__n8n-mcp__tools_documentation",
"mcp__n8n-mcp__search_nodes",
"mcp__n8n-mcp__get_node",
"mcp__n8n-mcp__validate_node",
"mcp__n8n-mcp__validate_workflow",
"mcp__n8n-mcp__search_templates",
"mcp__n8n-mcp__get_template",
"mcp__n8n-mcp__n8n_health_check",
"mcp__n8n-mcp__n8n_create_workflow",
"mcp__n8n-mcp__n8n_get_workflow",
"mcp__n8n-mcp__n8n_update_full_workflow",
"mcp__n8n-mcp__n8n_update_partial_workflow",
"mcp__n8n-mcp__n8n_delete_workflow",
"mcp__n8n-mcp__n8n_list_workflows",
"mcp__n8n-mcp__n8n_validate_workflow",
"mcp__n8n-mcp__n8n_autofix_workflow",
"mcp__n8n-mcp__n8n_workflow_versions",
"mcp__n8n-mcp__n8n_deploy_template",
"mcp__n8n-mcp__n8n_test_workflow",
"mcp__n8n-mcp__n8n_executions"
]
}
}
Step 4: Create CLAUDE.md — The Critical Piece
This is the most important file. The CLAUDE.md file tells Claude Code HOW to use the MCP tools effectively. Without it, Claude will have the tools available but won’t know the best practices, validation strategy, or workflow patterns.
Why CLAUDE.md matters:
- Defines the workflow process: templates first, then node discovery, validation, building
- Sets parallel execution rules: independent operations run simultaneously
- Establishes validation strategy: minimal > full > workflow-level validation
- Documents critical warnings: never trust defaults, explicit parameter configuration
- Provides correct syntax for operations like
addConnection(4 separate string params) - Lists popular node types with correct prefixes
- Defines response format: silent execution, no commentary between tools
Without CLAUDE.md: Claude has the tools but uses them inefficiently — sequential calls, no validation, missing parameters, verbose output.
With CLAUDE.md: Claude operates like an n8n expert — parallel tool calls, templates-first approach, multi-level validation, silent execution.
Shared File Approach (Recommended)
The n8n instructions are stored as a shared file so any project can import them:
Shared file location:
~/.claude/shared/n8n-mcp-instructions.md
In your project’s .claude/CLAUDE.md, add this line at the end:
@import /Users/chrislee/.claude/shared/n8n-mcp-instructions.md
Replicating to Another Project
To set up n8n-MCP in a new project:
- Copy
.mcp.jsonto new project root — updateN8N_API_URLandN8N_API_KEYif connecting to a different n8n instance - Copy
.claude/settings.local.json— can be reused as-is - Add
@importto the end of your existing.claude/CLAUDE.md - Run
claudein the new project directory
Available Tools (20 total)
| Category | Tools |
|---|---|
| Discovery | tools_documentation, search_nodes, get_node, search_templates, get_template |
| Validation | validate_node, validate_workflow, n8n_validate_workflow |
| CRUD | n8n_create_workflow, n8n_get_workflow, n8n_update_full_workflow, n8n_update_partial_workflow, n8n_delete_workflow, n8n_list_workflows |
| Operations | n8n_health_check, n8n_autofix_workflow, n8n_workflow_versions, n8n_deploy_template, n8n_test_workflow, n8n_executions |
Core Principles for Using n8n MCP
1. Silent Execution
Execute tools without commentary. Only respond AFTER all tools complete.
2. Parallel Execution
When operations are independent, execute them in parallel for maximum performance.
3. Templates First
ALWAYS check templates before building from scratch (2,709 available).
4. Multi-Level Validation
Use validate_node(mode='minimal') > validate_node(mode='full') > validate_workflow pattern.
5. Never Trust Defaults
Default parameter values are the #1 source of runtime failures. ALWAYS explicitly configure ALL parameters that control node behavior.
Workflow Process
- Start: Call
tools_documentation()for best practices - Template Discovery Phase – Search templates using metadata, task, keyword, or node types
- Node Discovery – If no suitable template, search for nodes with
search_nodes - Configuration Phase – Use
get_nodewith different detail levels - Validation Phase – Validate nodes with minimal then full mode
- Building Phase – Build from validated configurations with explicit parameters
- Workflow Validation – Complete validation before deployment
- Deployment – Create, validate, and test workflow on n8n instance
Critical Warnings
Never Trust Defaults
Default values cause runtime failures. Always explicitly set all parameters:
// FAILS at runtime
{"resource": "message", "operation": "post", "text": "Hello"}
// WORKS - all parameters explicit
{"resource": "message", "operation": "post", "select": "channel", "channelId": "C123", "text": "Hello"}
addConnection Syntax
The addConnection operation requires four separate string parameters:
{
"type": "addConnection",
"source": "node-id-string",
"target": "target-node-id-string",
"sourcePort": "main",
"targetPort": "main"
}
IF Node Multi-Output Routing
IF nodes have two outputs (TRUE and FALSE). Use the branch parameter:
// Route to TRUE branch:
{"type": "addConnection", "source": "if-node-id", "target": "success-handler-id", "sourcePort": "main", "targetPort": "main", "branch": "true"}
// Route to FALSE branch:
{"type": "addConnection", "source": "if-node-id", "target": "failure-handler-id", "sourcePort": "main", "targetPort": "main", "branch": "false"}
Most Popular n8n Nodes
| # | Node | Description |
|---|---|---|
| 1 | n8n-nodes-base.code |
JavaScript/Python scripting |
| 2 | n8n-nodes-base.httpRequest |
HTTP API calls |
| 3 | n8n-nodes-base.webhook |
Event-driven triggers |
| 4 | n8n-nodes-base.set |
Data transformation |
| 5 | n8n-nodes-base.if |
Conditional routing |
| 6 | n8n-nodes-base.manualTrigger |
Manual workflow execution |
| 7 | n8n-nodes-base.scheduleTrigger |
Time-based triggers |
| 8 | @n8n/n8n-nodes-langchain.agent |
AI agents |
| 9 | n8n-nodes-base.googleSheets |
Spreadsheet integration |
| 10 | n8n-nodes-base.telegram |
Telegram bot integration |
Note: LangChain nodes use the @n8n/n8n-nodes-langchain. prefix, core nodes use n8n-nodes-base.
Troubleshooting
- MCP server not connecting: Check
N8N_API_URLhas no trailing slash and API key is valid - Tools not auto-approved: Verify
.claude/settings.local.jsonis in the correct directory - Claude not following best practices: Check
.claude/CLAUDE.mdexists and is properly formatted - API key expired: Regenerate in n8n Settings > API
