DEPLOYMENT_PLAN.md•8.29 kB
# MCP Router Deployment Plan
## 🎯 Overview
This plan outlines how to deploy your MCP Router for testing with live AI agents, including hosting options, security considerations, and integration steps.
## 🏗️ Current Status
- ✅ **MCP Router fully functional** (5 tools implemented)
- ✅ **OAuth authentication working** (Google Calendar + Gmail)
- ✅ **Local development complete** (localhost:8080)
- ✅ **All dependencies resolved** (TypeScript, Fastify, Google APIs)
## 🚀 Deployment Options
### Option 1: Railway (Recommended for Testing)
**Best for: Quick deployment, easy scaling, built-in monitoring**
**Pros:**
- Zero-config deployment from GitHub
- Automatic HTTPS with custom domains
- Built-in environment variable management
- Free tier available
- Easy database integration (Redis)
**Steps:**
1. Push code to GitHub repository
2. Connect Railway to GitHub repo
3. Set environment variables in Railway dashboard
4. Deploy automatically
5. Get production URL (e.g., `https://your-app.railway.app`)
**Cost:** Free tier (500 hours/month) + $5/month for production
### Option 2: Render
**Best for: Simple deployment, good free tier**
**Pros:**
- Free tier with 750 hours/month
- Automatic deployments from GitHub
- Built-in SSL certificates
- Easy environment management
**Steps:**
1. Connect GitHub repository
2. Configure build command: `npm run build`
3. Set start command: `node dist/server.js`
4. Add environment variables
5. Deploy
**Cost:** Free tier available
### Option 3: DigitalOcean App Platform
**Best for: Production-ready, scalable**
**Pros:**
- Professional hosting platform
- Auto-scaling capabilities
- Integrated monitoring
- Database hosting options
**Steps:**
1. Create new app from GitHub
2. Configure Node.js runtime
3. Set environment variables
4. Deploy with custom domain
**Cost:** $5/month minimum
### Option 4: Vercel (Serverless)
**Best for: Edge deployment, global CDN**
**Pros:**
- Global edge deployment
- Automatic HTTPS
- Easy custom domains
- Serverless scaling
**Considerations:**
- May need adjustments for long-running OAuth flows
- Better for API endpoints than persistent connections
## 🔧 Pre-Deployment Setup
### 1. Environment Variables (Production)
```bash
# Required for production
NODE_ENV=production
APP_PORT=8080
HOST=your-domain.com
# Google OAuth (already configured)
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=https://your-domain.com/oauth/google/callback
# Security
TOKEN_ENC_KEY=your-encryption-key
# Optional
REDIS_URL=redis://your-redis-url
GMAIL_SENDER_EMAIL=your-email@gmail.com
GMAIL_SENDER_NAME=Your Name
```
### 2. Google OAuth Configuration Updates
**Update Google Cloud Console:**
1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Navigate to APIs & Services > Credentials
3. Edit your OAuth 2.0 Client ID
4. Add production redirect URI: `https://your-domain.com/oauth/google/callback`
5. Save changes
### 3. Security Enhancements
- [ ] Generate new encryption key for production
- [ ] Set up Redis for idempotency storage
- [ ] Configure CORS for your AI agent domain
- [ ] Set up monitoring and logging
## 🤖 AI Agent Integration
### MCP Protocol Integration
Your MCP Router exposes these endpoints for AI agents:
#### **Base URL:** `https://your-domain.com`
#### **Available Tools:**
1. **`time.resolve`** - Parse natural language time expressions
2. **`calendar.find_free_slots`** - Find available meeting times
3. **`calendar.create_event`** - Schedule meetings
4. **`calendar.cancel_event`** - Cancel meetings
5. **`email.send`** - Send templated emails
#### **Authentication Flow:**
1. AI agent redirects user to: `GET /oauth/google/login`
2. User completes Google OAuth
3. Tokens stored securely in encrypted token store
4. AI agent can now use all tools with user's permissions
### Integration Examples
#### **Claude Desktop Integration:**
```json
{
"mcpServers": {
"google-mcp-router": {
"command": "node",
"args": ["/path/to/your/mcp-router/dist/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
```
#### **Custom AI Agent Integration:**
```python
# Example Python integration
import requests
class MCPRouterClient:
def __init__(self, base_url):
self.base_url = base_url
def resolve_time(self, input_text):
response = requests.post(
f"{self.base_url}/mcp/tools/time.resolve",
json={"input": input_text}
)
return response.json()
def find_free_slots(self, start_time, end_time):
response = requests.post(
f"{self.base_url}/mcp/tools/calendar.find_free_slots",
json={
"window_start_iso": start_time,
"window_end_iso": end_time
}
)
return response.json()
```
## 📋 Deployment Checklist
### Pre-Deployment
- [ ] Choose hosting platform (Railway recommended)
- [ ] Update Google OAuth redirect URIs
- [ ] Generate production encryption key
- [ ] Set up Redis instance (optional but recommended)
- [ ] Test locally with production environment variables
### Deployment Steps
- [ ] Push code to GitHub repository
- [ ] Connect hosting platform to GitHub
- [ ] Configure environment variables
- [ ] Set up custom domain (optional)
- [ ] Deploy and test OAuth flow
- [ ] Test all MCP tools
- [ ] Set up monitoring
### Post-Deployment
- [ ] Verify OAuth authentication works
- [ ] Test calendar operations
- [ ] Test email sending
- [ ] Configure AI agent integration
- [ ] Set up error monitoring
- [ ] Document API endpoints
## 🔒 Security Considerations
### Production Security
- [ ] Use HTTPS only (automatic with most platforms)
- [ ] Secure environment variables
- [ ] Implement rate limiting
- [ ] Set up CORS for specific domains
- [ ] Monitor for suspicious activity
- [ ] Regular security updates
### OAuth Security
- [ ] Validate state parameters
- [ ] Secure cookie handling
- [ ] Token encryption at rest
- [ ] Automatic token refresh
- [ ] Secure token storage
## 📊 Monitoring & Maintenance
### Health Checks
- [ ] `/health` endpoint monitoring
- [ ] OAuth flow monitoring
- [ ] API response time tracking
- [ ] Error rate monitoring
- [ ] Token refresh success rate
### Maintenance Tasks
- [ ] Regular dependency updates
- [ ] Security patch management
- [ ] Performance optimization
- [ ] Log rotation and cleanup
- [ ] Backup procedures
## 🎯 Testing Strategy
### 1. Local Testing
```bash
# Test OAuth flow
curl -L http://localhost:8080/oauth/google/login
# Test MCP tools
curl -X POST http://localhost:8080/mcp/tools/time.resolve \
-H "Content-Type: application/json" \
-d '{"input": "next Monday at 2pm"}'
```
### 2. Production Testing
- [ ] OAuth authentication flow
- [ ] All 5 MCP tools functionality
- [ ] Error handling and edge cases
- [ ] Performance under load
- [ ] Security vulnerability scanning
### 3. AI Agent Integration Testing
- [ ] Claude Desktop integration
- [ ] Custom AI agent integration
- [ ] End-to-end workflow testing
- [ ] User experience validation
## 📈 Scaling Considerations
### Current Capacity
- **Free Tier Limits:**
- Railway: 500 hours/month
- Render: 750 hours/month
- Vercel: 100GB bandwidth/month
### Scaling Up
- **Paid Plans:** $5-20/month for production use
- **Database:** Add Redis for production idempotency
- **CDN:** Use Cloudflare for global distribution
- **Monitoring:** Add Datadog or New Relic
## 🚀 Next Steps
1. **Choose hosting platform** (Railway recommended)
2. **Set up GitHub repository** (if not already done)
3. **Configure production environment**
4. **Deploy and test OAuth flow**
5. **Integrate with AI agent**
6. **Monitor and optimize**
## 📞 Support & Troubleshooting
### Common Issues
- **OAuth redirect mismatch:** Check Google Console settings
- **CORS errors:** Configure allowed origins
- **Token storage issues:** Verify encryption key
- **Rate limiting:** Implement proper throttling
### Debug Tools
- **Health endpoint:** `/health`
- **Metrics endpoint:** `/metrics`
- **Tool metadata:** `/mcp/tools`
- **Server logs:** Platform-specific logging
---
**Ready to deploy?** Choose your hosting platform and follow the deployment steps above! 🚀