#!/bin/bash # # Start script for Gemini MCP Server # Supports both stdio and HTTP modes # # Default values MODE="stdio" PROJECT_ROOT="." PORT="8006" # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in --mode) MODE="$2" shift 2 ;; --project-root) PROJECT_ROOT="$2" shift 2 ;; --port) PORT="$2" shift 2 ;; --help) echo "Usage: $0 [options]" echo "Options:" echo " --mode Server mode (default: stdio)" echo " --project-root Project root directory (default: .)" echo " --port Port for HTTP mode (default: 8006)" echo " --help Show this help message" exit 0 ;; *) echo "Unknown option: $1" exit 1 ;; esac done # Check if running in container if [ -f /.dockerenv ] || [ -n "$CONTAINER_ENV" ]; then echo "ERROR: Gemini MCP Server cannot run inside a container!" echo "The Gemini CLI requires Docker access and must run on the host system." echo "Please run this script on your host machine." exit 1 fi # Check if Python is available if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then echo "ERROR: Python is not installed or not in PATH" exit 1 fi # Use python3 if available, otherwise python PYTHON_CMD="python" if command -v python3 &> /dev/null; then PYTHON_CMD="python3" fi # Get the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Change to script directory cd "$SCRIPT_DIR" # Start the server echo "Starting Gemini MCP Server..." echo "Mode: $MODE" echo "Project Root: $PROJECT_ROOT" if [ "$MODE" = "http" ]; then echo "Port: $PORT" export UVICORN_PORT=$PORT fi # Run the server exec $PYTHON_CMD gemini_mcp_server.py --mode "$MODE" --project-root "$PROJECT_ROOT"