#!/bin/bash
# MCP Calendar Server Setup Script
# This script helps you get started with the MCP Calendar Server
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}🚀 MCP Calendar Server Setup${NC}"
echo "==============================="
echo
# Check Node.js version
echo -e "${YELLOW}Checking Node.js version...${NC}"
if ! command -v node &> /dev/null; then
echo -e "${RED}❌ Node.js is not installed. Please install Node.js 18 or higher.${NC}"
exit 1
fi
NODE_VERSION=$(node -v | sed 's/v//')
REQUIRED_VERSION="18.0.0"
if ! npx semver -r ">=$REQUIRED_VERSION" "$NODE_VERSION" &> /dev/null; then
echo -e "${RED}❌ Node.js version $NODE_VERSION is too old. Please install Node.js 18 or higher.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Node.js version $NODE_VERSION is compatible${NC}"
echo
# Install dependencies
echo -e "${YELLOW}Installing dependencies...${NC}"
npm install
echo -e "${GREEN}✅ Dependencies installed${NC}"
echo
# Copy environment file
if [ ! -f .env ]; then
echo -e "${YELLOW}Creating environment file...${NC}"
cp .env.example .env
echo -e "${GREEN}✅ Environment file created (.env)${NC}"
echo -e "${YELLOW}⚠️ Please edit .env with your configuration${NC}"
else
echo -e "${YELLOW}Environment file already exists${NC}"
fi
echo
# Check for Docker (optional)
echo -e "${YELLOW}Checking for Docker (optional)...${NC}"
if command -v docker &> /dev/null; then
echo -e "${GREEN}✅ Docker is available${NC}"
# Ask if user wants to start services with Docker
read -p "Do you want to start PostgreSQL and Redis with Docker? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Starting Docker services...${NC}"
docker-compose up -d postgres redis
echo -e "${GREEN}✅ PostgreSQL and Redis started${NC}"
# Wait for services to be ready
echo -e "${YELLOW}Waiting for services to be ready...${NC}"
sleep 5
# Test database connection
if docker-compose exec -T postgres pg_isready &> /dev/null; then
echo -e "${GREEN}✅ PostgreSQL is ready${NC}"
else
echo -e "${YELLOW}⚠️ PostgreSQL might still be starting up${NC}"
fi
fi
else
echo -e "${YELLOW}⚠️ Docker not found. You'll need to install PostgreSQL and Redis manually.${NC}"
fi
echo
# Build the project
echo -e "${YELLOW}Building the project...${NC}"
npm run build
echo -e "${GREEN}✅ Project built successfully${NC}"
echo
# Instructions for Google Calendar setup
echo -e "${BLUE}📅 Google Calendar Setup Instructions:${NC}"
echo "======================================="
echo "1. Go to https://console.cloud.google.com/"
echo "2. Create a new project or select an existing one"
echo "3. Enable the Google Calendar API"
echo "4. Go to 'Credentials' and create an OAuth 2.0 Client ID"
echo "5. Set the redirect URI to: http://localhost:3000/auth/google/callback"
echo "6. Copy the Client ID and Client Secret to your .env file"
echo
# Configuration checklist
echo -e "${BLUE}📋 Configuration Checklist:${NC}"
echo "=========================="
echo "□ Edit .env with your Google Calendar credentials"
echo "□ Set DATABASE_URL (if not using Docker)"
echo "□ Set REDIS_URL (if not using Docker)"
echo "□ Set JWT_SECRET to a secure random string"
echo
# Final instructions
echo -e "${BLUE}🎯 Next Steps:${NC}"
echo "=============="
echo "1. Edit the .env file with your configuration"
echo "2. Run 'npm start' to start the server"
echo "3. Configure your MCP client to use this server"
echo
# Show example MCP configuration
echo -e "${BLUE}📝 MCP Client Configuration Example:${NC}"
echo "====================================="
echo "Add this to your claude_desktop_config.json:"
echo
cat << 'EOF'
{
"mcpServers": {
"calendar-assistant": {
"command": "node",
"args": ["/absolute/path/to/mcp-calendar-server/dist/index.js"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/calendar_assistant",
"GOOGLE_CLIENT_ID": "your-google-client-id",
"GOOGLE_CLIENT_SECRET": "your-google-client-secret",
"JWT_SECRET": "your-jwt-secret"
}
}
}
}
EOF
echo
echo -e "${GREEN}🎉 Setup complete! Happy scheduling! 🎉${NC}"