#!/bin/bash

# GitHub MCP Live Integration Helper Script

set -e

echo "╔═══════════════════════════════════════════════════════════╗"
echo "║  GitHub MCP Server - Setup Helper                       ║"
echo "╚═══════════════════════════════════════════════════════════╝"
echo ""

# Check if ngrok auth token is set
if [ -z "$NGROK_AUTH_TOKEN" ]; then
    echo "⚠️  ngrok auth token not found in environment"
    echo ""
    echo "To fix this:"
    echo "1. Sign up for free ngrok account: https://dashboard.ngrok.com/signup"
    echo "2. Get your auth token: https://dashboard.ngrok.com/get-started/your-authtoken"
    echo "3. Run: export NGROK_AUTH_TOKEN='your_token_here'"
    echo ""
    read -p "Press Enter to continue (you'll be prompted for token)..."
else
    echo "✅ ngrok auth token found in environment"
fi

echo ""
echo "📋 Prerequisites Checklist:"
echo ""
echo "1. GitHub Personal Access Token"
echo "   Create at: https://github.com/settings/tokens/new"
echo "   Scopes needed: repo, admin:repo_hook"
echo ""
echo "2. Test Repository"
echo "   Use any repo you own, or create: gh repo create mcp-test --public"
echo ""
echo "3. ngrok Auth Token (if not set above)"
echo "   Get from: https://dashboard.ngrok.com/get-started/your-authtoken"
echo ""

read -p "Ready to start? (y/n) " -n 1 -r
echo ""

if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Setup cancelled."
    exit 0
fi

echo ""
echo "🚀 Starting GitHub MCP Live Server..."
echo ""

cd "$(dirname "$0")/.."
npx tsx examples/github-server-live.ts
