|
| 1 | +# Cloud Deployment Guide |
| 2 | + |
| 3 | +All servers in this repository are containerized and can be deployed to cloud platforms for scalable, production-ready deployments. The servers support HTTP transport mode specifically designed for cloud deployments. |
| 4 | + |
| 5 | +## AWS ECS Fargate Deployment |
| 6 | + |
| 7 | +Amazon ECS Fargate provides serverless container hosting ideal for MCP servers. Below are generic instructions applicable to all servers in this repository. |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +1. AWS CLI configured with appropriate permissions |
| 12 | +2. An existing ECS cluster or create one using AWS Console/CLI |
| 13 | +3. Docker image pushed to Amazon ECR (Elastic Container Registry) |
| 14 | + |
| 15 | +### Step 1: Build and Push Docker Image |
| 16 | + |
| 17 | +```bash |
| 18 | +# Navigate to your chosen server directory |
| 19 | +cd servers/mcp-neo4j-cypher # or any other server |
| 20 | + |
| 21 | +# Build the Docker image |
| 22 | +docker build -t mcp-neo4j-server . |
| 23 | + |
| 24 | +# Tag for ECR (replace with your region and account ID) |
| 25 | +docker tag mcp-neo4j-server:latest 123456789012.dkr.ecr.us-east-1.amazonaws.com/mcp-neo4j-server:latest |
| 26 | + |
| 27 | +# Login to ECR |
| 28 | +aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com |
| 29 | + |
| 30 | +# Push to ECR |
| 31 | +docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/mcp-neo4j-server:latest |
| 32 | +``` |
| 33 | + |
| 34 | +### Step 2: Create ECS Task Definition |
| 35 | + |
| 36 | +Create a task definition JSON file (`task-definition.json`): |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "family": "mcp-neo4j-server", |
| 41 | + "networkMode": "awsvpc", |
| 42 | + "requiresCompatibilities": ["FARGATE"], |
| 43 | + "cpu": "256", |
| 44 | + "memory": "512", |
| 45 | + "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", |
| 46 | + "containerDefinitions": [ |
| 47 | + { |
| 48 | + "name": "mcp-neo4j-server", |
| 49 | + "image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/mcp-neo4j-server:latest", |
| 50 | + "portMappings": [ |
| 51 | + { |
| 52 | + "containerPort": 8000, |
| 53 | + "protocol": "tcp" |
| 54 | + } |
| 55 | + ], |
| 56 | + "environment": [ |
| 57 | + { |
| 58 | + "name": "NEO4J_TRANSPORT", |
| 59 | + "value": "http" |
| 60 | + }, |
| 61 | + { |
| 62 | + "name": "NEO4J_MCP_SERVER_HOST", |
| 63 | + "value": "0.0.0.0" |
| 64 | + }, |
| 65 | + { |
| 66 | + "name": "NEO4J_MCP_SERVER_PORT", |
| 67 | + "value": "8000" |
| 68 | + } |
| 69 | + ], |
| 70 | + "secrets": [ |
| 71 | + { |
| 72 | + "name": "NEO4J_PASSWORD", |
| 73 | + "valueFrom": "arn:aws:secretsmanager:us-east-1:123456789012:secret:neo4j-password-AbCdEf" |
| 74 | + } |
| 75 | + ], |
| 76 | + "logConfiguration": { |
| 77 | + "logDriver": "awslogs", |
| 78 | + "options": { |
| 79 | + "awslogs-group": "/ecs/mcp-neo4j-server", |
| 80 | + "awslogs-region": "us-east-1", |
| 81 | + "awslogs-stream-prefix": "ecs" |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + ] |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +### Step 3: Create ECS Service with Load Balancer |
| 90 | + |
| 91 | +```bash |
| 92 | +# Register the task definition |
| 93 | +aws ecs register-task-definition --cli-input-json file://task-definition.json |
| 94 | + |
| 95 | +# Create an Application Load Balancer (ALB) through AWS Console or CLI |
| 96 | +# Create target group for port 8000 |
| 97 | + |
| 98 | +# Create the ECS service |
| 99 | +aws ecs create-service \ |
| 100 | + --cluster your-ecs-cluster \ |
| 101 | + --service-name mcp-neo4j-service \ |
| 102 | + --task-definition mcp-neo4j-server:1 \ |
| 103 | + --desired-count 2 \ |
| 104 | + --launch-type FARGATE \ |
| 105 | + --network-configuration "awsvpcConfiguration={subnets=[subnet-12345,subnet-67890],securityGroups=[sg-12345678],assignPublicIp=ENABLED}" \ |
| 106 | + --load-balancers targetGroupArn=arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/mcp-targets/1234567890123456,containerName=mcp-neo4j-server,containerPort=8000 |
| 107 | +``` |
| 108 | + |
| 109 | +### Step 4: Configure Auto Scaling |
| 110 | + |
| 111 | +```bash |
| 112 | +# Register scalable target |
| 113 | +aws application-autoscaling register-scalable-target \ |
| 114 | + --service-namespace ecs \ |
| 115 | + --scalable-dimension ecs:service:DesiredCount \ |
| 116 | + --resource-id service/your-ecs-cluster/mcp-neo4j-service \ |
| 117 | + --min-capacity 1 \ |
| 118 | + --max-capacity 10 |
| 119 | + |
| 120 | +# Create scaling policy |
| 121 | +aws application-autoscaling put-scaling-policy \ |
| 122 | + --service-namespace ecs \ |
| 123 | + --scalable-dimension ecs:service:DesiredCount \ |
| 124 | + --resource-id service/your-ecs-cluster/mcp-neo4j-service \ |
| 125 | + --policy-name mcp-neo4j-scaling-policy \ |
| 126 | + --policy-type TargetTrackingScaling \ |
| 127 | + --target-tracking-scaling-policy-configuration file://scaling-policy.json |
| 128 | +``` |
| 129 | + |
| 130 | +Where `scaling-policy.json`: |
| 131 | + |
| 132 | +```json |
| 133 | +{ |
| 134 | + "TargetValue": 70.0, |
| 135 | + "PredefinedMetricSpecification": { |
| 136 | + "PredefinedMetricType": "ECSServiceAverageCPUUtilization" |
| 137 | + }, |
| 138 | + "ScaleOutCooldown": 300, |
| 139 | + "ScaleInCooldown": 300 |
| 140 | +} |
| 141 | +``` |
| 142 | + |
| 143 | +## Azure Container Apps Deployment |
| 144 | + |
| 145 | +Azure Container Apps provides a serverless container platform perfect for MCP server deployments with built-in scaling and load balancing. |
| 146 | + |
| 147 | +### Prerequisites |
| 148 | + |
| 149 | +1. Azure CLI installed and logged in |
| 150 | +2. Resource group and Container Apps environment |
| 151 | +3. Container image pushed to Azure Container Registry (ACR) |
| 152 | + |
| 153 | +### Step 1: Build and Push Docker Image |
| 154 | + |
| 155 | +```bash |
| 156 | +# Navigate to your chosen server directory |
| 157 | +cd servers/mcp-neo4j-memory # or any other server |
| 158 | + |
| 159 | +# Build the Docker image |
| 160 | +docker build -t mcp-neo4j-server . |
| 161 | + |
| 162 | +# Create Azure Container Registry (if not exists) |
| 163 | +az acr create --resource-group myResourceGroup --name myacrregistry --sku Basic |
| 164 | + |
| 165 | +# Login to ACR |
| 166 | +az acr login --name myacrregistry |
| 167 | + |
| 168 | +# Tag and push image |
| 169 | +docker tag mcp-neo4j-server:latest myacrregistry.azurecr.io/mcp-neo4j-server:latest |
| 170 | +docker push myacrregistry.azurecr.io/mcp-neo4j-server:latest |
| 171 | +``` |
| 172 | + |
| 173 | +### Step 2: Create Container Apps Environment |
| 174 | + |
| 175 | +```bash |
| 176 | +# Install the Container Apps extension |
| 177 | +az extension add --name containerapp |
| 178 | + |
| 179 | +# Create resource group |
| 180 | +az group create --name myResourceGroup --location eastus |
| 181 | + |
| 182 | +# Create Container Apps environment |
| 183 | +az containerapp env create \ |
| 184 | + --name myenvironment \ |
| 185 | + --resource-group myResourceGroup \ |
| 186 | + --location eastus |
| 187 | +``` |
| 188 | + |
| 189 | +### Step 3: Deploy Container App |
| 190 | + |
| 191 | +```bash |
| 192 | +# Create the container app |
| 193 | +az containerapp create \ |
| 194 | + --name mcp-neo4j-app \ |
| 195 | + --resource-group myResourceGroup \ |
| 196 | + --environment myenvironment \ |
| 197 | + --image myacrregistry.azurecr.io/mcp-neo4j-server:latest \ |
| 198 | + --target-port 8000 \ |
| 199 | + --ingress external \ |
| 200 | + --min-replicas 1 \ |
| 201 | + --max-replicas 10 \ |
| 202 | + --cpu 0.25 \ |
| 203 | + --memory 0.5Gi \ |
| 204 | + --secrets \ |
| 205 | + neo4j-password=your-secret-password \ |
| 206 | + --env-vars \ |
| 207 | + NEO4J_TRANSPORT=http \ |
| 208 | + NEO4J_MCP_SERVER_HOST=0.0.0.0 \ |
| 209 | + NEO4J_MCP_SERVER_PORT=8000 \ |
| 210 | + NEO4J_URI=bolt://your-neo4j-instance:7687 \ |
| 211 | + NEO4J_USERNAME=neo4j \ |
| 212 | + NEO4J_PASSWORD=secretref:neo4j-password |
| 213 | +``` |
| 214 | + |
| 215 | +### Step 4: Configure Auto Scaling Rules |
| 216 | + |
| 217 | +```bash |
| 218 | +# Create HTTP scaling rule |
| 219 | +az containerapp revision set-scaling-rule \ |
| 220 | + --name mcp-neo4j-app \ |
| 221 | + --resource-group myResourceGroup \ |
| 222 | + --rule-name http-rule \ |
| 223 | + --rule-type http \ |
| 224 | + --http-concurrent-requests 10 |
| 225 | + |
| 226 | +# Create CPU scaling rule |
| 227 | +az containerapp revision set-scaling-rule \ |
| 228 | + --name mcp-neo4j-app \ |
| 229 | + --resource-group myResourceGroup \ |
| 230 | + --rule-name cpu-rule \ |
| 231 | + --rule-type cpu \ |
| 232 | + --cpu-utilization 70 |
| 233 | +``` |
| 234 | + |
| 235 | +### Step 5: Configure Load Balancing and Traffic Distribution |
| 236 | + |
| 237 | +```bash |
| 238 | +# Create additional revision for blue-green deployment |
| 239 | +az containerapp revision copy \ |
| 240 | + --name mcp-neo4j-app \ |
| 241 | + --resource-group myResourceGroup \ |
| 242 | + --from-revision mcp-neo4j-app--abc123 \ |
| 243 | + --image myacrregistry.azurecr.io/mcp-neo4j-server:v2 |
| 244 | + |
| 245 | +# Configure traffic splitting |
| 246 | +az containerapp ingress traffic set \ |
| 247 | + --name mcp-neo4j-app \ |
| 248 | + --resource-group myResourceGroup \ |
| 249 | + --revision-weight mcp-neo4j-app--abc123=50 mcp-neo4j-app--def456=50 |
| 250 | +``` |
| 251 | + |
| 252 | +## Configuration Best Practices |
| 253 | + |
| 254 | +### Environment Variables for Cloud Deployment |
| 255 | + |
| 256 | +All servers support these common environment variables for cloud deployment: |
| 257 | + |
| 258 | +| Variable | Description | Default | |
| 259 | +|----------|-------------|---------| |
| 260 | +| `NEO4J_TRANSPORT` | Set to `http` for cloud deployments | `stdio` | |
| 261 | +| `NEO4J_MCP_SERVER_HOST` | Bind address (use `0.0.0.0` for containers) | `127.0.0.1` | |
| 262 | +| `NEO4J_MCP_SERVER_PORT` | Port for HTTP server | `8000` | |
| 263 | +| `NEO4J_MCP_SERVER_PATH` | URL path for MCP endpoint | `/api/mcp/` | |
| 264 | +| `NEO4J_MCP_SERVER_ALLOWED_HOSTS` | Comma-separated allowed hosts | `localhost,127.0.0.1` | |
| 265 | +| `NEO4J_MCP_SERVER_ALLOW_ORIGINS` | CORS allowed origins | (empty - secure by default) | |
| 266 | + |
| 267 | +### Security Configuration |
| 268 | + |
| 269 | +For production deployments, configure security settings: |
| 270 | + |
| 271 | +```bash |
| 272 | +# Environment variables for security |
| 273 | +NEO4J_MCP_SERVER_ALLOWED_HOSTS="yourdomain.com,www.yourdomain.com" |
| 274 | +NEO4J_MCP_SERVER_ALLOW_ORIGINS="https://yourdomain.com,https://app.yourdomain.com" |
| 275 | +``` |
| 276 | + |
| 277 | +### Health Checks |
| 278 | + |
| 279 | +Configure health checks in your container orchestration platform: |
| 280 | + |
| 281 | +- **Health Check Endpoint**: `GET /health` (if available) or `GET /api/mcp/` |
| 282 | +- **Port**: `8000` |
| 283 | +- **Protocol**: `HTTP` |
| 284 | + |
| 285 | +### Resource Recommendations |
| 286 | + |
| 287 | +Based on server type and expected load: |
| 288 | + |
| 289 | +- **CPU**: 0.25-0.5 vCPU per instance (scale up for heavy workloads) |
| 290 | +- **Memory**: 512MB-1GB per instance |
| 291 | +- **Replicas**: Start with 2 for high availability, scale based on traffic |
| 292 | + |
| 293 | +### Monitoring and Logging |
| 294 | + |
| 295 | +- Enable container logs aggregation (CloudWatch Logs, Azure Monitor) |
| 296 | +- Set up application performance monitoring |
| 297 | +- Monitor HTTP response times and error rates |
| 298 | +- Track container resource utilization |
| 299 | + |
| 300 | +## Integration with MCP Clients |
| 301 | + |
| 302 | +After deploying to cloud platforms, integrate with MCP clients using HTTP endpoints: |
| 303 | + |
| 304 | +```json |
| 305 | +{ |
| 306 | + "mcpServers": { |
| 307 | + "neo4j-cloud": { |
| 308 | + "command": "npx", |
| 309 | + "args": ["-y", "mcp-remote@latest", "https://your-deployment-url/api/mcp/"] |
| 310 | + } |
| 311 | + } |
| 312 | +} |
| 313 | +``` |
| 314 | + |
| 315 | +This approach allows Claude Desktop and other MCP clients to connect to your cloud-deployed servers through HTTP proxy tools like `mcp-remote`. |
| 316 | + |
| 317 | +## Troubleshooting |
| 318 | + |
| 319 | +### Common Issues |
| 320 | + |
| 321 | +1. **Container not starting**: Check environment variables and secrets configuration |
| 322 | +2. **Health check failures**: Verify the container is listening on the correct port (8000) and host (0.0.0.0) |
| 323 | +3. **Connection timeouts**: Ensure security groups/firewall rules allow traffic on port 8000 |
| 324 | +4. **CORS errors**: Configure `NEO4J_MCP_SERVER_ALLOW_ORIGINS` for your client domains |
| 325 | +5. **Auto-scaling not working**: Verify scaling policies and metrics are properly configured |
| 326 | + |
| 327 | +### Logging and Debugging |
| 328 | + |
| 329 | +Enable debug logging by setting environment variables: |
| 330 | + |
| 331 | +```bash |
| 332 | +LOG_LEVEL=DEBUG |
| 333 | +NEO4J_MCP_DEBUG=true |
| 334 | +``` |
| 335 | + |
| 336 | +Monitor container logs through your cloud platform's logging service to troubleshoot deployment issues. |
0 commit comments