# 远程部署和 Manus 注册快速指南
本文档提供 MCP Hello World 服务器远程部署和注册到 Manus 平台的详细步骤。
## 快速开始
### 1. 本地测试
首先在本地测试 HTTP 服务器:
```bash
# 安装依赖
pip install -r requirements.txt
# 启动服务器
python mcp_server_http.py
```
访问 `http://localhost:8000/health` 验证服务器正常运行。
### 2. Docker 部署
#### 方法A: 使用 Docker Compose(推荐)
```bash
docker-compose up -d
```
#### 方法B: 使用 Docker 命令
```bash
# 构建镜像
docker build -t hello-world-mcp:latest .
# 运行容器
docker run -d \
--name hello-world-mcp \
-p 8000:8000 \
--restart unless-stopped \
hello-world-mcp:latest
```
### 3. 配置 HTTPS(必需)
Manus 要求服务器使用 HTTPS。使用 Nginx + Let's Encrypt:
```bash
# 安装 Nginx 和 Certbot
sudo apt update
sudo apt install nginx certbot python3-certbot-nginx
# 配置 Nginx
sudo nano /etc/nginx/sites-available/mcp-server
```
Nginx 配置:
```nginx
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:8000;
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;
}
}
```
启用配置并获取 SSL 证书:
```bash
sudo ln -s /etc/nginx/sites-available/mcp-server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo certbot --nginx -d your-domain.com
```
### 4. 在 Manus 上注册
1. 登录 Manus 控制台
2. 进入"设置" > "集成"
3. 点击"自定义 MCP 服务器" > "添加服务器"
4. 填写信息:
- **名称**: Hello World MCP
- **URL**: `https://your-domain.com/mcp`
- **认证**: 根据你的服务器配置选择
5. 点击"测试连接"
6. 确认工具列表后点击"保存"
## 验证部署
### 健康检查
```bash
curl https://your-domain.com/health
```
应该返回:
```json
{"status": "healthy", "service": "hello-world-mcp"}
```
### 工具列表
```bash
curl https://your-domain.com/tools
```
### 测试 MCP 协议
```bash
curl -X POST https://your-domain.com/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'
```
## 环境变量配置
可以通过环境变量配置服务器:
```bash
export HOST=0.0.0.0
export PORT=8000
python mcp_server_http.py
```
或在 Docker 中:
```yaml
environment:
- HOST=0.0.0.0
- PORT=8000
```
## 安全建议
1. **启用防火墙**:
```bash
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
```
2. **添加 API 认证**(可选):
修改 `mcp_server_http.py` 添加 API 密钥验证
3. **设置速率限制**:
在 Nginx 中配置速率限制
4. **监控日志**:
```bash
# 查看容器日志
docker logs -f hello-world-mcp
# 查看系统日志
journalctl -u nginx -f
```
## 常见问题
### Q: Manus 提示连接失败
A: 检查:
1. 服务器是否正常运行
2. HTTPS 证书是否有效
3. 防火墙是否开放端口
4. Nginx 配置是否正确
### Q: 工具列表为空
A: 检查:
1. `/tools` 端点是否正常
2. MCP 协议响应格式是否正确
3. 查看服务器错误日志
### Q: SSL 证书续期
A: Certbot 会自动续期,你也可以手动测试:
```bash
sudo certbot renew --dry-run
```
## 下一步
- 阅读 [README.md](README.md) 了解完整功能
- 查看代码注释了解实现细节
- 根据需要自定义工具和约束