/** * sh-mcp-ops entrypoint. * * Builds the app and starts listening. This is the ONLY place a listener is * created — importing any module above is side-effect free (build-plan §2.1). * * A `handler` placeholder is exported for a future Lambda adapter, but this PR * does NOT depend on the AWS Lambda runtime (build-plan §2.2). */ import { buildOpsApp } from './app.js'; export { buildOpsApp } from './app.js'; async function main(): Promise { const { app, config } = await buildOpsApp(); app.listen(config.port, () => { console.log( JSON.stringify({ msg: 'sh-mcp-ops listening', env: config.env, port: config.port, endpoints: ['/mcp', '/openapi.json', 'POST /tools/:name', '/healthz'], }), ); }); } /** * Placeholder Lambda handler shape for a future phase. Intentionally throws — * the HTTP server (`main`) is the supported runtime in Phase 1. */ export function handler(): never { throw new Error('Lambda handler is not implemented in Phase 1; run the HTTP server.'); } // Start only when executed directly (not when imported by tests). const invokedDirectly = process.argv[1] !== undefined && import.meta.url === `file://${process.argv[1]}`; if (invokedDirectly) { main().catch((err: unknown) => { console.error('Failed to start sh-mcp-ops:', err); process.exit(1); }); }