integration-mcp-server
Version:
Integration MCP Server with YouTrack, Forgejo, and language server capabilities - easy setup for Claude Desktop & VSCode with Windows compatibility
99 lines • 3.41 kB
JavaScript
import { Command } from 'commander';
import { spawn } from 'child_process';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
// ES 모듈에서 __dirname 대체
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const program = new Command();
program
.name('integration-mcp-server')
.description('Integration MCP Server - YouTrack, Forgejo, and more')
.version('1.2.1');
program
.command('start')
.description('Start the MCP server')
.option('-d, --dev', 'Run in development mode')
.option('-p, --port <port>', 'Port to run on (if applicable)')
.action(async (options) => {
console.log('🚀 Starting Integration MCP Server...');
try {
// index.js 파일 경로
const serverPath = join(__dirname, 'index.js');
// Node.js로 MCP 서버 실행
const serverProcess = spawn('node', [serverPath], {
stdio: 'inherit',
env: {
...process.env,
NODE_ENV: options.dev ? 'development' : 'production',
MCP_PORT: options.port || process.env.MCP_PORT,
}
});
serverProcess.on('error', (error) => {
console.error('❌ Failed to start MCP server:', error.message);
process.exit(1);
});
serverProcess.on('exit', (code) => {
if (code !== 0) {
console.error(`❌ MCP server exited with code ${code}`);
process.exit(code || 1);
}
});
// Graceful shutdown
process.on('SIGINT', () => {
console.log('\n🛑 Shutting down MCP server...');
serverProcess.kill('SIGINT');
});
process.on('SIGTERM', () => {
console.log('\n🛑 Shutting down MCP server...');
serverProcess.kill('SIGTERM');
});
}
catch (error) {
console.error('❌ Error starting MCP server:', error);
process.exit(1);
}
});
// 기본 명령어 (start와 동일)
program
.action(async () => {
console.log('🚀 Starting Integration MCP Server...');
try {
// index.js 파일 경로
const serverPath = join(__dirname, 'index.js');
// Node.js로 MCP 서버 실행
const serverProcess = spawn('node', [serverPath], {
stdio: 'inherit',
env: {
...process.env,
NODE_ENV: 'production',
}
});
serverProcess.on('error', (error) => {
console.error('❌ Failed to start MCP server:', error.message);
process.exit(1);
});
serverProcess.on('exit', (code) => {
if (code !== 0) {
console.error(`❌ MCP server exited with code ${code}`);
process.exit(code || 1);
}
});
// Graceful shutdown
process.on('SIGINT', () => {
console.log('\n🛑 Shutting down MCP server...');
serverProcess.kill('SIGINT');
});
process.on('SIGTERM', () => {
console.log('\n🛑 Shutting down MCP server...');
serverProcess.kill('SIGTERM');
});
}
catch (error) {
console.error('❌ Error starting MCP server:', error);
process.exit(1);
}
});
program.parse();
//# sourceMappingURL=cli.js.map