/** * Acai Code MCP Server - Entry Point * * This is the main entry point for the MCP server. * All functionality is modularized in separate files for better maintainability. */ // Load configuration first import { loadLocalConfigProfile, applyProfileToEnv } from "./config/index.js"; // Load and apply config profile (backward compatibility) const selectedProfile = loadLocalConfigProfile(); applyProfileToEnv(selectedProfile); console.error("[MCP] Server starting in SSE mode. Credentials will be provided per-session via HTTP headers."); // Import core modules import { createMcpServer, createRequestMonitor, toolHandlers, setRegistrationFunctions } from "./server.js"; import { startHttpServer } from "./httpServer.js"; import { startMonitorServer } from "./monitor.js"; // Import registration functions import { registerPrompts } from "./prompts/index.js"; import { registerTools } from "./tools/index.js"; import { registerResources } from "./resources/index.js"; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // IMPORTANT: Set registration functions BEFORE starting HTTP server // Each session creates its own server instance with these functions // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ setRegistrationFunctions({ registerPrompts, registerTools, registerResources }); // Create the shared request monitor (will be applied to each session server) const requestMonitor = createRequestMonitor(); // Create a server instance for retry functionality in the monitor UI const server = createMcpServer(); registerPrompts(server); registerTools(server); registerResources(server); // Start HTTP server for SSE transport // Each session will create its own server instance via createSessionServer() startHttpServer(); // Start monitor server (if not disabled) startMonitorServer(requestMonitor, toolHandlers);