RENDER_DEPLOYMENT_GUIDE.md•6.45 kB
# 🚀 **RENDER DEPLOYMENT GUIDE - Charnoks MCP Server**
## **Why Render is Perfect for Your MCP Server**
### ✅ **Render Advantages:**
- **Free Tier**: $0/month for hobby projects (with 750 hours/month limit)
- **Paid Tier**: $7/month for production (unlimited hours)
- **Auto-scaling**: Automatic traffic handling
- **Zero configuration**: Git-based deployment
- **Built-in SSL**: Automatic HTTPS certificates
- **Health checks**: Built-in monitoring
- **Easier than Heroku**: No CLI installation needed
---
## 🚀 **IMMEDIATE DEPLOYMENT STEPS**
### **Step 1: Prepare Your Repository**
Your MCP server is already Render-ready! No changes needed:
- ✅ `package.json` with proper scripts
- ✅ Express.js server on configurable PORT
- ✅ Environment variable support
- ✅ Health check endpoint (`/health`)
- ✅ Production-optimized build process
### **Step 2: Deploy to Render**
1. **Go to Render Dashboard**: https://render.com
2. **Connect GitHub**: Link your `mcp-server` repository
3. **Create Web Service**:
- **Repository**: `DeltaRhoSygnis/mcp-server`
- **Branch**: `main`
- **Region**: Choose closest to your users
- **Runtime**: `Node`
- **Build Command**: `npm run build`
- **Start Command**: `npm start`
### **Step 3: Configure Environment Variables in Render**
In the Render dashboard, add these environment variables:
```bash
# Required Variables
NODE_ENV=production
PORT=10000
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here
# AI Configuration
GEMINI_API_KEY=your_gemini_api_key_here
# Security (generate these)
JWT_SECRET=your_32_character_secret_here
MCP_AUTH_TOKEN=your_16_character_token_here
# Performance
MAX_REQUESTS_PER_MINUTE=200
# CORS (add your frontend domains)
ALLOWED_ORIGINS=https://charnoksv3.vercel.app,http://localhost:3000,http://localhost:5173
```
### **Step 4: Deploy & Verify**
1. **Deploy**: Click "Create Web Service" - Render will automatically build and deploy
2. **Get URL**: Your service will be available at `https://your-app-name.onrender.com`
3. **Test Health**: Visit `https://your-app-name.onrender.com/health`
4. **Check Logs**: Monitor deployment in Render dashboard
---
## 🔧 **RENDER-SPECIFIC OPTIMIZATIONS**
### **Auto-Deploy Configuration**
```yaml
# render.yaml (optional - Render auto-detects your setup)
services:
- type: web
name: charnoks-mcp-server
env: node
buildCommand: npm run build
startCommand: npm start
envVars:
- key: NODE_ENV
value: production
- key: PORT
fromService:
type: web
name: charnoks-mcp-server
property: port
```
### **Health Check Optimization**
Your existing health check is perfect:
```typescript
// Already in your src/index.ts
this.app.get('/health', async (req, res) => {
// Comprehensive health check with Gemini & Supabase status
res.status(200).json({
status: 'healthy',
timestamp: new Date().toISOString(),
version: '2.0.0',
uptime: process.uptime()
});
});
```
### **Performance Settings**
```bash
# Render automatically handles:
# ✅ Load balancing
# ✅ SSL certificates
# ✅ CDN integration
# ✅ Health monitoring
# ✅ Auto-restart on failures
```
---
## 🌐 **POST-DEPLOYMENT INTEGRATION**
### **Update Your Frontend Environment**
In your `Charnoksv3` repository, update environment variables:
```env
# .env.local or .env.production
VITE_MCP_SERVER_URL=https://your-app-name.onrender.com
VITE_MCP_AUTH_TOKEN=your_mcp_auth_token_here
```
### **WebSocket Connection**
```javascript
// Update WebSocket URLs
const wsUrl = process.env.NODE_ENV === 'production'
? 'wss://your-app-name.onrender.com/ws/chat'
: 'ws://localhost:3002/ws/chat';
const ws = new WebSocket(wsUrl);
```
---
## 📊 **COST COMPARISON**
### **Render Pricing:**
- **Free Tier**: $0/month - 750 hours, perfect for development
- **Starter**: $7/month - Unlimited hours, 0.5 CPU, 512MB RAM
- **Standard**: $25/month - 1 CPU, 2GB RAM, ideal for production
- **Pro**: $85/month - 2 CPU, 4GB RAM, high performance
### **vs Heroku:**
- **Heroku Hobby**: $7/month - Similar to Render Starter
- **Heroku Standard**: $25/month - Similar to Render Standard
- **Advantage**: Render is often more reliable and faster
### **Why Render > Heroku:**
- ✅ Better performance per dollar
- ✅ More generous free tier
- ✅ Faster deployments
- ✅ Better developer experience
- ✅ No cold starts on paid plans
---
## 🚨 **MIGRATION STEPS (if moving from local)**
1. **Push to GitHub**: Ensure your MCP server is in GitHub
2. **Deploy to Render**: Follow steps above
3. **Update Frontend**: Change API URLs to Render domain
4. **Test Integration**: Verify all MCP tools work remotely
5. **Monitor Performance**: Use Render's built-in metrics
---
## 🎯 **PRODUCTION OPTIMIZATIONS**
### **Scale for Production:**
- Start with **Starter Plan** ($7/month)
- Monitor CPU/Memory usage in Render dashboard
- Upgrade to **Standard Plan** ($25/month) when needed
- Enable auto-scaling if traffic increases
### **Monitoring Setup:**
```bash
# Render provides built-in:
✅ CPU/Memory monitoring
✅ Request/Response tracking
✅ Error rate monitoring
✅ Uptime monitoring
✅ Log aggregation
```
### **Database Optimization:**
Your server already includes:
- ✅ Connection pooling with Supabase
- ✅ Auto-migration on startup
- ✅ Health checks for connectivity
- ✅ Error handling and retry logic
---
## 🎉 **PERFECT ARCHITECTURE**
```
Charnoksv3 (Vercel) ←→ MCP Server (Render) ←→ Supabase Database
↓ ↓ ↓
UI Components AI Processing Data Storage
Client Services Business Logic Real-time Data
Offline Features WebSocket Chat Authentication
```
**Benefits:**
- ✅ All platforms optimized for their strengths
- ✅ Independent scaling and deployment
- ✅ Cost-effective ($7-25/month total)
- ✅ Professional, production-ready setup
- ✅ Easy maintenance and monitoring
---
## 🚀 **NEXT STEPS**
1. **Deploy to Render** - Takes 5-10 minutes
2. **Test MCP Tools** - Verify all endpoints work
3. **Update Frontend** - Point to Render URL
4. **Monitor Performance** - Use Render dashboard
5. **Scale as Needed** - Upgrade plan when traffic grows
Your MCP server is **production-ready for Render deployment right now!** 🚀