# N8n MCP

## n8n MCP

### What This Does

Enables Claude Code to create, validate, test, and manage n8n workflows programmatically.

### Prerequisites

* Docker Desktop installed
* n8n instance with API access enabled
* n8n API Key (from Settings → API)

### Step 1: Create Local Config Folder

```bash
mkdir -p ~/.config/mcp/n8n
```

### Step 2: Get Credentials

1. Open your n8n instance
2. Go to **Settings → API**
3. Click **Create API Key**
4. Copy the API key (starts with `n8n_api_`)
5. Note your n8n URL (e.g., `https://your-instance.n8n.cloud`)

### Step 3: Save Credentials Locally

Create `~/.config/mcp/n8n/.env`:

```bash
cat > ~/.config/mcp/n8n/.env << 'EOF'
N8N_API_URL=https://your-n8n-instance.com
N8N_API_KEY=n8n_api_xxxxxxxxxxxxx
EOF
```

Replace with your actual values.

### Step 4: Pull Docker Image

```bash
docker pull ghcr.io/czlonkowski/n8n-mcp:latest
```

### Step 5: Test the Connection

```bash
# Load env and run
source ~/.config/mcp/n8n/.env && docker run --rm \
  -e N8N_API_URL="$N8N_API_URL" \
  -e N8N_API_KEY="$N8N_API_KEY" \
  ghcr.io/czlonkowski/n8n-mcp:latest \
  --version
```

### Step 6: Add to Claude Code

Add to `~/.claude/settings.json`:

```json
{
  "mcpServers": {
    "n8n-mcp": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "--env-file", "${HOME}/.config/mcp/n8n/.env",
        "ghcr.io/czlonkowski/n8n-mcp:latest"
      ]
    }
  }
}
```

**Note:** `${HOME}` expansion may not work in all environments. If it doesn't, use the full absolute path:

```json
{
  "mcpServers": {
    "n8n-mcp": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "--env-file", "/Users/yourname/.config/mcp/n8n/.env",
        "ghcr.io/czlonkowski/n8n-mcp:latest"
      ]
    }
  }
}
```

### Step 7: Verify It Works

Restart Claude Code and test:

```
List all workflows in n8n
```

Expected: You should see a list of your n8n workflows.

### Available Tools

| Tool                       | Description                     |
| -------------------------- | ------------------------------- |
| `n8n_create_workflow`      | Create new workflows            |
| `n8n_get_workflow`         | Retrieve workflow details       |
| `n8n_update_full_workflow` | Update entire workflow          |
| `n8n_delete_workflow`      | Delete workflows                |
| `n8n_list_workflows`       | List all workflows              |
| `n8n_validate_workflow`    | Validate workflow structure     |
| `n8n_test_workflow`        | Test/trigger workflow execution |
| `n8n_executions`           | View execution history          |
| `search_nodes`             | Search available nodes          |
| `get_node`                 | Get node documentation          |

### Troubleshooting

| Issue                 | Solution                                             |
| --------------------- | ---------------------------------------------------- |
| Connection refused    | Verify N8N\_API\_URL is accessible                   |
| 401 Unauthorized      | Check API key is correct                             |
| Image not found       | Run `docker pull ghcr.io/czlonkowski/n8n-mcp:latest` |
| Workflows not visible | Ensure API key has workflow access                   |
| env-file not found    | Use absolute path instead of `${HOME}`               |
