()
| 136 | // --------------------------------------------------------------------------- |
| 137 | |
| 138 | async function main(): Promise<void> { |
| 139 | await validateSrcRoot(); |
| 140 | |
| 141 | const app = express(); |
| 142 | app.use(express.json()); |
| 143 | app.use(authMiddleware); |
| 144 | |
| 145 | // Health check |
| 146 | app.get("/health", (_req, res) => { |
| 147 | res.json({ |
| 148 | status: "ok", |
| 149 | server: "claude-code-explorer", |
| 150 | version: "1.1.0", |
| 151 | srcRoot: SRC_ROOT, |
| 152 | }); |
| 153 | }); |
| 154 | |
| 155 | // Register both transports |
| 156 | await startStreamableHTTP(app); |
| 157 | await startLegacySSE(app); |
| 158 | |
| 159 | app.listen(PORT, () => { |
| 160 | console.log(`Claude Code Explorer MCP (HTTP) listening on port ${PORT}`); |
| 161 | console.log(` Streamable HTTP: POST/GET http://localhost:${PORT}/mcp`); |
| 162 | console.log(` Legacy SSE: GET http://localhost:${PORT}/sse`); |
| 163 | console.log(` Health: GET http://localhost:${PORT}/health`); |
| 164 | console.log(` Source root: ${SRC_ROOT}`); |
| 165 | if (API_KEY) console.log(" Auth: Bearer token required"); |
| 166 | }); |
| 167 | } |
| 168 | |
| 169 | main().catch((err) => { |
| 170 | console.error("Fatal error:", err); |
no test coverage detected