This commit addresses several critical issues and improvements: 🔧 Critical Fixes: - Fixed conversation history not being included when using continuation_id in AI-to-AI conversations - Fixed test mock targeting issues preventing proper conversation memory validation - Fixed Docker debug logging functionality with Gemini tools 🐛 Bug Fixes: - Docker compose configuration for proper container command execution - Test mock import targeting from utils.conversation_memory.* to tools.base.* - Version bump to 3.1.0 reflecting significant improvements 🚀 Improvements: - Enhanced Docker environment configuration with comprehensive logging setup - Added cross-tool continuation documentation and examples in README - Improved error handling and validation across all tools - Better logging configuration with LOG_LEVEL environment variable support - Enhanced conversation memory system documentation 🧪 Testing: - Added comprehensive conversation history bug fix tests - Added cross-tool continuation functionality tests - All 132 tests now pass with proper conversation history validation - Improved test coverage for AI-to-AI conversation threading ✨ Code Quality: - Applied black, isort, and ruff formatting across entire codebase - Enhanced inline documentation for conversation memory system - Cleaned up temporary files and improved repository hygiene - Better test descriptions and coverage for critical functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
205 lines
6.9 KiB
Bash
Executable File
205 lines
6.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit on any error, undefined variables, and pipe failures
|
|
set -euo pipefail
|
|
|
|
# Modern Docker setup script for Gemini MCP Server with Redis
|
|
# This script sets up the complete Docker environment including Redis for conversation threading
|
|
|
|
echo "🚀 Setting up Gemini MCP Server with Docker Compose..."
|
|
echo ""
|
|
|
|
# Get the current working directory (absolute path)
|
|
CURRENT_DIR=$(pwd)
|
|
|
|
# Check if .env already exists
|
|
if [ -f .env ]; then
|
|
echo "⚠️ .env file already exists! Updating if needed..."
|
|
echo ""
|
|
else
|
|
# Check if GEMINI_API_KEY is already set in environment
|
|
if [ -n "$GEMINI_API_KEY" ]; then
|
|
API_KEY_VALUE="$GEMINI_API_KEY"
|
|
echo "✅ Found existing GEMINI_API_KEY in environment"
|
|
else
|
|
API_KEY_VALUE="your-gemini-api-key-here"
|
|
fi
|
|
|
|
# Create the .env file
|
|
cat > .env << EOF
|
|
# Gemini MCP Server Docker Environment Configuration
|
|
# Generated on $(date)
|
|
|
|
# Your Gemini API key (get one from https://makersuite.google.com/app/apikey)
|
|
# IMPORTANT: Replace this with your actual API key
|
|
GEMINI_API_KEY=$API_KEY_VALUE
|
|
|
|
# Redis configuration (automatically set for Docker Compose)
|
|
REDIS_URL=redis://redis:6379/0
|
|
|
|
# Workspace root - host path that maps to /workspace in container
|
|
# This should be the host directory path that contains all files Claude might reference
|
|
# We use $HOME (not $PWD) because Claude needs access to ANY absolute file path,
|
|
# not just files within the current project directory. Additionally, Claude Code
|
|
# could be running from multiple locations at the same time.
|
|
WORKSPACE_ROOT=$HOME
|
|
|
|
# Logging level (DEBUG, INFO, WARNING, ERROR)
|
|
# DEBUG: Shows detailed operational messages, conversation threading, tool execution flow
|
|
# INFO: Shows general operational messages (default)
|
|
# WARNING: Shows only warnings and errors
|
|
# ERROR: Shows only errors
|
|
# Uncomment and change to DEBUG if you need detailed troubleshooting information
|
|
LOG_LEVEL=INFO
|
|
EOF
|
|
echo "✅ Created .env file with Redis configuration"
|
|
echo ""
|
|
fi
|
|
|
|
# Check if Docker and Docker Compose are installed
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "❌ Docker is not installed. Please install Docker first."
|
|
echo " Visit: https://docs.docker.com/get-docker/"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
|
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
|
echo " Visit: https://docs.docker.com/compose/install/"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if Docker daemon is running
|
|
if ! docker info &> /dev/null; then
|
|
echo "❌ Docker daemon is not running. Please start Docker."
|
|
exit 1
|
|
fi
|
|
|
|
# Use modern docker compose syntax if available, fall back to docker-compose
|
|
COMPOSE_CMD="docker compose"
|
|
if ! docker compose version &> /dev/null; then
|
|
COMPOSE_CMD="docker-compose"
|
|
fi
|
|
|
|
echo "🛠️ Building and starting services..."
|
|
echo ""
|
|
|
|
# Stop and remove existing containers
|
|
echo " - Stopping existing containers..."
|
|
$COMPOSE_CMD down --remove-orphans >/dev/null 2>&1 || true
|
|
|
|
# Clean up any old containers with different naming patterns
|
|
OLD_CONTAINERS_FOUND=false
|
|
|
|
# Check for old Gemini MCP container
|
|
if docker ps -a --format "{{.Names}}" | grep -q "^gemini-mcp-server-gemini-mcp-1$" 2>/dev/null || false; then
|
|
OLD_CONTAINERS_FOUND=true
|
|
echo " - Cleaning up old container: gemini-mcp-server-gemini-mcp-1"
|
|
docker stop gemini-mcp-server-gemini-mcp-1 >/dev/null 2>&1 || true
|
|
docker rm gemini-mcp-server-gemini-mcp-1 >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Check for old Redis container
|
|
if docker ps -a --format "{{.Names}}" | grep -q "^gemini-mcp-server-redis-1$" 2>/dev/null || false; then
|
|
OLD_CONTAINERS_FOUND=true
|
|
echo " - Cleaning up old container: gemini-mcp-server-redis-1"
|
|
docker stop gemini-mcp-server-redis-1 >/dev/null 2>&1 || true
|
|
docker rm gemini-mcp-server-redis-1 >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Check for old image
|
|
if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^gemini-mcp-server-gemini-mcp:latest$" 2>/dev/null || false; then
|
|
OLD_CONTAINERS_FOUND=true
|
|
echo " - Cleaning up old image: gemini-mcp-server-gemini-mcp:latest"
|
|
docker rmi gemini-mcp-server-gemini-mcp:latest >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Only show cleanup messages if something was actually cleaned up
|
|
|
|
# Build and start services
|
|
echo " - Building Gemini MCP Server image..."
|
|
if $COMPOSE_CMD build --no-cache >/dev/null 2>&1; then
|
|
echo "✅ Docker image built successfully!"
|
|
else
|
|
echo "❌ Failed to build Docker image. Run '$COMPOSE_CMD build' manually to see errors."
|
|
exit 1
|
|
fi
|
|
|
|
echo " - Starting Redis and MCP services..."
|
|
if $COMPOSE_CMD up -d >/dev/null 2>&1; then
|
|
echo "✅ Services started successfully!"
|
|
else
|
|
echo "❌ Failed to start services. Run '$COMPOSE_CMD up -d' manually to see errors."
|
|
exit 1
|
|
fi
|
|
|
|
# Wait for services to be healthy
|
|
echo " - Waiting for Redis to be ready..."
|
|
sleep 3
|
|
|
|
# Check service status
|
|
if $COMPOSE_CMD ps --format table | grep -q "Up" 2>/dev/null || false; then
|
|
echo "✅ All services are running!"
|
|
else
|
|
echo "⚠️ Some services may not be running. Check with: $COMPOSE_CMD ps"
|
|
fi
|
|
|
|
echo ""
|
|
echo "📋 Service Status:"
|
|
$COMPOSE_CMD ps --format table
|
|
|
|
echo ""
|
|
echo "🔄 Next steps:"
|
|
if grep -q "your-gemini-api-key-here" .env 2>/dev/null || false; then
|
|
echo "1. Edit .env and replace 'your-gemini-api-key-here' with your actual Gemini API key"
|
|
echo "2. Restart services: $COMPOSE_CMD restart"
|
|
echo "3. Copy the configuration below to your Claude Desktop config:"
|
|
else
|
|
echo "1. Copy the configuration below to your Claude Desktop config:"
|
|
fi
|
|
|
|
echo ""
|
|
echo "===== CLAUDE DESKTOP CONFIGURATION ====="
|
|
echo "{"
|
|
echo " \"mcpServers\": {"
|
|
echo " \"gemini\": {"
|
|
echo " \"command\": \"docker\","
|
|
echo " \"args\": ["
|
|
echo " \"exec\","
|
|
echo " \"-i\","
|
|
echo " \"gemini-mcp-server\","
|
|
echo " \"python\","
|
|
echo " \"server.py\""
|
|
echo " ]"
|
|
echo " }"
|
|
echo " }"
|
|
echo "}"
|
|
echo "==========================================="
|
|
echo ""
|
|
echo "===== CLAUDE CODE CLI CONFIGURATION ====="
|
|
echo "# Add the MCP server via Claude Code CLI:"
|
|
echo "claude mcp add gemini -s user -- docker exec -i gemini-mcp-server python server.py"
|
|
echo ""
|
|
echo "# List your MCP servers to verify:"
|
|
echo "claude mcp list"
|
|
echo ""
|
|
echo "# Remove if needed:"
|
|
echo "claude mcp remove gemini"
|
|
echo "==========================================="
|
|
echo ""
|
|
|
|
echo "📁 Config file locations:"
|
|
echo " macOS: ~/Library/Application Support/Claude/claude_desktop_config.json"
|
|
echo ' Windows (WSL): /mnt/c/Users/USERNAME/AppData/Roaming/Claude/claude_desktop_config.json'
|
|
echo ""
|
|
|
|
echo "🔧 Useful commands:"
|
|
echo " Start services: $COMPOSE_CMD up -d"
|
|
echo " Stop services: $COMPOSE_CMD down"
|
|
echo " View logs: $COMPOSE_CMD logs -f"
|
|
echo " Restart services: $COMPOSE_CMD restart"
|
|
echo " Service status: $COMPOSE_CMD ps"
|
|
echo ""
|
|
|
|
echo "🗃️ Redis for conversation threading is automatically configured and running!"
|
|
echo " All AI-to-AI conversations will persist between requests." |