Support for Gemini CLI (setup instructions) - WIP

This commit is contained in:
Fahad
2025-06-25 19:36:09 +04:00
parent 9c1503faac
commit 6d0bafa81d
7 changed files with 276 additions and 83 deletions

View File

@@ -1298,11 +1298,108 @@ EOF
fi
}
# Check and update Gemini CLI configuration
check_gemini_cli_integration() {
local script_dir="$1"
local zen_wrapper="$script_dir/zen-mcp-server"
# Check if Gemini settings file exists
local gemini_config="$HOME/.gemini/settings.json"
if [[ ! -f "$gemini_config" ]]; then
# Gemini CLI not installed or not configured
return 0
fi
# Check if zen is already configured
if grep -q '"zen"' "$gemini_config" 2>/dev/null; then
# Already configured
return 0
fi
# Ask user if they want to add Zen to Gemini CLI
echo ""
read -p "Configure Zen for Gemini CLI? (Y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Nn]$ ]]; then
print_info "Skipping Gemini CLI integration"
return 0
fi
# Ensure wrapper script exists
if [[ ! -f "$zen_wrapper" ]]; then
print_info "Creating wrapper script for Gemini CLI..."
cat > "$zen_wrapper" << 'EOF'
#!/bin/bash
# Wrapper script for Gemini CLI compatibility
DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DIR"
exec .zen_venv/bin/python server.py "$@"
EOF
chmod +x "$zen_wrapper"
print_success "Created zen-mcp-server wrapper script"
fi
# Update Gemini settings
print_info "Updating Gemini CLI configuration..."
# Create backup
cp "$gemini_config" "${gemini_config}.backup_$(date +%Y%m%d_%H%M%S)"
# Add zen configuration using Python for proper JSON handling
local temp_file=$(mktemp)
python3 -c "
import json
import sys
try:
with open('$gemini_config', 'r') as f:
config = json.load(f)
# Ensure mcpServers exists
if 'mcpServers' not in config:
config['mcpServers'] = {}
# Add zen server
config['mcpServers']['zen'] = {
'command': '$zen_wrapper'
}
with open('$temp_file', 'w') as f:
json.dump(config, f, indent=2)
except Exception as e:
print(f'Error processing config: {e}', file=sys.stderr)
sys.exit(1)
" && mv "$temp_file" "$gemini_config"
if [[ $? -eq 0 ]]; then
print_success "Successfully configured Gemini CLI"
echo " Config: $gemini_config"
echo " Restart Gemini CLI to use Zen MCP Server"
else
print_error "Failed to update Gemini CLI config"
echo "Manual config location: $gemini_config"
echo "Add this configuration:"
cat << EOF
{
"mcpServers": {
"zen": {
"command": "$zen_wrapper"
}
}
}
EOF
fi
}
# Display configuration instructions
display_config_instructions() {
local python_cmd="$1"
local server_path="$2"
# Get script directory for Gemini CLI config
local script_dir=$(dirname "$server_path")
echo ""
local config_header="ZEN MCP SERVER CONFIGURATION"
echo "===== $config_header ====="
@@ -1340,6 +1437,20 @@ EOF
echo ""
print_info "3. Restart Claude Desktop after updating the config file"
echo ""
print_info "For Gemini CLI:"
echo " Add this configuration to ~/.gemini/settings.json:"
echo ""
cat << EOF
{
"mcpServers": {
"zen": {
"command": "$script_dir/zen-mcp-server"
}
}
}
EOF
echo ""
}
# Display setup instructions
@@ -1509,7 +1620,10 @@ main() {
check_claude_cli_integration "$python_cmd" "$server_path"
check_claude_desktop_integration "$python_cmd" "$server_path"
# Step 10: Display log information
# Step 10: Check Gemini CLI integration
check_gemini_cli_integration "$script_dir"
# Step 11: Display log information
echo ""
echo "Logs will be written to: $script_dir/$LOG_DIR/$LOG_FILE"
echo ""
@@ -1522,7 +1636,7 @@ main() {
echo "To show config: ./run-server.sh -c"
echo "To update: git pull, then run ./run-server.sh again"
echo ""
echo "Happy Clauding! 🎉"
echo "Happy coding! 🎉"
fi
}