Docker MCP网关+n8n部署包
在无头Ubuntu服务器(Hostinger VPS)上使用n8n MCP运行Docker MCP网关的完整部署包。
📋 包含什么
此包包含部署所需的一切:
- Docker MCP网关 -集中式MCP服务器编排
- n8n MCP服务器 -工作流程文档和管理(39个工具)
- n8n实例 -您现有的工作流自动化平台
- 12台MCP服务器 -您当前配置的所有MCP工具
- 卡迪 -自动HTTPS反向代理
- 波特纳 -可选的基于web的Docker管理
🎯 您的用例
监控和自动化代理 这可以:
- 监控您的网站和Supabase数据库
- 自动检测问题
- 阅读谷歌表格和Supabase
- 通过AI分析提出解决方案
- 执行修复(确认)
- 发送通知
- 创建/修改n8n工作流
- 运行自动迁移
📁 文件结构
deployment/
├── README.md # This file
├── docker-compose.yml # Main deployment configuration
├── Caddyfile # HTTPS reverse proxy config
├── .env.example # Environment variables template
├── deploy.sh # Automated deployment script
├── GEMINI_CLI_SETUP.md # AI CLI integration guide
├── AUTOMATION_WORKFLOWS.md # Example workflows (coming)
├── DEPLOYMENT_GUIDE.md # Step-by-step walkthrough (below)
└── mcp-config/
├── catalog.yaml # Your 12 MCP servers configuration
└── registry.yaml # Enabled servers tracking🚀 快速入门(5分钟)
先决条件
- Hostinger VPS与Ubuntu 24.04(2 CPU,8GB RAM,100GB磁盘)
- 指向您的VPS IP的域名
- SSH访问服务器
- 已安装Docker(如果缺少脚本,将安装)
步骤1:将文件上传到服务器
# On your local machine
cd /Users/md6597mac.com/docker_mcp_project/deployment
# Upload to server (replace with your details)
scp -r * user@your-vps-ip:~/docker-mcp/
# SSH into server
ssh user@your-vps-ip
cd ~/docker-mcp步骤2:配置环境
# Copy example environment file
cp .env.example .env
# Edit with your values
nano .env
# Required values:
# - DOMAIN: your-domain.com
# - N8N_USER: admin (or your choice)
# - N8N_PASSWORD: strong-password-here
# - N8N_MCP_AUTH_TOKEN: (generate with: openssl rand -hex 32)
# - N8N_API_KEY: (get from n8n after first login)生成安全令牌:
# Auth token (save this!)
openssl rand -hex 32
# Or use this one-liner to set it in .env
echo "N8N_MCP_AUTH_TOKEN=$(openssl rand -hex 32)" >> .env步骤3:使用Hostinger Docker Manager进行部署
选项A:使用Hostinger Docker Manager UI
- 登录您的Hostinger VPS面板
- 导航到Docker管理器
- 点击“导入项目”
- 指向您的
docker-compose.yml位置:~/docker-mcp/docker-compose.yml - Docker Manager将检测并部署所有服务
选项B:使用CLI
# Start services
docker compose up -d
# View logs
docker compose logs -f
# Check status
docker compose ps步骤4:等待服务启动
# Monitor startup (takes 30-60 seconds)
watch docker compose ps
# Check health
curl http://localhost:5678/healthz # n8n
curl http://localhost:3000/health # n8n-MCP
curl http://localhost:8811/health # MCP Gateway步骤5:访问和配置n8n
- 访问n8n用户界面:
https://your-domain.com
- 用户名:(来自.env N8N_USER) - 密码:(来自.env N8N_Password)
- 生成n8n API密钥:
- 前往设置→ API - 单击“创建API密钥” - 复制密钥
- 使用API密钥更新.env:
nano .env
# Add: N8N_API_KEY=n8n_api_xxxxxxxxx
# Restart to apply
docker compose up -d步骤6:测试MCP连接
从笔记本电脑进行测试:
# Test MCP Gateway
curl https://mcp.your-domain.com/health
# Test n8n-MCP
curl https://n8n-mcp.your-domain.com/health
# List n8n-MCP tools (requires auth)
curl -X POST https://n8n-mcp.your-domain.com/mcp \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'🎨 架构概述
┌─────────────────────────────────────────────────────────────┐
│ Internet │
│ ├─ https://your-domain.com → n8n UI │
│ ├─ https://mcp.your-domain.com → MCP Gateway (SSE) │
│ └─ https://n8n-mcp.your-domain.com/mcp → n8n-MCP Server │
└─────────────────────────┬───────────────────────────────────┘
│ (Caddy - Auto HTTPS)
┌─────────────────────────┴───────────────────────────────────┐
│ Docker Network (172.28.0.0/16) │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ MCP Gateway Container (Port 8811) │ │
│ │ ├─ context7 (code docs) │ │
│ │ ├─ desktop-commander (system ops) │ │
│ │ ├─ duckduckgo (web search) │ │
│ │ ├─ github-official (GitHub ops) │ │
│ │ ├─ markdownify (web to markdown) │ │
│ │ ├─ memory (persistent memory) │ │
│ │ ├─ next-devtools (Next.js tools) │ │
│ │ ├─ playwright (browser automation) │ │
│ │ ├─ puppeteer (browser automation) │ │
│ │ ├─ sequentialthinking (chain-of-thought) │ │
│ │ ├─ supabase (database ops) │ │
│ │ └─ youtube_transcript (video transcripts) │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ n8n-MCP Container (Port 3000) │ │
│ │ - 23 documentation tools │ │
│ │ - 16 workflow management tools │ │
│ │ - Connected to n8n API │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ n8n Container (Port 5678) │ │
│ │ - Workflow automation │ │
│ │ - MCP Client Tool node │ │
│ │ - AI Agent nodes │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Caddy Container (Ports 80, 443) │ │
│ │ - Automatic HTTPS (Let's Encrypt) │ │
│ │ - Reverse proxy for all services │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘🔧 配置详情
您的12台MCP服务器
所有配置均基于您的本地 ~/.docker/mcp/registry.yaml:
- 上下文7 -代码文档(React、Next.js、Vue等)
- 桌面指挥官 -系统操作
- 鸭鸭走 -网络搜索
- github官方 -GitHub API操作
- 标记化 -将web内容转换为markdown
- 记忆 -跨会话的持久上下文
- 下一个devtools mcp -Next.js开发工具
- 剧作家 -浏览器自动化(E2E测试)
- 操纵者 -浏览器自动化(替代方案)
- 顺序思维 -思维链推理
- Supabase -您的Supabase数据库操作
- youtube_transcript -视频记录
n8n MCP服务器(39个工具)
文档工具(23):
list_nodes-列出所有n8n节点search_nodes-按关键字搜索get_node_info-详细节点信息get_node_essentials-基本属性validate_workflow-验证配置- 还有18个。..
工作流管理工具(16) -需要N8N_API_KEY:
n8n_create_workflow-创建工作流n8n_update_workflow-更新工作流n8n_get_workflow-检索工作流详细信息n8n_list_workflows-列出所有工作流n8n_trigger_webhook_workflow-执行工作流- 还有11个。..
🔐 安全配置
防火墙(自动)
# Ports opened by deployment:
# - 80/tcp (HTTP - redirects to HTTPS)
# - 443/tcp (HTTPS - all services)
# - 22/tcp (SSH - for management)
# All other ports blocked
# MCP Gateway (8811), n8n (5678), n8n-MCP (3000) only accessible via Caddy身份验证层
- MCP网关 -SSE传输(未来:添加身份验证)
- n8n MCP -承载令牌身份验证
- n8n用户界面 -基本身份验证(用户名/密码)
- n8n API -API密钥验证
速率限制
在docker-compose.yml中为n8n MCP配置:
- 每个IP每15分钟50个请求
- 防止暴力攻击
SSRF保护
为n8n MCP配置:
WEBHOOK_SECURITY_MODE=moderate-允许本地主机n8n,阻止外部私有IP- 云元数据端点始终被阻止
📊 资源使用情况
预计资源消耗:
| 服务 | CPU | RAM | 磁盘 |
|---|---|---|---|
| MCP网关 | 0.5-1.5核 | 512MB-2GB | ~500MB |
| n8n MCP | 0.2-0.5芯 | 256MB-512MB | ~30MB |
| n8n | 0.5-1.5核 | 1GB-3GB | ~2GB+数据 |
| 球童 | 0.1-0.25芯 | 128MB-256MB | ~50MB |
| 总计 | ~2芯 | ~4-6GB | 约3GB+数据 |
你的VPS(2核,8GB RAM)非常适合这个!
🔍 监控与管理
Docker编写命令
# View logs
docker compose logs -f # All services
docker compose logs -f mcp-gateway # Specific service
docker compose logs --tail 100 n8n # Last 100 lines
# Check status
docker compose ps
docker compose ps --all
# Restart service
docker compose restart n8n-mcp
# Stop all
docker compose down
# Stop and remove volumes (careful!)
docker compose down -v
# Update images and restart
docker compose pull
docker compose up -d
# View resource usage
docker stats门户(Web UI)
访问地址: https://portainer.your-domain.com
特征:
- 可视化容器管理
- 实时日志
- 资源使用图
- 控制台访问容器
- 快速重启/停止/启动
健康检查
# Check all services
curl https://your-domain.com/healthz
curl https://mcp.your-domain.com/health
curl https://n8n-mcp.your-domain.com/health
# Detailed health info
curl https://n8n-mcp.your-domain.com/health | jq
# Shows: status, uptime, memory, version, features🚨 故障排除
问题:服务无法启动
# Check logs for errors
docker compose logs
# Common causes:
# 1. Port already in use
sudo netstat -tlnp | grep :80
sudo netstat -tlnp | grep :443
# 2. Insufficient memory
free -h
# 3. Docker daemon not running
sudo systemctl status docker
sudo systemctl start docker问题:无法通过域访问
# Check DNS
nslookup your-domain.com
nslookup mcp.your-domain.com
# Check Caddy logs
docker compose logs caddy
# Check if ports are open
sudo ufw status
# Test locally first
curl http://localhost:5678/healthz问题:MCP工具不工作
# Check MCP Gateway logs
docker compose logs mcp-gateway
# List running MCP containers
docker ps | grep mcp/
# Test tool directly
docker exec mcp-gateway docker mcp server ls
# Check network connectivity
docker network inspect docker-mcp_mcp-network问题:n8n MCP身份验证失败
# Check auth token length
echo $N8N_MCP_AUTH_TOKEN | wc -c # Should be 64
# Verify both tokens match in .env
grep AUTH_TOKEN .env
# Test authentication
curl -X POST http://localhost:3000/mcp \
-H "Authorization: Bearer $N8N_MCP_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'📚 后续步骤
- ✅ 部署服务(你在这里!)
- 📝 使用您的凭据配置Supabase MCP
- 🤖 设置Gemini CLI以进行远程访问(请参阅Gemini_CLI_SETUP.md)
- 🔄 在n8n中创建监控工作流
- 📊 构建自动化代理(请参阅automation_WORKFLOWS.md)
- 🚀 测试端到端监控和修复流程
📖 附加指南
- 双子座_CLI_SETUP.md -将AI CLI工具连接到远程MCP网关
- 自动化_工作流.md -监控和自动化工作流程示例
- 本地客户端设置 -在笔记本电脑上配置Claude Desktop
🆘 获取帮助
- 检查日志:
docker compose logs -f - 门户用户界面:
https://portainer.your-domain.com - n8n社区: https://community.n8n.io
- Docker MCP问题: https://github.com/docker/mcp-gateway/issues
📝 维护
常规任务
# Update all images (monthly)
cd ~/docker-mcp
docker compose pull
docker compose up -d
# Check disk usage
docker system df
# Clean up old images
docker system prune -a
# Backup n8n data
docker run --rm \
-v docker-mcp_n8n-data:/source:ro \
-v $(pwd):/backup \
alpine tar czf /backup/n8n-backup-$(date +%Y%m%d).tar.gz -C /source .
# Backup .env file
cp .env .env.backup更新配置
# Edit docker-compose.yml or .env
nano docker-compose.yml
# Apply changes
docker compose up -d
# Watch logs for errors
docker compose logs -f🎉 成功!
现在,您已经拥有了一个完整的、可用于生产的MCP网关部署,其中包括:
- ✅ 12台可远程访问的MCP服务器
- ✅ 用于工作流管理的n8n MCP(39个工具)
- ✅ n8n用于自动化工作流程
- ✅ 自动HTTPS
- ✅ 容器管理UI(Portainer)
- ✅ 为AI代理集成做好准备
您的监控和自动化代理现在可以:
- 检查Supabase是否有错误
- 监控您的网站
- 阅读谷歌表格数据
- 提出并执行修复
- 创建n8n工作流
- 发送通知
下一步:关注GEMINI_CLI_SETUP.md连接您的AI代理! 🚀
