import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module';
import { LoggerService } from './infrastructure/logging/logger.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
bufferLogs: true,
});
const logger = app.get(LoggerService);
app.useLogger(logger);
logger.setContext('Bootstrap');
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}),
);
const port = process.env.PORT || 3000;
// Only listen on HTTP if not in STDIO mode
if (process.env.MCP_TRANSPORT === 'STDIO') {
await app.init();
logger.log('Application initialized in STDIO mode for MCP');
logger.log('Waiting for MCP client connection...');
} else {
await app.listen(port);
logger.log(`Application is running on: http://localhost:${port}`);
logger.log(`Health check: http://localhost:${port}/health`);
logger.log(`MCP endpoint: http://localhost:${port}/api/mcp`);
}
}
(async () => {
await bootstrap();
})();