Skip to main content
Glama
Om-Shree-0709

GitHub MCP TypeScript SDK Server

setup-cursor.jsβ€’4.76 kB
#!/usr/bin/env node /** * Setup script to configure Cursor with the GitHub MCP Server */ import { config } from "dotenv"; import { existsSync, writeFileSync, mkdirSync, readFileSync } from "fs"; import { fileURLToPath } from "url"; import { dirname, join } from "path"; import { homedir } from "os"; // Load environment variables config(); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); console.log("πŸ”§ Setting up GitHub MCP Server for Cursor\n"); // Get the current project path const projectPath = __dirname; const serverPath = join(projectPath, "dist", "server.js"); console.log("πŸ“ Project path:", projectPath); console.log("πŸš€ Server path:", serverPath); // Check if server exists if (!existsSync(serverPath)) { console.error("❌ Server not found! Please run 'npm run build' first."); process.exit(1); } // Check if .env exists const envPath = join(projectPath, ".env"); if (!existsSync(envPath)) { console.error("❌ .env file not found! Please run 'npm run setup' first."); process.exit(1); } // Read .env file const envContent = readFileSync(envPath, "utf8"); const githubToken = envContent.match(/GITHUB_TOKEN=(.+)/)?.[1]; const githubUsername = envContent.match(/GITHUB_USERNAME=(.+)/)?.[1]; if (!githubToken) { console.error("❌ GITHUB_TOKEN not found in .env file!"); process.exit(1); } console.log("βœ… Found GitHub token and username"); // Cursor MCP configuration paths for different OS const os = process.platform; let cursorConfigPath; switch (os) { case "win32": cursorConfigPath = join( homedir(), "AppData", "Roaming", "Cursor", "User", "globalStorage", "cursor.mcp" ); break; case "darwin": cursorConfigPath = join( homedir(), "Library", "Application Support", "Cursor", "User", "globalStorage", "cursor.mcp" ); break; case "linux": cursorConfigPath = join( homedir(), ".config", "Cursor", "User", "globalStorage", "cursor.mcp" ); break; default: console.error("❌ Unsupported operating system:", os); process.exit(1); } console.log("πŸ“‚ Cursor config directory:", cursorConfigPath); // Create directory if it doesn't exist if (!existsSync(cursorConfigPath)) { console.log("πŸ“ Creating Cursor MCP directory..."); mkdirSync(cursorConfigPath, { recursive: true }); } const configFilePath = join(cursorConfigPath, "config.json"); // MCP configuration const mcpConfig = { mcpServers: { "github-mcp": { command: "node", args: [serverPath], cwd: projectPath, env: { GITHUB_TOKEN: githubToken, ...(githubUsername && { GITHUB_USERNAME: githubUsername }), }, }, }, }; // Check if config file already exists let existingConfig = {}; if (existsSync(configFilePath)) { try { const existingContent = readFileSync(configFilePath, "utf8"); existingConfig = JSON.parse(existingContent); console.log("πŸ“‹ Found existing Cursor MCP configuration"); } catch (error) { console.log("⚠️ Existing config file is invalid, will overwrite"); } } // Merge configurations const finalConfig = { ...existingConfig, mcpServers: { ...existingConfig.mcpServers, ...mcpConfig.mcpServers, }, }; // Write configuration try { writeFileSync(configFilePath, JSON.stringify(finalConfig, null, 2)); console.log("βœ… Cursor MCP configuration updated successfully!"); console.log("πŸ“„ Config file:", configFilePath); } catch (error) { console.error("❌ Failed to write configuration:", error.message); process.exit(1); } console.log("\nπŸŽ‰ Setup Complete!"); console.log("\nπŸ“‹ Configuration Summary:"); console.log("β€’ Server: github-mcp"); console.log("β€’ Command: node"); console.log("β€’ Path:", serverPath); console.log("β€’ Working Directory:", projectPath); console.log("β€’ GitHub Token: βœ… Configured"); if (githubUsername) { console.log("β€’ GitHub Username: βœ…", githubUsername); } console.log("\nπŸ”„ Next Steps:"); console.log("1. Restart Cursor IDE"); console.log("2. Open the MCP panel in Cursor"); console.log("3. You should see 'github-mcp' server listed"); console.log("4. Start using GitHub tools in Cursor!"); console.log("\n🎯 Example Usage in Cursor:"); console.log("β€’ Ask: 'Show me information about the VS Code repository'"); console.log("β€’ Ask: 'What are the open issues in React?'"); console.log("β€’ Ask: 'Get my GitHub statistics'"); console.log("β€’ Ask: 'Search for TypeScript repositories'"); console.log("\nπŸ“– For more details, see cursor-setup.md"); console.log( "πŸ› οΈ For troubleshooting, run 'npm run simple-test' to verify server works" );

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