UNPKG

copilot-mcp-server

Version:

MCP server that integrates with GitHub Copilot to provide code assistance

56 lines (46 loc) 1.52 kB
#!/usr/bin/env node import { config } from 'dotenv'; import { CopilotMCPServer } from './server.js'; import { ServerConfig } from './types.js'; config(); function loadConfig(): ServerConfig { const githubConfig = { token: process.env.GITHUB_TOKEN, appId: process.env.GITHUB_APP_ID, privateKeyPath: process.env.GITHUB_APP_PRIVATE_KEY_PATH, installationId: process.env.GITHUB_INSTALLATION_ID, org: process.env.GITHUB_ORG, }; // Note: We don't check for authentication here as the CopilotClient will auto-detect // GitHub Copilot tokens from the standard config files return { github: githubConfig, logLevel: (process.env.LOG_LEVEL as any) || 'info', debug: process.env.DEBUG === 'true', maxRequestsPerMinute: parseInt(process.env.MAX_REQUESTS_PER_MINUTE || '60'), }; } async function main() { try { const serverConfig = loadConfig(); const server = new CopilotMCPServer(serverConfig); process.on('SIGINT', () => { console.error('Received SIGINT, shutting down gracefully...'); process.exit(0); }); process.on('SIGTERM', () => { console.error('Received SIGTERM, shutting down gracefully...'); process.exit(0); }); await server.start(); } catch (error) { console.error('Failed to start Copilot MCP Server:', error); process.exit(1); } } if (import.meta.url === `file://${process.argv[1]}`) { main().catch((error) => { console.error('Unhandled error:', error); process.exit(1); }); }