import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { McpController } from './mcp/mcp.controller';
import { AttendanceService } from './services/attendance.service';
import { GithubService } from './services/github.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Manually create and set up the controller with its dependencies
const attendanceService = new AttendanceService();
const githubService = new GithubService();
const mcpController = new McpController();
// @ts-ignore - Bypass private property access
mcpController.attendanceService = attendanceService;
// @ts-ignore - Bypass private property access
mcpController.githubService = githubService;
// Get the app controller instance and replace it with our manually created one
const appController = app.get(McpController);
Object.assign(appController, mcpController);
// Enable CORS for codex to connect
app.enableCors({
origin: '*',
methods: 'GET, POST, OPTIONS',
allowedHeaders: 'Content-Type',
});
const port = process.env.PORT || 3001;
await app.listen(port, '0.0.0.0');
console.log(`MCP server listening at http://localhost:${port}`);
console.log(`Server is accessible from codex at http://localhost:${port}/mcp`);
}
bootstrap();