#!/bin/bash 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}╔══════════════════════════════════════╗${NC}" echo -e "${BLUE}║ ${GREEN}Memory Store MCP Server Installer${BLUE} ║${NC}" echo -e "${BLUE}╚══════════════════════════════════════╝${NC}" echo "" # Check if MEM_TOKEN is provided echo -n "Checking MEM_TOKEN... " if [ -z "$MEM_TOKEN" ]; then echo -e "${RED}✗ MISSING${NC}" echo "" echo -e "${RED}Error: MEM_TOKEN environment variable is required${NC}" echo "Usage: MEM_TOKEN=your_github_token curl -fsSL https://install.memory.store | bash" exit 1 else echo -e "${GREEN}✓ OK${NC}" fi # Check if Docker is installed echo -n "Checking Docker Engine... " if ! command -v docker &> /dev/null; then echo -e "${YELLOW}✗ NOT INSTALLED${NC}" echo "" echo -e "${YELLOW}Docker not found. Attempting installation...${NC}" OS=$(uname) if [ "$OS" = "Linux" ]; then curl -fsSL https://get.docker.com | sh elif [ "$OS" = "Darwin" ]; then if command -v brew &> /dev/null; then brew install --cask docker else echo -e "${YELLOW}Homebrew not found. Please install Docker Desktop manually from:${NC}" echo "https://www.docker.com/products/docker-desktop" exit 1 fi open -a Docker || true echo "Please ensure Docker Desktop is running before continuing." else echo -e "${RED}Unsupported OS: $OS${NC}" echo "Please install Docker manually: https://docs.docker.com/get-docker/" exit 1 fi echo -n "Checking Docker Engine... " if ! command -v docker &> /dev/null; then echo -e "${RED}✗ Installation failed${NC}" exit 1 else echo -e "${GREEN}✓ Installed${NC}" fi else echo -e "${GREEN}✓ OK${NC}" fi # Check if Docker daemon is running echo -n "Checking Docker daemon... " if ! docker info &> /dev/null; then echo -e "${RED}✗ NOT RUNNING${NC}" echo "" echo -e "${RED}Error: Docker daemon is not running${NC}" echo "Please start Docker and try again" exit 1 else echo -e "${GREEN}✓ OK${NC}" fi echo "" echo -e "${YELLOW}► Authenticating with GitHub Container Registry...${NC}" echo ${MEM_TOKEN} | docker login ghcr.io -u token --password-stdin > /dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "${RED} ✗ Authentication failed${NC}" echo " Please check your MEM_TOKEN" exit 1 else echo -e "${GREEN} ✓ Authenticated${NC}" fi echo "" echo -e "${YELLOW}► Checking Memory Store image...${NC}" if docker image inspect ghcr.io/julep-ai/mem-mcp-containerd:latest >/dev/null 2>&1; then echo -e "${GREEN} ✓ Image already exists locally${NC}" else echo " Image not found locally, pulling from registry..." echo " This may take a few minutes on first install" docker pull ghcr.io/julep-ai/mem-mcp-containerd:latest if [ $? -ne 0 ]; then echo -e "${RED} ✗ Failed to pull image${NC}" echo " Please check your MEM_TOKEN permissions" exit 1 else echo -e "${GREEN} ✓ Image pulled${NC}" fi fi # Stop and remove existing container if it exists if [ "$(docker ps -aq -f name=mem-mcp)" ]; then echo "" echo -e "${YELLOW}► Cleaning up existing installation...${NC}" docker stop mem-mcp 2>/dev/null || true docker rm mem-mcp 2>/dev/null || true echo -e "${GREEN} ✓ Cleaned${NC}" fi # Optional: Create volume for persistent containerd state # Uncomment if you want data to persist across container recreations # echo "" # echo -e "${YELLOW}► Setting up persistent storage...${NC}" # docker volume create mem-containerd-state 2>/dev/null || true # echo -e "${GREEN} ✓ Storage configured${NC}" echo "" echo -e "${YELLOW}► Starting Memory Store server...${NC}" # docker run \ # --name mem-mcp \ # --privileged \ # --restart unless-stopped \ # -p 6366:8000 \ # ghcr.io/julep-ai/hello-world:latest # # Optional: Add this line for persistent storage across container recreations # # -v mem-containerd-state:/home/rootless/.local/share \ # The container manages its own internal volumes via nerdctl docker run -d \ --name mem-mcp \ --privileged \ -p 6366:8000 \ -e OFFLINE=1 \ -e CONTAINERD_SNAPSHOTTER=native \ -v mem-containerd-store:/home/rootless/.local/share/containerd \ -v mem-buildkit-store:/home/rootless/.local/share/buildkit \ -v "$(pwd)/data:/data" \ ghcr.io/julep-ai/mem-mcp-containerd:latest-offline > /dev/null 2>&1 # --restart unless-stopped \ # Optional: Add this line for persistent storage across container recreations # -v mem-containerd-state:/home/rootless/.local/share \ if [ $? -ne 0 ]; then echo -e "${RED} ✗ Failed to start container${NC}" exit 1 else echo -e "${GREEN} ✓ Container started${NC}" fi # Wait for service to be ready echo "" echo -e "${YELLOW}► Waiting for services to initialize...${NC}" echo -n " " for i in {1..60}; do if curl -s http://localhost:6366/health &> /dev/null; then echo "" echo -e "${GREEN} ✓ Services ready${NC}" break fi # Show progress dots if [ $((i % 10)) -eq 0 ]; then echo -n "." fi sleep 2 done # Check if service is running echo "" if curl -s http://localhost:6366/health &> /dev/null; then echo -e "${GREEN}╔══════════════════════════════════════╗${NC}" echo -e "${GREEN}║ ✅ Installation Successful! ║${NC}" echo -e "${GREEN}╚══════════════════════════════════════╝${NC}" echo "" echo -e "Memory Store is running at: ${BLUE}http://localhost:6366${NC}" echo "" echo -e "${YELLOW}Useful commands:${NC}" echo " View logs: docker logs -f mem-mcp" echo " Stop server: docker stop mem-mcp" echo " Start server: docker start mem-mcp" echo " Uninstall: docker stop mem-mcp && docker rm mem-mcp" echo "" # Try to open browser (works on most systems) if command -v xdg-open &> /dev/null; then xdg-open http://localhost:6366 2>/dev/null || true elif command -v open &> /dev/null; then open http://localhost:6366 2>/dev/null || true fi else echo -e "${YELLOW}╔══════════════════════════════════════╗${NC}" echo -e "${YELLOW}║ ⚠️ Services Still Starting ║${NC}" echo -e "${YELLOW}╚══════════════════════════════════════╝${NC}" echo "" echo "The container needs more time to initialize internal services." echo "" echo "Check status: docker logs mem-mcp" echo "Access at: http://localhost:6366" fi