install.shโข9.16 kB
#!/bin/bash
# MCP Fullstack Installation Script for macOS and Linux
# This script installs MCP Fullstack and optionally sets it up as a system service
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color
# Detect platform
PLATFORM=$(uname)
ARCH=$(uname -m)
echo -e "${BLUE}๐ MCP Fullstack Installation Script${NC}"
echo -e "${BLUE}====================================${NC}"
echo ""
echo -e "Platform: ${GREEN}$PLATFORM${NC}"
echo -e "Architecture: ${GREEN}$ARCH${NC}"
echo ""
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo -e "${RED}โ Node.js is not installed${NC}"
echo "Please install Node.js 18+ from https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node --version)
echo -e "Node.js: ${GREEN}$NODE_VERSION${NC}"
# Check Node.js version
REQUIRED_VERSION="18"
CURRENT_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$CURRENT_VERSION" -lt "$REQUIRED_VERSION" ]; then
echo -e "${RED}โ Node.js $REQUIRED_VERSION+ is required (current: $NODE_VERSION)${NC}"
exit 1
fi
# Check if npm is installed
if ! command -v npm &> /dev/null; then
echo -e "${RED}โ npm is not installed${NC}"
exit 1
fi
NPM_VERSION=$(npm --version)
echo -e "npm: ${GREEN}$NPM_VERSION${NC}"
echo ""
# Installation options
INSTALL_SERVICE=false
INSTALL_DIR="$HOME/.mcp-fullstack"
PORT="3000"
SERVICE_USER=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--service)
INSTALL_SERVICE=true
shift
;;
--dir)
INSTALL_DIR="$2"
shift 2
;;
--port)
PORT="$2"
shift 2
;;
--user)
SERVICE_USER="$2"
shift 2
;;
--help)
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --service Install as system service"
echo " --dir DIR Installation directory (default: ~/.mcp-fullstack)"
echo " --port PORT Server port (default: 3000)"
echo " --user USER Service user (Linux only, default: current user)"
echo " --help Show this help message"
exit 0
;;
*)
echo -e "${RED}โ Unknown option: $1${NC}"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo -e "${PURPLE}๐ Installation Configuration${NC}"
echo -e "Install Directory: ${GREEN}$INSTALL_DIR${NC}"
echo -e "Server Port: ${GREEN}$PORT${NC}"
echo -e "Install as Service: ${GREEN}$([ "$INSTALL_SERVICE" = true ] && echo "Yes" || echo "No")${NC}"
if [ "$INSTALL_SERVICE" = true ] && [ "$PLATFORM" = "Linux" ] && [ -n "$SERVICE_USER" ]; then
echo -e "Service User: ${GREEN}$SERVICE_USER${NC}"
fi
echo ""
# Confirm installation
read -p "Continue with installation? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Installation cancelled."
exit 0
fi
echo -e "${YELLOW}๐ Starting installation...${NC}"
echo ""
# Create installation directory
echo -e "${BLUE}๐ Creating installation directory...${NC}"
mkdir -p "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/logs"
# Check if we're in the project directory or need to clone
if [ -f "package.json" ] && grep -q "mcp-fullstack" package.json; then
echo -e "${BLUE}๐ฆ Using current directory as source...${NC}"
SOURCE_DIR=$(pwd)
else
echo -e "${BLUE}๐ฆ Cloning from repository...${NC}"
# In a real deployment, you'd clone from the actual repository
echo -e "${YELLOW}โ ๏ธ Note: This script should be updated with the actual repository URL${NC}"
SOURCE_DIR=$(pwd) # For now, assume we're in the project directory
fi
# Copy project files (excluding node_modules and other build artifacts)
echo -e "${BLUE}๐ Copying project files...${NC}"
rsync -av --exclude='node_modules' --exclude='.git' --exclude='dist' --exclude='dashboard/node_modules' --exclude='dashboard/dist' "$SOURCE_DIR/" "$INSTALL_DIR/"
# Navigate to installation directory
cd "$INSTALL_DIR"
# Install dependencies
echo -e "${BLUE}๐ฆ Installing dependencies...${NC}"
npm install --production
# Build the dashboard
echo -e "${BLUE}๐๏ธ Building dashboard...${NC}"
cd dashboard
npm install
npm run build
cd ..
# Build the server
echo -e "${BLUE}๐๏ธ Building server...${NC}"
npm run build
# Create environment file
echo -e "${BLUE}โ๏ธ Creating environment configuration...${NC}"
cat > .env << EOF
# MCP Fullstack Configuration
PORT=$PORT
HOST=0.0.0.0
LOG_LEVEL=info
# WebDriver (optional - for remote WebDriver)
# WEB_DRIVER_REMOTE_URL=http://selenium-hub:4444/wd/hub
# Supabase (optional)
# SUPABASE_URL=https://your-project.supabase.co
# SUPABASE_SERVICE_ROLE=your-service-role-key
# SUPABASE_ANON=your-anon-key
# External Services (optional)
# RENDER_API_TOKEN=your-render-token
# VERCEL_TOKEN=your-vercel-token
# POSTHOG_API_HOST=https://app.posthog.com
# POSTHOG_PROJECT_KEY=your-project-key
# POSTHOG_PERSONAL_API_KEY=your-personal-api-key
# GEMINI_API_KEY=your-gemini-api-key
EOF
# Create CLI symlink
echo -e "${BLUE}๐ Creating CLI symlink...${NC}"
SYMLINK_DIR="/usr/local/bin"
if [ "$PLATFORM" = "Darwin" ]; then
# macOS
if [ ! -d "$SYMLINK_DIR" ]; then
sudo mkdir -p "$SYMLINK_DIR"
fi
sudo ln -sf "$INSTALL_DIR/dist/cli.js" "$SYMLINK_DIR/mcp-fullstack"
sudo chmod +x "$SYMLINK_DIR/mcp-fullstack"
elif [ "$PLATFORM" = "Linux" ]; then
# Linux
if [ ! -d "$SYMLINK_DIR" ]; then
sudo mkdir -p "$SYMLINK_DIR"
fi
sudo ln -sf "$INSTALL_DIR/dist/cli.js" "$SYMLINK_DIR/mcp-fullstack"
sudo chmod +x "$SYMLINK_DIR/mcp-fullstack"
fi
# Install as service if requested
if [ "$INSTALL_SERVICE" = true ]; then
echo -e "${BLUE}๐ง Installing as system service...${NC}"
# Prepare service installation command
SERVICE_CMD="$INSTALL_DIR/dist/cli.js service install --port $PORT"
if [ "$PLATFORM" = "Linux" ] && [ -n "$SERVICE_USER" ]; then
SERVICE_CMD="$SERVICE_CMD --user $SERVICE_USER"
fi
# Check if we need sudo for service installation
if [ "$PLATFORM" = "Linux" ] && [ "$(id -u)" -ne 0 ]; then
echo -e "${YELLOW}โ ๏ธ Service installation requires sudo privileges${NC}"
sudo node $SERVICE_CMD
else
node $SERVICE_CMD
fi
# Start the service
echo -e "${BLUE}โถ๏ธ Starting service...${NC}"
if [ "$PLATFORM" = "Linux" ] && [ "$(id -u)" -ne 0 ]; then
sudo node "$INSTALL_DIR/dist/cli.js" service start
else
node "$INSTALL_DIR/dist/cli.js" service start
fi
fi
# Install Chrome/Chromium for browser automation
echo -e "${BLUE}๐ Checking for Chrome/Chromium...${NC}"
if command -v google-chrome &> /dev/null || command -v chromium-browser &> /dev/null || command -v chromium &> /dev/null; then
echo -e "${GREEN}โ
Chrome/Chromium found${NC}"
else
echo -e "${YELLOW}โ ๏ธ Chrome/Chromium not found${NC}"
echo "For browser automation features, please install Chrome or Chromium:"
if [ "$PLATFORM" = "Darwin" ]; then
echo " brew install google-chrome"
elif [ "$PLATFORM" = "Linux" ]; then
echo " Ubuntu/Debian: sudo apt install chromium-browser"
echo " CentOS/RHEL: sudo yum install chromium"
echo " Arch: sudo pacman -S chromium"
fi
fi
# Installation complete
echo ""
echo -e "${GREEN}๐ Installation completed successfully!${NC}"
echo -e "${GREEN}=================================${NC}"
echo ""
# Show next steps
echo -e "${PURPLE}๐ Next Steps:${NC}"
echo ""
if [ "$INSTALL_SERVICE" = true ]; then
echo -e "1. ${BLUE}Service Management:${NC}"
echo -e " โข Check status: ${GREEN}mcp-fullstack service status${NC}"
echo -e " โข View logs: ${GREEN}mcp-fullstack service logs${NC}"
echo -e " โข Restart: ${GREEN}mcp-fullstack service restart${NC}"
echo ""
echo -e "2. ${BLUE}Access Dashboard:${NC}"
echo -e " โข Open: ${GREEN}http://localhost:$PORT${NC}"
echo -e " โข Install as PWA for standalone window experience${NC}"
echo ""
else
echo -e "1. ${BLUE}Start the server:${NC}"
echo -e " โข Run: ${GREEN}cd $INSTALL_DIR && npm start${NC}"
echo -e " โข Or: ${GREEN}mcp-fullstack start${NC}"
echo ""
echo -e "2. ${BLUE}Install as service (optional):${NC}"
echo -e " โข Run: ${GREEN}mcp-fullstack service install${NC}"
echo ""
echo -e "3. ${BLUE}Access Dashboard:${NC}"
echo -e " โข Open: ${GREEN}http://localhost:$PORT${NC}"
echo ""
fi
echo -e "3. ${BLUE}Configuration:${NC}"
echo -e " โข Edit: ${GREEN}$INSTALL_DIR/.env${NC}"
echo -e " โข Add your API keys for external services${NC}"
echo ""
echo -e "4. ${BLUE}CLI Commands:${NC}"
echo -e " โข Help: ${GREEN}mcp-fullstack --help${NC}"
echo -e " โข Info: ${GREEN}mcp-fullstack info${NC}"
echo -e " โข Test: ${GREEN}mcp-fullstack test${NC}"
echo ""
echo -e "${BLUE}๐ Documentation:${NC}"
echo -e " โข README: ${GREEN}$INSTALL_DIR/README.md${NC}"
echo -e " โข Repository: ${GREEN}https://github.com/your-repo/mcp-fullstack${NC}"
echo ""
echo -e "${GREEN}Happy coding with MCP Fullstack! ๐${NC}"