DEPLOYMENT.md•6.32 kB
# Deployment Guide
This guide covers various deployment options for the Sequential Thinking MCP Server.
## Table of Contents
- [Local Deployment](#local-deployment)
- [Docker Deployment](#docker-deployment)
- [Cloudflare Workers](#cloudflare-workers)
- [Cloud Platforms](#cloud-platforms)
---
## Local Deployment
### Development
```bash
# Install dependencies
npm install
# Build the project
npm run build
# Run in stdio mode (for MCP clients)
npm start
# Run HTTP server
npm run start:http
```
### Production
```bash
# Install production dependencies only
npm ci --only=production
# Build
npm run build
# Run with PM2 (process manager)
npm install -g pm2
pm2 start dist/server-http.js --name sequential-thinking
pm2 save
pm2 startup
```
---
## Docker Deployment
### Build and Run
```bash
# Build the image
docker build -t sequential-thinking-server .
# Run the container
docker run -p 3000:3000 sequential-thinking-server
# Run with custom port
docker run -p 8080:3000 -e PORT=3000 sequential-thinking-server
```
### Docker Compose
Create `docker-compose.yml`:
```yaml
version: '3.8'
services:
sequential-thinking:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- PORT=3000
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
```
Run with:
```bash
docker-compose up -d
```
---
## Cloudflare Workers
### Prerequisites
1. Cloudflare account (free tier works)
2. Wrangler CLI installed: `npm install -g wrangler`
### Setup
```bash
# Login to Cloudflare
wrangler login
# Deploy to production
npm run deploy:workers
# Deploy to staging
wrangler deploy --env staging
```
### Custom Domain
1. Add a custom domain in your Cloudflare dashboard
2. Update `wrangler.toml`:
```toml
routes = [
{ pattern = "thinking.yourdomain.com", custom_domain = true }
]
```
3. Deploy:
```bash
npm run deploy:workers
```
### Using Durable Objects (for persistence)
For persistent state across requests, use Cloudflare Durable Objects.
Update `wrangler.toml`:
```toml
[[durable_objects.bindings]]
name = "THINKING_SESSIONS"
class_name = "ThinkingSession"
[[migrations]]
tag = "v1"
new_classes = ["ThinkingSession"]
```
---
## Cloud Platforms
### Heroku
1. Create a `Procfile`:
```
web: node dist/server-http.js
```
2. Deploy:
```bash
heroku create sequential-thinking-server
git push heroku main
```
### Google Cloud Run
```bash
# Build and push image
gcloud builds submit --tag gcr.io/PROJECT_ID/sequential-thinking
# Deploy
gcloud run deploy sequential-thinking \
--image gcr.io/PROJECT_ID/sequential-thinking \
--platform managed \
--region us-central1 \
--allow-unauthenticated
```
### AWS Elastic Beanstalk
1. Install EB CLI:
```bash
pip install awsebcli
```
2. Initialize and deploy:
```bash
eb init -p node.js-20 sequential-thinking
eb create sequential-thinking-env
eb deploy
```
### Railway
```bash
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Deploy
railway up
```
### Render
1. Create `render.yaml`:
```yaml
services:
- type: web
name: sequential-thinking
env: node
buildCommand: npm install && npm run build
startCommand: npm run start:http
envVars:
- key: NODE_ENV
value: production
```
2. Connect your GitHub repo to Render
3. Deploy automatically on push
### DigitalOcean App Platform
1. Create `app.yaml`:
```yaml
name: sequential-thinking-server
services:
- name: api
github:
repo: your-username/sequential-thinking-mvp-server
branch: main
build_command: npm install && npm run build
run_command: npm run start:http
environment_slug: node-js
http_port: 3000
routes:
- path: /
```
2. Deploy via DigitalOcean dashboard or CLI
---
## Environment Variables
Configure these environment variables for your deployment:
| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | HTTP server port | `3000` |
| `NODE_ENV` | Environment (development/production) | `development` |
---
## Health Checks
All deployments should configure health checks:
- **Endpoint**: `GET /health`
- **Expected Response**: `200 OK` with `{"status":"ok","timestamp":...}`
- **Timeout**: 10 seconds
- **Interval**: 30 seconds
---
## Monitoring
### Recommended Monitoring Tools
- **Application Monitoring**: New Relic, Datadog, or AppDynamics
- **Error Tracking**: Sentry
- **Uptime Monitoring**: UptimeRobot, Pingdom
- **Logs**: Logtail, Papertrail, or CloudWatch
### Health Check Monitoring
Set up automated monitoring for:
```bash
curl https://your-deployment.com/health
```
---
## Security Considerations
1. **HTTPS**: Always use HTTPS in production
2. **Rate Limiting**: Implement rate limiting for public endpoints
3. **Authentication**: Add authentication if needed
4. **CORS**: Configure CORS appropriately for your use case
5. **Secrets**: Use environment variables for sensitive data
---
## Scaling
### Horizontal Scaling
The server is stateless (session data is in-memory), so:
- For HTTP deployments, use a load balancer
- Consider using Redis or a database for session persistence
- Cloudflare Workers auto-scales
### Vertical Scaling
Minimum requirements:
- **CPU**: 1 core
- **RAM**: 512MB
- **Storage**: 100MB
Recommended for production:
- **CPU**: 2 cores
- **RAM**: 1GB
- **Storage**: 1GB
---
## Troubleshooting
### Server won't start
Check logs for:
```bash
# Docker
docker logs <container-id>
# PM2
pm2 logs sequential-thinking
# Cloud platforms
# Use platform-specific log viewers
```
### High memory usage
- Implement session cleanup for old sessions
- Use external storage (Redis, DB) instead of in-memory
### Connection timeouts
- Increase timeout values in your load balancer/proxy
- Check network security groups/firewall rules
---
## Support
For deployment issues:
1. Check the logs
2. Verify environment variables
3. Test health endpoint
4. Open an issue on GitHub
---
## Next Steps
After deployment:
1. Test all endpoints
2. Set up monitoring
3. Configure backups (if using persistent storage)
4. Document your deployment configuration
5. Set up CI/CD for automatic deployments