#!/usr/bin/env node
/**
* Quick Start Script for GitHub MCP Server
* This script helps users get up and running quickly
*/
import { config } from "dotenv";
import { existsSync, readFileSync } from "fs";
import { spawn } from "child_process";
import { fileURLToPath } from "url";
import { dirname, join } from "path";
// Load environment variables from .env file
config();
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log("🚀 GitHub MCP Server - Quick Start\n");
// Check if .env exists
const envPath = join(__dirname, ".env");
if (!existsSync(envPath)) {
console.log("⚠️ No .env file found. Please run setup first:");
console.log(" npm run setup\n");
process.exit(1);
}
// Check if dist exists
const distPath = join(__dirname, "dist");
if (!existsSync(distPath)) {
console.log("🔨 Building server...");
const build = spawn("npm", ["run", "build"], { stdio: "inherit" });
build.on("close", (code) => {
if (code === 0) {
console.log("✅ Build successful!");
startServer();
} else {
console.log("❌ Build failed!");
process.exit(1);
}
});
} else {
startServer();
}
function startServer() {
console.log("\n🚀 Starting GitHub MCP Server...\n");
const server = spawn("npm", ["start"], { stdio: "inherit" });
server.on("close", (code) => {
if (code !== 0) {
console.log(`\n❌ Server exited with code ${code}`);
}
});
// Handle Ctrl+C
process.on("SIGINT", () => {
console.log("\n👋 Shutting down server...");
server.kill();
process.exit(0);
});
}