직접 만들고, 내 생각을 더하다
세상의 트렌드를 읽고 싶어하는 한 사람으로, 목공 DIY를 좋아하고, AI, n8n을 사용해 자동화 프로세스를 배우고 있다.

n8n 설치 완벽 가이드 2025: 엔터프라이즈급 워크플로우 자동화와 Claude AI MCP 연동 구현(n8n 기초 시리즈 2편)

n8n 2025 완벽 설치 가이드. Docker, PostgreSQL 환경 구성부터 Claude AI MCP 연동까지 엔터프라이즈급 워크플로우 자동화 구축 방법

 

왜 2025년에 n8n인가?

기업의 디지털 트랜스포메이션이 가속화되면서, 워크플로우 자동화는 더 이상 선택이 아닌 필수가 되었다. 특히 2024년 말 Anthropic이 발표한 Model Context Protocol(MCP)의 등장으로, n8n은 단순한 자동화 도구를 넘어 AI-네이티브 플랫폼으로 진화했다고 볼 수 있다.

이번 가이드에서는 n8n의 프로덕션 레벨의 로컬 설치부터 최신 MCP 연동까지, 자체적으로 n8n 환경을 구축하기 위해 요구되는 기술적 요구사항을 다뤄 보고자 한다.

1. n8n 아키텍처 이해와 설치 전 준비사항

1.1 시스템 요구사항 분석

최소 사양 (개발/테스트 환경)

  • CPU: 1 vCPU (2.0GHz)
  • RAM: 1GB
  • Storage: 10GB SSD
  • Node.js: 18.x LTS 이상

권장 사양 (프로덕션 환경)

  • CPU: 2+ vCPU (2.4GHz)
  • RAM: 4GB+
  • Storage: 50GB+ NVMe SSD
  • Node.js: 20.x LTS

1.2 네트워크 및 보안 고려사항

# 필수 포트 설정
Port 5678  # n8n 웹 인터페이스
Port 443   # HTTPS (프로덕션)
Port 80    # HTTP 리다이렉트

2. Docker 기반 n8n 설치 (권장)

2.1 Docker Compose를 활용한 프로덕션 설정

Docker는 n8n 설치의 가장 안정적이고 확장 가능한 방법이다. 다음 설정은 PostgreSQL 백엔드와 Redis 캐싱을 포함한 엔터프라이즈 구성이다.

PostgreSQL은 SQLite 대비 5-10배 동시성 처리가 개선되는 장점이 있고, 대용량 데이터 처리에 적합해서 추천한다.

Redis 캐싱은 임시 데이터와 실시간 큐 처리로 성능을 최적화하는 효과가 있다.

# docker-compose.yml
version: '3.8'

services:
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - NODE_ENV=production
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=${N8N_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
      - N8N_HOST=${N8N_HOST}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://${N8N_HOST}/
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${DB_NAME}
      - DB_POSTGRESDB_USER=${DB_USER}
      - DB_POSTGRESDB_PASSWORD=${DB_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
    volumes:
      - n8n_data:/home/node/.n8n
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:15-alpine
    container_name: n8n_postgres
    restart: unless-stopped
    environment:
      - POSTGRES_DB=${DB_NAME}
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    container_name: n8n_redis
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD}

volumes:
  n8n_data:
  postgres_data:

2.2 환경 변수 설정

# .env 파일 생성
cat > .env << EOF
N8N_USER=admin
N8N_PASSWORD=$(openssl rand -base64 32)
N8N_HOST=your-domain.com
DB_NAME=n8n
DB_USER=n8n_user
DB_PASSWORD=$(openssl rand -base64 32)
N8N_ENCRYPTION_KEY=$(openssl rand -base64 32)
REDIS_PASSWORD=$(openssl rand -base64 32)
EOF

2.3 실행 및 초기 설정

# 컨테이너 실행
docker-compose up -d

# 로그 모니터링
docker-compose logs -f n8n

# 상태 확인
docker-compose ps

3. npm 기반 로컬 설치

3.1 Node.js 환경 구성

# Node.js 20.x LTS 설치 (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# 버전 확인
node --version
npm --version

# PM2 프로세스 매니저 설치
npm install -g pm2

3.2 n8n 글로벌 설치

# n8n 설치
npm install -g n8n

# 시스템 서비스 설정
sudo tee /etc/systemd/system/n8n.service > /dev/null <<EOF
[Unit]
Description=n8n workflow automation
After=network.target

[Service]
Type=simple
User=n8n
WorkingDirectory=/home/n8n
Environment=NODE_ENV=production
Environment=N8N_HOST=0.0.0.0
Environment=N8N_PORT=5678
ExecStart=/usr/bin/n8n start
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

# 서비스 활성화
sudo systemctl enable n8n
sudo systemctl start n8n

4. 2025년 최신 MCP 연동 구현

4.1 n8n 네이티브 MCP 노드 활용

n8n 1.88 버전부터 도입된 네이티브 MCP 지원을 통해 Claude AI와의 직접 연동이 가능하다.

n8n과 MCP간의 관계를 묘사한 이미지


MCP Server Trigger 노드 설정

// n8n 워크플로우에서 MCP 서버 설정
{
  "nodes": [
    {
      "parameters": {
        "authentication": "bearerAuth",
        "path": "/mcp/calculator",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "mcp-server-trigger",
      "name": "MCP Server Trigger",
      "type": "n8n-nodes-base.mcpServerTrigger",
      "typeVersion": 1,
      "position": [250, 300]
    }
  ]
}

Claude Desktop 설정 파일 구성

{
  "mcpServers": {
    "n8n-automation": {
      "command": "npx",
      "args": [
        "-y", 
        "supergateway",
        "--sse",
        "https://your-n8n-domain.com/webhook/mcp-endpoint"
      ],
      "env": {
        "BEARER_TOKEN": "your-bearer-token"
      }
    }
  }
}

4.2 고급 MCP 서버 구현

커스텀 MCP 서버를 통한 더욱 정교한 제어가 필요한 경우:

# custom_mcp_server.py
from mcp import MCPServer, Resource, Tool
import asyncio
import aiohttp
import json

class N8nMCPServer(MCPServer):
    def __init__(self, n8n_host: str, api_key: str):
        super().__init__()
        self.n8n_host = n8n_host
        self.api_key = api_key
        self.session = None
    
    async def start(self):
        self.session = aiohttp.ClientSession()
        await super().start()
    
    @tool
    async def trigger_workflow(self, workflow_id: str, data: dict = None):
        """n8n 워크플로우 실행"""
        url = f"{self.n8n_host}/api/v1/workflows/{workflow_id}/activate"
        headers = {
            'X-N8N-API-KEY': self.api_key,
            'Content-Type': 'application/json'
        }
        
        async with self.session.post(url, json=data or {}, headers=headers) as resp:
            return await resp.json()
    
    @resource("/workflows/{workflow_id}/executions")
    async def get_workflow_executions(self, workflow_id: str):
        """워크플로우 실행 이력 조회"""
        url = f"{self.n8n_host}/api/v1/executions"
        headers = {'X-N8N-API-KEY': self.api_key}
        params = {'workflowId': workflow_id}
        
        async with self.session.get(url, headers=headers, params=params) as resp:
            return await resp.json()

if __name__ == "__main__":
    server = N8nMCPServer(
        n8n_host="https://your-n8n-instance.com",
        api_key="your-api-key"
    )
    asyncio.run(server.start())

4.3 실시간 데이터 동기화 구현

// n8n에서 실시간 MCP 연동을 위한 고급 설정
const mcpConfig = {
  transport: {
    type: "sse",
    url: "https://your-n8n-domain.com/mcp/stream"
  },
  authentication: {
    type: "bearer",
    token: process.env.MCP_BEARER_TOKEN
  },
  tools: [
    {
      name: "google_drive_sync",
      description: "실시간 Google Drive 파일 동기화",
      parameters: {
        type: "object",
        properties: {
          folder_id: { type: "string" },
          sync_mode: { type: "string", enum: ["realtime", "batch"] }
        }
      }
    }
  ]
};

5. 프로덕션 환경 최적화 및 보안

5.1 SSL/TLS 구성

# /etc/nginx/sites-available/n8n
server {
    listen 443 ssl http2;
    server_name your-domain.com;
    
    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
    
    # Security headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options DENY always;
    add_header X-Content-Type-Options nosniff always;
    
    location / {
        proxy_pass http://localhost:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

5.2 모니터링 및 로깅

# monitoring/docker-compose.yml
version: '3.8'

services:
  prometheus:
    image: prom/prometheus:latest
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
  
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin
    volumes:
      - grafana_data:/var/lib/grafana

volumes:
  grafana_data:

6. 실무 활용 사례: AI 기반 문서 처리 파이프라인

6.1 Google Drive + Claude AI 자동 요약 워크플로우

{
  "name": "AI Document Processing Pipeline",
  "nodes": [
    {
      "parameters": {
        "operation": "list",
        "folderId": "={{$json.folder_id}}",
        "options": {
          "fields": "files(id,name,mimeType,modifiedTime)"
        }
      },
      "name": "Google Drive List",
      "type": "n8n-nodes-base.googleDrive"
    },
    {
      "parameters": {
        "mode": "chooseBranch",
        "branches": [
          {
            "name": "Documents",
            "expression": "={{$json.mimeType.includes('document')}}"
          }
        ]
      },
      "name": "Filter Documents",
      "type": "n8n-nodes-base.if"
    },
    {
      "parameters": {
        "endpoint": "/mcp/document-analysis",
        "authentication": "bearerAuth",
        "requestBody": {
          "document_id": "={{$json.id}}",
          "analysis_type": "summary"
        }
      },
      "name": "MCP Document Analysis",
      "type": "n8n-nodes-base.mcpClient"
    }
  ]
}

6.2 성능 최적화 전략

# n8n 워커 스케일링 설정
export EXECUTIONS_MODE=queue
export QUEUE_BULL_REDIS_HOST=redis-cluster
export N8N_WORKERS=4
export N8N_WORKER_TIMEOUT=300

# 메모리 최적화
export NODE_OPTIONS="--max-old-space-size=4096"
export N8N_LOG_LEVEL=warn

결론: n8n과 MCP의 미래

2025년 현재, n8n은 단순한 워크플로우 자동화 도구를 넘어 AI-퍼스트 플랫폼으로 진화하고 있다. MCP 통합을 통해 Claude AI와의 네이티브 연동이 가능해지면서, 지능형 자동화의 새로운 패러다임이 열리고 있는 것이다.

이번 가이드에서 제시한 설치 및 구성 방법을 통해 엔터프라이즈급 n8n 환경을 구축하고, AI 기반 워크플로우 자동화의 혁신을 경험해보길 바란다. 특히 MCP 연동을 통한 Claude AI와의 협업은 업무 효율성을 새로운 차원으로 끌어올릴 것이다. 

개인적으로 n8n을 로컬 PC에 설치해서 배우려고 하는 경우에는 PostgreSQL, Redis를 빼고 설치해 보아도 괜찮다. 다만, n8n을 실제로 자동화 도구로 사용하려고 한다면, Docker를 설치한 후에 그 위에 n8n을 설치하는 것을 추천한다.

핵심 요약:

  • Docker 기반 설치로 안정성과 확장성 확보
  • PostgreSQL + Redis 조합으로 엔터프라이즈 성능 구현
  • 네이티브 MCP 노드를 통한 Claude AI 직접 연동
  • 프로덕션 레벨 보안 및 모니터링 구성
  • AI 기반 문서 처리 파이프라인 실무 활용

앞으로도 n8n과 MCP 생태계의 발전을 주시하며, 어떻게 내가 하고 있는 일에 접목할 수 있는지 계속 시도해 보길 바란다.

댓글 쓰기