Skip to main content
Glama
deploy-production.sh9.82 kB
#!/bin/bash # ================================================================ # LEGACY SCRIPT - Replaced by GitHub Actions # ================================================================ # This script is kept for emergency manual deployments only. # Normal deployments should use the GitHub Actions workflow: # - Push to 'main' branch for automatic deployment (with approval) # - See GITHUB_CICD_PLAN.md for details # ================================================================ # ============================================ # Tableau MCP Server - PRODUCTION Deployment # ============================================ # This script automates the deployment of the # Tableau MCP Server to Google Cloud Run (Production) # ============================================ set -e # Exit on error # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # ============================================ # Configuration # ============================================ ENVIRONMENT="production" SERVICE_NAME="tableau-mcp-production" REGION="australia-southeast1" IMAGE_TAG="production-latest" echo -e "${BLUE}============================================${NC}" echo -e "${BLUE}Tableau MCP Server - PRODUCTION Deployment${NC}" echo -e "${BLUE}============================================${NC}" echo "" # ============================================ # Deployment Warning # ============================================ echo -e "${YELLOW}⚠️ WARNING: This is a legacy manual deployment script.${NC}" echo -e "${YELLOW} GitHub Actions is now the primary deployment method.${NC}" echo "" read -p "Continue with manual PRODUCTION deployment? (yes/no): " CONFIRM if [ "$CONFIRM" != "yes" ]; then echo -e "${RED}Deployment cancelled.${NC}" exit 0 fi echo "" # ============================================ # Step 1: Verify Prerequisites # ============================================ echo -e "${YELLOW}[Step 1/8] Verifying prerequisites...${NC}" # Check if gcloud is installed if ! command -v gcloud &> /dev/null; then echo -e "${RED}ERROR: gcloud CLI is not installed${NC}" echo "Install from: https://cloud.google.com/sdk/docs/install" exit 1 fi # Check if docker is installed if ! command -v docker &> /dev/null; then echo -e "${RED}ERROR: Docker is not installed${NC}" echo "Install from: https://docs.docker.com/get-docker/" exit 1 fi # Get current project PROJECT_ID=$(gcloud config get-value project 2>/dev/null) if [ -z "$PROJECT_ID" ]; then echo -e "${RED}ERROR: No Google Cloud project set${NC}" echo "Run: gcloud config set project YOUR_PROJECT_ID" exit 1 fi echo -e "${GREEN}✓ Prerequisites verified${NC}" echo " - Project: $PROJECT_ID" echo " - Region: $REGION" echo " - Service: $SERVICE_NAME" echo "" # ============================================ # Step 2: PRODUCTION Confirmation # ============================================ echo -e "${RED}============================================${NC}" echo -e "${RED}WARNING: PRODUCTION DEPLOYMENT${NC}" echo -e "${RED}============================================${NC}" echo "You are about to deploy to PRODUCTION environment!" echo "" echo "Production will have:" echo " - Minimum 1 instance running (always on)" echo " - Higher resource limits (2 CPU, 1Gi memory)" echo " - Production Tableau credentials" echo " - Production API key" echo "" read -p "Are you ABSOLUTELY SURE you want to deploy to PRODUCTION? (yes/NO) " -r echo "" if [[ ! $REPLY =~ ^yes$ ]]; then echo -e "${RED}Deployment cancelled${NC}" echo "To deploy to staging instead, use: ./deploy-staging.sh" exit 0 fi echo "" # ============================================ # Step 3: Enable Required APIs # ============================================ echo -e "${YELLOW}[Step 3/8] Enabling required Google Cloud APIs...${NC}" gcloud services enable \ run.googleapis.com \ containerregistry.googleapis.com \ cloudbuild.googleapis.com \ secretmanager.googleapis.com \ --project=$PROJECT_ID echo -e "${GREEN}✓ APIs enabled${NC}" echo "" # ============================================ # Step 4: Build Docker Image # ============================================ echo -e "${YELLOW}[Step 4/8] Building Docker image...${NC}" IMAGE_NAME="gcr.io/$PROJECT_ID/tableau-mcp:$IMAGE_TAG" docker build -t $IMAGE_NAME . --platform linux/amd64 echo -e "${GREEN}✓ Docker image built: $IMAGE_NAME${NC}" echo "" # ============================================ # Step 5: Push to Google Container Registry # ============================================ echo -e "${YELLOW}[Step 5/8] Pushing image to Google Container Registry...${NC}" # Configure Docker authentication gcloud auth configure-docker --quiet # Push image docker push $IMAGE_NAME echo -e "${GREEN}✓ Image pushed to GCR${NC}" echo "" # ============================================ # Step 6: Verify Secrets Exist # ============================================ echo -e "${YELLOW}[Step 6/8] Verifying production secrets...${NC}" SECRETS=("tableau-token-production" "mcp-api-key-production") MISSING_SECRETS=() for SECRET in "${SECRETS[@]}"; do if ! gcloud secrets describe $SECRET --project=$PROJECT_ID &>/dev/null; then MISSING_SECRETS+=($SECRET) fi done if [ ${#MISSING_SECRETS[@]} -ne 0 ]; then echo -e "${RED}ERROR: Missing required production secrets:${NC}" for SECRET in "${MISSING_SECRETS[@]}"; do echo " - $SECRET" done echo "" echo "Create secrets using: ./create-secrets.sh production" echo "Or see: SECRETS_SETUP.md" exit 1 fi echo -e "${GREEN}✓ All required production secrets exist${NC}" echo "" # ============================================ # Step 7: Deploy to Cloud Run # ============================================ echo -e "${YELLOW}[Step 7/8] Deploying to Cloud Run (PRODUCTION)...${NC}" # Get environment configuration echo "Please provide the PRODUCTION configuration:" read -p "Tableau Server URL (e.g., https://your-server.tableau.com): " TABLEAU_SERVER_URL read -p "Tableau Site ID (leave empty for default site): " TABLEAU_SITE_ID read -p "Tableau Token Name: " TABLEAU_TOKEN_NAME echo "" echo "Final confirmation - deploying with:" echo " - URL: $TABLEAU_SERVER_URL" echo " - Site: ${TABLEAU_SITE_ID:-[default site]}" echo " - Token: $TABLEAU_TOKEN_NAME" echo "" read -p "Proceed with PRODUCTION deployment? (yes/NO) " -r echo "" if [[ ! $REPLY =~ ^yes$ ]]; then echo -e "${RED}Deployment cancelled${NC}" exit 0 fi # Deploy service gcloud run deploy $SERVICE_NAME \ --image=$IMAGE_NAME \ --platform=managed \ --region=$REGION \ --allow-unauthenticated \ --min-instances=1 \ --max-instances=10 \ --cpu=2 \ --memory=1Gi \ --timeout=300 \ --concurrency=100 \ --set-env-vars="NODE_ENV=production,PORT=8080,TABLEAU_SERVER_URL=$TABLEAU_SERVER_URL,TABLEAU_SITE_ID=$TABLEAU_SITE_ID,TABLEAU_TOKEN_NAME=$TABLEAU_TOKEN_NAME,TABLEAU_API_VERSION=3.23" \ --set-secrets="TABLEAU_TOKEN_VALUE=tableau-token-production:latest,MCP_API_KEY=mcp-api-key-production:latest" \ --project=$PROJECT_ID echo -e "${GREEN}✓ Deployed to Cloud Run (PRODUCTION)${NC}" echo "" # ============================================ # Step 8: Get Service URL and Test # ============================================ echo -e "${YELLOW}[Step 8/8] Verifying production deployment...${NC}" # Get service URL SERVICE_URL=$(gcloud run services describe $SERVICE_NAME \ --region=$REGION \ --project=$PROJECT_ID \ --format='value(status.url)') echo "" echo -e "${GREEN}============================================${NC}" echo -e "${GREEN}✓ PRODUCTION DEPLOYMENT SUCCESSFUL!${NC}" echo -e "${GREEN}============================================${NC}" echo "" echo "Service URL: $SERVICE_URL" echo "" echo "Endpoints:" echo " - Health: $SERVICE_URL/health" echo " - Readiness: $SERVICE_URL/ready" echo " - Liveness: $SERVICE_URL/alive" echo " - MCP SSE: $SERVICE_URL/sse" echo "" # Test health endpoint echo "Testing health endpoint..." HEALTH_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $SERVICE_URL/health) if [ "$HEALTH_STATUS" == "200" ]; then echo -e "${GREEN}✓ Health check passed${NC}" else echo -e "${RED}✗ Health check failed (HTTP $HEALTH_STATUS)${NC}" fi echo "" # Get MCP API Key for Cursor configuration MCP_API_KEY=$(gcloud secrets versions access latest --secret=mcp-api-key-production --project=$PROJECT_ID) echo "Next steps:" echo "1. Test MCP endpoints with your production API key" echo "2. Update Cursor MCP configuration with production URL" echo "3. Monitor logs and metrics closely" echo "4. Set up alerting for production issues" echo "" echo "MCP Configuration for Cursor (PRODUCTION):" echo "---" echo "URL: $SERVICE_URL/sse" echo "API Key: $MCP_API_KEY" echo "---" echo "" echo "View logs:" echo " gcloud run logs read $SERVICE_NAME --region=$REGION --project=$PROJECT_ID --limit=50" echo "" echo "Stream logs (real-time):" echo " gcloud run logs tail $SERVICE_NAME --region=$REGION --project=$PROJECT_ID" echo "" echo "Update service:" echo " ./deploy-production.sh" echo "" echo "Rollback:" echo " gcloud run revisions list --service=$SERVICE_NAME --region=$REGION" echo " gcloud run services update-traffic $SERVICE_NAME --region=$REGION --to-revisions=REVISION_NAME=100" echo "" echo "Monitor metrics:" echo " https://console.cloud.google.com/run/detail/$REGION/$SERVICE_NAME/metrics?project=$PROJECT_ID" echo "" echo -e "${BLUE}Production deployment complete!${NC}" echo -e "${YELLOW}Remember to:${NC}" echo " 1. Monitor logs for any issues" echo " 2. Test all MCP tools in production" echo " 3. Set up alerting (see MONITORING_GUIDE.md)" echo " 4. Document production API key location" echo " 5. Schedule secret rotation (every 90 days)"

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/russelenriquez-agile/tableau-mcp-project'

If you have feedback or need assistance with the MCP directory API, please join our Discord server