How to Connect Claude Code to n8n: Build AI-Powered Automations with MCP
I wanted Claude Code to trigger my n8n workflows directly. But there was no built-in way to do this - until I found the n8n-MCP server.
The Problem
I use n8n for workflow automation. I use Claude Code for development. These two powerful tools couldn’t talk to each other.
I wanted Claude to:
- Trigger n8n workflows from my coding sessions
- Read workflow execution results
- Create and modify automations
But n8n has a REST API, not an MCP server. And Claude Code only speaks MCP.
What is MCP?
MCP stands for Model Context Protocol. It’s the bridge that lets Claude Code interact with external tools and services.
Think of it like this:
+-------------+ MCP Server +-------------+| Claude Code | <------------------> | n8n API |+-------------+ +-------------+ | | | Uses MCP protocol | REST API v v+-------------+ +-------------+| Your Code | | Workflows |+-------------+ +-------------+Claude Code needs an MCP server in the middle to translate between MCP and n8n’s REST API.
Finding the Solution
I searched GitHub and found n8n-mcp by czlonkowski. It’s exactly what I needed - an MCP server that bridges Claude Code with n8n.
Here’s how the integration works:
1. Claude Code sends MCP request2. n8n-mcp translates to n8n API call3. n8n executes the workflow4. Results flow back through MCP5. Claude Code receives the responseStep-by-Step Setup
Step 1: Clone the n8n-MCP Repository
git clone https://github.com/czlonkowski/n8n-mcpcd n8n-mcpnpm installnpm run buildStep 2: Get Your n8n API Key
In your n8n instance:
- Go to Settings → API
- Create a new API key
- Copy the key and your n8n URL
Step 3: Configure Claude Code
I made a mistake here first. I tried to add the configuration to the wrong file.
Wrong approach - I put it in ~/.claude/config.json. Nothing happened.
Correct approach - Add to ~/.claude/settings.json:
{ "mcpServers": { "n8n": { "command": "node", "args": ["/absolute/path/to/n8n-mcp/build/index.js"], "env": { "N8N_API_URL": "http://localhost:5678", "N8N_API_KEY": "your-api-key-here" } } }}Make sure to use the absolute path to the built index.js file.
Step 4: Restart Claude Code
After updating the settings, restart Claude Code for the changes to take effect.
Using the Integration
Now Claude Code can interact with n8n. Here are some things I’ve done:
Trigger a Workflow
I just ask Claude:
“Trigger my ‘send-email’ workflow with recipient [email protected]”
Claude uses the n8n-mcp server to execute the workflow with the provided parameters.
List Workflows
“Show me all my n8n workflows”
Claude retrieves and displays my workflow list.
Check Execution Status
“Did the last workflow run successfully?”
Claude queries the execution history.
Common Mistakes I Made
Mistake 1: Wrong Configuration File
I initially added the MCP config to config.json instead of settings.json. The MCP server never loaded.
Fix: Use ~/.claude/settings.json for MCP server configurations.
Mistake 2: Relative Path
I used a relative path for the args:
"args": ["./n8n-mcp/build/index.js"]This failed because Claude Code couldn’t resolve the path.
Fix: Always use absolute paths:
"args": ["/Users/yourname/projects/n8n-mcp/build/index.js"]Mistake 3: Missing Environment Variables
I forgot to set N8N_API_URL and N8N_API_KEY. The MCP server started but couldn’t connect to n8n.
Fix: Always include both environment variables in the env section.
Why This Matters
Combining Claude Code with n8n opens powerful automation possibilities:
- AI-Driven Workflows: Claude can decide when to trigger workflows based on context
- Natural Language Automation: Describe what you want in plain English
- Code + Automation: Mix coding tasks with workflow triggers
- Iterative Development: Test workflows directly from Claude Code sessions
Architecture Deep Dive
The n8n-mcp server acts as a translator:
┌─────────────────────────────────────────┐│ n8n-mcp Server ││ ││ ┌─────────────┐ ┌─────────────┐ ││ │ MCP Protocol│ │ n8n REST │ ││ │ Handler │───▶│ API │ ││ └─────────────┘ └─────────────┘ ││ ▲ │ │└─────────│───────────────────│──────────┘ │ ▼ Claude Code n8n InstanceThe server implements the MCP protocol on one side and makes REST calls to n8n on the other. This architecture allows Claude Code to work with any service that has an API - you just need to build (or find) an MCP server for it.
Related Knowledge
- Model Context Protocol (MCP): A standardized way for AI assistants to connect to external tools and data sources
- n8n: Open-source workflow automation tool (alternative to Zapier)
- Claude Code: Anthropic’s CLI tool for AI-assisted development
Alternative Approaches
Before finding n8n-mcp, I considered:
- Direct REST API calls: Would require writing custom code for each interaction
- Zapier/Make: These have MCP support but I prefer self-hosted n8n
- Custom MCP server: Would work but n8n-mcp already exists
The n8n-mcp approach is cleaner because it follows the MCP standard and requires no custom code.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments