A cross-platform demonstration of n8n workflow automation integrated with Model Context Protocol (MCP) using Docker containerization.
This repository contains a complete, production-ready demonstration of integrating n8n (workflow automation platform) with MCP (Model Context Protocol). The entire stack runs in Docker containers, ensuring consistent behavior across Windows and macOS environments.
- ✅ Cross-platform compatibility - Identical behavior on Windows and Mac
- ✅ Containerized deployment - Zero dependency installation required
- ✅ Pre-configured workflow - Ready-to-use n8n-MCP integration example
- ✅ Simulated MCP server - Demonstrates protocol integration patterns
- ✅ Production-ready architecture - Following infrastructure best practices
- ✅ Comprehensive documentation - Setup, troubleshooting, and architecture guides
┌─────────────────────────────────────────────────────────────┐
│ Docker Network │
│ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ │ │ │ │
│ │ n8n │◄──────HTTP────────►│ MCP Server │ │
│ │ (Port 5678)│ │ (Port 8080) │ │
│ │ │ │ │ │
│ └──────┬───────┘ └──────────────────┘ │
│ │ │
│ │ │
└─────────┼───────────────────────────────────────────────────┘
│
│ Webhook
▼
External Client
(curl, Postman, etc.)
- n8n Container: Workflow automation engine with pre-loaded MCP integration workflow
- MCP Server Container: FastAPI-based simulation of Model Context Protocol endpoints
- Docker Network: Private network enabling secure inter-container communication
- Persistent Volume: Stores n8n data, workflows, and configuration
- Docker Desktop 20.10+ (Windows | Mac)
- Git for cloning the repository
- 8GB RAM minimum (16GB recommended)
- Ports available: 5678 (n8n), 8080 (MCP server)
-
Clone the repository
git clone https://github.com/yourusername/n8n-mcp-demo.git cd n8n-mcp-demo -
Configure environment
cp .env.example .env # Edit .env to customize credentials (optional) -
Start the stack
docker-compose up -d
-
Verify services
docker-compose ps # Both containers should show "Up" status -
Access n8n and create owner account
- Open browser to http://localhost:5678
- On first run, create an owner account with:
- Email: [email protected]
- First/Last name: Your Name
- Password: (choose a secure password)
- Login with your created credentials
-
Import the workflow
- In n8n UI, click "Workflows" in left sidebar
- Click "+" or "Add Workflow"
- Click "⋮" (three dots) menu → "Import from file"
- Select
workflows/mcp-integration-demo.jsonfrom the project directory - The workflow will open in the editor
-
Activate the workflow
- Click "Activate" toggle in top right (should turn green/blue)
- Workflow is now ready to receive webhook requests
-
Test via Webhook
curl -X POST http://localhost:5678/webhook/mcp-demo \ -H "Content-Type: application/json" \ -d '{ "query": "What is the current context?", "user_id": "demo-user" }'
-
Expected Response
{ "success": true, "context": [ { "source": "knowledge_base", "content": "This is simulated context from MCP", "relevance": 0.95 } ], "action_result": { "success": true, "message": "Action process_context executed successfully" }, "timestamp": "2025-10-23T..." }
The demo workflow demonstrates:
- Webhook Trigger - Receives HTTP POST requests
- MCP Context Request - Fetches context from MCP server
- Context Validation - Checks if valid context was returned
- Action Execution - Processes context via MCP
- Response Formatting - Returns structured JSON response
| Variable | Default | Description |
|---|---|---|
N8N_BASIC_AUTH_USER |
admin | n8n login username |
N8N_BASIC_AUTH_PASSWORD |
admin | n8n login password |
N8N_HOST |
localhost | n8n host address |
MCP_SERVER_URL |
http://mcp-server:8080 | MCP server endpoint |
MCP_API_KEY |
demo-key | API key for MCP authentication |
GENERIC_TIMEZONE |
America/New_York | Timezone for n8n |
The MCP server is a simple FastAPI application embedded in the docker-compose.yml. To customize:
- Edit the Python code in
docker-compose.ymlundermcp-serverservice - Restart the containers:
docker-compose restart mcp-server
Supported endpoints:
GET /health- Health checkPOST /api/context- Retrieve context for a queryPOST /api/execute- Execute an action with parameters
Containers won't start
# Check port conflicts
docker-compose down
lsof -i :5678 # Mac
netstat -an | findstr 5678 # Windows
# Remove conflicting containers
docker-compose down -v
docker-compose up -dn8n shows "unauthorized"
- Verify credentials in
.envfile - Restart containers after changing
.env:docker-compose restart
MCP server connection fails
# Check MCP server logs
docker logs mcp-server-demo
# Test MCP server directly
curl http://localhost:8080/healthWorkflow won't activate
- Ensure both containers are running
- Check n8n logs:
docker logs n8n-mcp-demo - Verify MCP_SERVER_URL uses container name (
mcp-server), notlocalhost
Windows (WSL2)
- Ensure WSL2 is enabled and Docker Desktop uses WSL2 backend
- File paths in docker-compose use Unix-style slashes
- Run commands in PowerShell or WSL2 terminal
macOS
- Docker Desktop must be running before
docker-compose up - For M1/M2 Macs, containers use ARM64 architecture (fully supported)
- n8n container: ~200MB RAM, <5% CPU (idle)
- MCP server: ~100MB RAM, <2% CPU (idle)
- Total disk: ~500MB (including Docker images)
For production use:
- Replace simulated MCP server with actual MCP implementation
- Add reverse proxy (Nginx/Traefik) for HTTPS
- Configure external database (PostgreSQL) for n8n
- Implement proper secret management (HashiCorp Vault, AWS Secrets Manager)
- Add monitoring (Prometheus + Grafana)
n8n-mcp-demo/
├── .github/
│ └── workflows/ # CI/CD pipelines (optional)
├── config/ # n8n configuration files
├── docs/
│ ├── ARCHITECTURE.md # Detailed architecture documentation
│ ├── PRESENTATION.md # Technical presentation slides
│ └── TROUBLESHOOTING.md # Extended troubleshooting guide
├── workflows/
│ └── mcp-integration-demo.json # Pre-configured workflow
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── docker-compose.yml # Docker orchestration config
├── LICENSE # MIT License
└── README.md # This file
⚠️ Change default credentials before production deployment⚠️ Use HTTPS in production (not HTTP)⚠️ Rotate API keys regularly⚠️ Network isolation - MCP server not exposed to public internet⚠️ Volume permissions - Ensure proper file ownership in Docker volumes
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
- n8n - Workflow automation platform
- FastAPI - MCP server framework
- Docker - Containerization platform
- Documentation: See
/docsfolder - Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ for Platform Engineers