Skip to main content
Glama
Om-Shree-0709

GitHub MCP TypeScript SDK Server

setup.js3.1 kB
#!/usr/bin/env node /** * Setup script for GitHub MCP Server * Helps users configure the server with their GitHub token */ import { readFileSync, writeFileSync, existsSync } from "fs"; import { fileURLToPath } from "url"; import { dirname, join } from "path"; import { createInterface } from "readline"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const rl = createInterface({ input: process.stdin, output: process.stdout, }); console.log("🚀 GitHub MCP Server Setup\n"); function question(query) { return new Promise((resolve) => rl.question(query, resolve)); } async function setup() { try { // Check if .env already exists const envPath = join(__dirname, ".env"); if (existsSync(envPath)) { const overwrite = await question( "⚠️ .env file already exists. Overwrite? (y/N): " ); if (overwrite.toLowerCase() !== "y") { console.log("Setup cancelled."); rl.close(); return; } } console.log( "📋 To use this server, you need a GitHub Personal Access Token." ); console.log("🔗 Create one at: https://github.com/settings/tokens\n"); const token = await question("🔑 Enter your GitHub token: "); if (!token.trim()) { console.log("❌ Token is required!"); rl.close(); return; } const username = await question( "👤 Enter your GitHub username (optional): " ); // Create .env file const envContent = `# GitHub MCP Server Configuration GITHUB_TOKEN=${token.trim()} ${username.trim() ? `GITHUB_USERNAME=${username.trim()}` : "# GITHUB_USERNAME=your_username_here"} `; writeFileSync(envPath, envContent); console.log("\n✅ Configuration saved to .env file"); // Test the configuration console.log("\n🧪 Testing configuration..."); // Set environment variables for testing process.env.GITHUB_TOKEN = token.trim(); if (username.trim()) { process.env.GITHUB_USERNAME = username.trim(); } try { const { Octokit } = await import("@octokit/rest"); const octokit = new Octokit({ auth: token.trim() }); const { data } = await octokit.users.getAuthenticated(); console.log(`✅ Successfully authenticated as: ${data.login}`); if (data.login !== username.trim() && username.trim()) { console.log( `⚠️ Warning: Token belongs to ${data.login}, not ${username.trim()}` ); } } catch (error) { console.log("❌ Authentication failed:", error.message); console.log("Please check your token and try again."); rl.close(); return; } console.log("\n🎉 Setup complete!"); console.log("\n📚 Next steps:"); console.log("1. Build the server: npm run build"); console.log("2. Start the server: npm start"); console.log("3. Test the server: npm test"); console.log("\n📖 See README.md for more information."); } catch (error) { console.error("❌ Setup failed:", error.message); } finally { rl.close(); } } setup();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Om-Shree-0709/Github-MCP-Ts-SDK'

If you have feedback or need assistance with the MCP directory API, please join our Discord server