#!/usr/bin/env node
import { RobustUmbrellaMcpServer } from './robust-server.js';
import dotenv from 'dotenv';
// Load environment variables
dotenv.config();
// Simple error logging to file
const logError = (message: string) => {
const timestamp = new Date().toISOString();
console.error(`[${timestamp}] ${message}`);
// Also try to write to a simple error log
try {
const fs = require('fs');
fs.appendFileSync('mcp-startup.log', `[${timestamp}] ${message}\n`);
} catch (e) {
// Ignore file write errors
}
};
// Get the base URL from environment variables
const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1';
logError('=== Starting Robust MCP Server ===');
logError(`Base URL: ${baseURL}`);
// Handle startup errors more gracefully
process.on('unhandledRejection', (reason, promise) => {
logError(`Unhandled Rejection: ${reason}`);
// Don't exit, let the server try to continue
});
process.on('uncaughtException', (error) => {
logError(`Uncaught Exception: ${error.message}`);
logError(`Stack: ${error.stack}`);
// Exit after logging
process.exit(1);
});
try {
logError('Creating server instance...');
const server = new RobustUmbrellaMcpServer(baseURL);
logError('Starting server...');
server.run().catch((error) => {
logError(`Failed to start server: ${error.message}`);
logError(`Stack: ${error.stack}`);
process.exit(1);
});
} catch (error: any) {
logError(`Failed to create server: ${error.message}`);
logError(`Stack: ${error.stack}`);
process.exit(1);
}