#!/bin/bash # Start Gemini MCP Server in either stdio or HTTP mode # Default to stdio mode MODE="stdio" # Check for --http flag if [[ "$1" == "--http" ]]; then MODE="http" fi # Set default environment variables if not already set export GEMINI_ENABLED="${GEMINI_ENABLED:-true}" export GEMINI_AUTO_CONSULT="${GEMINI_AUTO_CONSULT:-true}" export GEMINI_CLI_COMMAND="${GEMINI_CLI_COMMAND:-gemini}" export GEMINI_TIMEOUT="${GEMINI_TIMEOUT:-200}" export GEMINI_RATE_LIMIT="${GEMINI_RATE_LIMIT:-2}" export GEMINI_MODEL="${GEMINI_MODEL:-gemini-2.5-flash}" export GEMINI_MCP_PORT="${GEMINI_MCP_PORT:-8006}" export GEMINI_MCP_HOST="${GEMINI_MCP_HOST:-127.0.0.1}" # Show current configuration echo "🤖 Gemini MCP Server Startup" echo "============================" echo "Mode: $MODE" echo "Environment:" echo " GEMINI_ENABLED=$GEMINI_ENABLED" echo " GEMINI_AUTO_CONSULT=$GEMINI_AUTO_CONSULT" echo " GEMINI_CLI_COMMAND=$GEMINI_CLI_COMMAND" echo " GEMINI_MODEL=$GEMINI_MODEL" echo "" if [[ "$MODE" == "http" ]]; then echo "Starting HTTP server on $GEMINI_MCP_HOST:$GEMINI_MCP_PORT..." echo "" # Start HTTP server python3 gemini_mcp_server.py --port $GEMINI_MCP_PORT # If server stops, show how to test it echo "" echo "Server stopped. To test the HTTP server:" echo " curl http://$GEMINI_MCP_HOST:$GEMINI_MCP_PORT/health" echo " curl http://$GEMINI_MCP_HOST:$GEMINI_MCP_PORT/mcp/tools" else echo "stdio mode instructions:" echo "" echo "To use with Claude Code, add this to your MCP settings:" echo "" echo '{' echo ' "mcpServers": {' echo ' "gemini": {' echo ' "command": "python3",' echo " \"args\": [\"$(pwd)/gemini_mcp_server.py\", \"--project-root\", \".\"]," echo " \"cwd\": \"$(pwd)\"," echo ' "env": {' echo ' "GEMINI_ENABLED": "true",' echo ' "GEMINI_AUTO_CONSULT": "true",' echo ' "GEMINI_CLI_COMMAND": "gemini"' echo ' }' echo ' }' echo ' }' echo '}' echo "" echo "Or run directly for testing:" echo " python3 gemini_mcp_server.py --project-root ." echo "" echo "For HTTP mode, run: $0 --http" fi