mem0 Memory System

#!/bin/bash # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ ┃ # ┃ ███╗ ███╗███████╗███╗ ███╗ ██████╗ ███╗ ███╗ ██████╗██████╗ ┃ # ┃ ████╗ ████║██╔════╝████╗ ████║██╔═══██╗ ████╗ ████║██╔════╝██╔══██╗ ┃ # ┃ ██╔████╔██║█████╗ ██╔████╔██║██║ ██║ ██╔████╔██║██║ ██████╔╝ ┃ # ┃ ██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║ ██║╚██╔╝██║██║ ██╔═══╝ ┃ # ┃ ██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝ ██║ ╚═╝ ██║╚██████╗██║ ┃ # ┃ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ┃ # ┃ ┃ # ┃ ✨ SERVER INSTALLER ✨ ┃ # ┃ Made with ❤️ by Pink Pixel ┃ # ┃ ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ # Colors for better readability BLACK='\033[0;30m' RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' WHITE='\033[0;37m' ORANGE='\033[0;91m' LIME='\033[0;92m' MAGENTA='\033[0;95m' BRIGHT_CYAN='\033[0;96m' BOLD='\033[1m' UNDERLINE='\033[4m' BLINK='\033[5m' REVERSE='\033[7m' NC='\033[0m' # No Color # Gradient colors for text GRAD1='\033[38;5;39m' # Light blue GRAD2='\033[38;5;38m' # Cyan GRAD3='\033[38;5;37m' # Light cyan GRAD4='\033[38;5;36m' # Teal GRAD5='\033[38;5;35m' # Light green GRAD6='\033[38;5;41m' # Green GRAD7='\033[38;5;47m' # Bright green GRAD8='\033[38;5;48m' # Mint # Spinner characters SPINNER=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') # Function to display a spinner with message show_spinner() { local message="$1" local duration=${2:-3} # Default duration: 3 seconds local end_time=$((SECONDS + duration)) local i=0 while [ $SECONDS -lt $end_time ]; do printf "\r${CYAN}${SPINNER[$i]} ${message}${NC}" i=$(( (i+1) % ${#SPINNER[@]} )) sleep 0.1 done printf "\r${GREEN}✓ ${message}${NC}\n" } # Function to display a progress bar show_progress() { local message="$1" local duration=${2:-3} # Default duration: 3 seconds local width=50 local bar_char="▓" local empty_char="░" local end_time=$((SECONDS + duration)) while [ $SECONDS -lt $end_time ]; do local elapsed=$((SECONDS - (end_time - duration))) local percent=$((elapsed * 100 / duration)) local filled=$((elapsed * width / duration)) printf "\r${message} [" printf "${GRAD7}" for ((i=0; i<filled; i++)); do printf "${bar_char}" done printf "${NC}" for ((i=filled; i<width; i++)); do printf "${empty_char}" done printf "] ${percent}%%" sleep 0.05 done printf "\r${message} [${GRAD7}" for ((i=0; i<width; i++)); do printf "${bar_char}" done printf "${NC}] 100%%\n" } # Function to print colored header print_header() { clear echo -e "${GRAD1}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓${NC}" echo -e "${GRAD2}┃ ┃${NC}" echo -e "${GRAD3}┃ ███╗ ███╗███████╗███╗ ███╗ ██████╗ ███╗ ███╗ ██████╗██████╗ ┃${NC}" echo -e "${GRAD4}┃ ████╗ ████║██╔════╝████╗ ████║██╔═══██╗ ████╗ ████║██╔════╝██╔══██╗ ┃${NC}" echo -e "${GRAD5}┃ ██╔████╔██║█████╗ ██╔████╔██║██║ ██║ ██╔████╔██║██║ ██████╔╝ ┃${NC}" echo -e "${GRAD6}┃ ██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║ ██║╚██╔╝██║██║ ██╔═══╝ ┃${NC}" echo -e "${GRAD7}┃ ██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝ ██║ ╚═╝ ██║╚██████╗██║ ┃${NC}" echo -e "${GRAD8}┃ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ┃${NC}" echo -e "${GRAD7}┃ ┃${NC}" echo -e "${GRAD6}┃ ${BLINK}✨${NC}${GRAD6} SERVER INSTALLER ${BLINK}✨${NC}${GRAD6} ┃${NC}" echo -e "${GRAD5}┃ Made with ❤️ by Pink Pixel ┃${NC}" echo -e "${GRAD4}┃ ┃${NC}" echo -e "${GRAD3}┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛${NC}" echo "" } # Function to print section header print_section() { local title="$1" local color="$2" echo "" echo -e "${color}╔════════════════════════════════════════════════════════════════════════════╗${NC}" echo -e "${color}║ ${BOLD}${title}${NC} ${color}${NC}" echo -e "${color}╚════════════════════════════════════════════════════════════════════════════╝${NC}" } # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } # Function to print success message print_success() { local message="$1" echo -e "${GREEN}✓ ${message}${NC}" } # Function to print error message print_error() { local message="$1" echo -e "${RED}✗ ${message}${NC}" } # Function to print warning message print_warning() { local message="$1" echo -e "${YELLOW}⚠ ${message}${NC}" } # Function to print info message print_info() { local message="$1" echo -e "${BLUE}ℹ ${message}${NC}" } # Function to create Python virtual environment create_venv() { local env_dir="$1" local method="$2" case "$method" in 1) # pip if command_exists python3; then print_section "Creating Virtual Environment (pip)" "${BLUE}" show_spinner "Setting up Python virtual environment" 2 python3 -m venv "$env_dir" source "$env_dir/bin/activate" show_spinner "Upgrading pip to latest version" 2 pip install --upgrade pip > /dev/null 2>&1 print_success "Virtual environment created successfully!" else print_error "Python 3 is not installed. Please install Python 3 and try again." exit 1 fi ;; 2) # uv if command_exists uv; then print_section "Creating Virtual Environment (uv)" "${BRIGHT_CYAN}" show_spinner "Setting up Python virtual environment with uv" 2 uv venv "$env_dir" source "$env_dir/bin/activate" print_success "Virtual environment created successfully!" else print_warning "uv is not installed. Falling back to pip..." create_venv "$env_dir" 1 fi ;; 3) # conda if command_exists conda; then print_section "Creating Conda Environment" "${PURPLE}" show_progress "Creating conda environment from environment.yml" 3 conda env create -f environment.yml > /dev/null 2>&1 conda activate mem0-mcp print_success "Conda environment created successfully!" else print_warning "conda is not installed. Falling back to pip..." create_venv "$env_dir" 1 fi ;; *) print_error "Invalid method. Using pip as default." create_venv "$env_dir" 1 ;; esac } # Function to install dependencies install_dependencies() { local method="$1" print_section "Installing Dependencies" "${GRAD6}" case "$method" in 1) # pip show_progress "Installing required packages with pip" 5 pip install -r requirements.txt > /dev/null 2>&1 ;; 2) # uv if command_exists uv; then show_progress "Installing required packages with uv (faster installation)" 4 uv pip install -r requirements.txt > /dev/null 2>&1 else show_progress "Installing required packages with pip" 5 pip install -r requirements.txt > /dev/null 2>&1 fi ;; 3) # conda # Dependencies already installed via environment.yml print_info "Dependencies already installed via environment.yml" return 0 ;; *) show_progress "Installing required packages with pip" 5 pip install -r requirements.txt > /dev/null 2>&1 ;; esac if [ $? -eq 0 ]; then print_success "Dependencies installed successfully!" else print_error "Failed to install dependencies." exit 1 fi } # Function to create activation script create_activation_script() { local env_dir="$1" local method="$2" print_section "Creating Activation Script" "${YELLOW}" show_spinner "Generating activation script" 2 cat > activate_mem0.sh << EOF #!/bin/bash # ✨ mem0 MCP Server Activation ✨ # Made with ❤️ by Pink Pixel echo -e "${GRAD3}✨ Activating mem0 MCP Server environment ✨${NC}" EOF if [ "$method" -eq 3 ]; then echo "conda activate mem0-mcp" >> activate_mem0.sh else echo "source \"$env_dir/bin/activate\"" >> activate_mem0.sh fi chmod +x activate_mem0.sh print_success "Activation script created: activate_mem0.sh" } # Function to display a fancy countdown countdown() { local seconds=$1 local message=${2:-"Starting in"} for (( i=$seconds; i>0; i-- )); do printf "\r${YELLOW}${message} ${BOLD}${i}${NC} second(s)..." sleep 1 done printf "\r${GREEN}${message} now!${NC} \n" } # Main installation process main() { print_header echo -e "${GRAD1}W${GRAD2}e${GRAD3}l${GRAD4}c${GRAD5}o${GRAD6}m${GRAD7}e ${GRAD8}t${GRAD7}o ${GRAD6}t${GRAD5}h${GRAD4}e ${GRAD3}m${GRAD2}e${GRAD1}m${GRAD2}0 ${GRAD3}M${GRAD4}C${GRAD5}P ${GRAD6}S${GRAD7}e${GRAD8}r${GRAD7}v${GRAD6}e${GRAD5}r ${GRAD4}i${GRAD3}n${GRAD2}s${GRAD1}t${GRAD2}a${GRAD3}l${GRAD4}l${GRAD5}e${GRAD6}r${GRAD7}!${NC}" echo -e "${CYAN}This script will set up a Python environment and install all required dependencies.${NC}" echo "" # Check for Python if ! command_exists python3; then print_error "Python 3 is not installed. Please install Python 3 and try again." exit 1 fi # Choose installation method print_section "Installation Method" "${MAGENTA}" echo -e "${GRAD1}Please select your preferred installation method:${NC}" echo -e "${BLUE}1. ${BOLD}pip${NC} ${BLUE}(standard Python package installer)${NC}" echo -e "${BRIGHT_CYAN}2. ${BOLD}uv${NC} ${BRIGHT_CYAN}(faster Python package installer)${NC}" echo -e "${PURPLE}3. ${BOLD}conda${NC} ${PURPLE}(Anaconda package manager)${NC}" echo "" read -p "$(echo -e "${YELLOW}Enter your choice (1-3, default: 1): ${NC}")" method method=${method:-1} # Validate input if [[ ! "$method" =~ ^[1-3]$ ]]; then print_warning "Invalid choice. Using pip as default." method=1 fi # Set environment directory local env_dir=".venv" # Create virtual environment create_venv "$env_dir" "$method" # Install dependencies install_dependencies "$method" # Create activation script create_activation_script "$env_dir" "$method" # Final instructions echo "" echo -e "${GRAD7}╔════════════════════════════════════════════════════════════════════════════╗${NC}" echo -e "${GRAD6}║ ║${NC}" echo -e "${GRAD5}║ ${BOLD}${REVERSE} Installation completed successfully! ${NC}${GRAD5} ║${NC}" echo -e "${GRAD4}║ ║${NC}" echo -e "${GRAD3}╚════════════════════════════════════════════════════════════════════════════╝${NC}" echo "" echo -e "${CYAN}To activate the environment, run:${NC}" echo -e " ${YELLOW}${BOLD}source ./activate_mem0.sh${NC}" echo "" echo -e "${CYAN}To start the server, run:${NC}" echo -e " ${YELLOW}${BOLD}python server.py${NC}" echo "" echo -e "${CYAN}To run the example, run:${NC}" echo -e " ${YELLOW}${BOLD}python auto_memory_example.py${NC}" echo "" echo -e "${PURPLE}Thank you for using mem0 MCP Server!${NC}" echo -e "${GRAD8}Made with ❤️ by Pink Pixel${NC}" # Countdown to auto-activation echo "" countdown 3 "Auto-activating environment in" source ./activate_mem0.sh } # Run the main function main