#!/usr/bin/env node
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { createServer } from '../server.js';
import { processManager } from '../lib/processManager.js';
import { browserManager } from '../tools/browser/index.js';
import { dockerManager } from '../tools/docker/index.js';
import { logger } from '../lib/logger.js';
import { config } from '../config.js';
async function main() {
    logger.info(`web-dev-mcp starting over stdio (workspace: ${config.workspaceRoot})`);
    const server = createServer();
    const transport = new StdioServerTransport();
    await server.connect(transport);
    logger.info('web-dev-mcp connected');
}
async function shutdown(signal) {
    logger.info(`received ${signal}, stopping tracked processes, closing browser, and cleaning up containers`);
    processManager.stopAll();
    await browserManager.close();
    await dockerManager.cleanupAll();
    process.exit(0);
}
process.on('SIGINT', () => void shutdown('SIGINT'));
process.on('SIGTERM', () => void shutdown('SIGTERM'));
main().catch((error) => {
    logger.error('fatal error starting server', { error: error instanceof Error ? error.message : error });
    process.exit(1);
});
//# sourceMappingURL=stdio.js.map