()
| 246 | } |
| 247 | |
| 248 | export async function runClaudeInChromeMcpServer(): Promise<void> { |
| 249 | enableConfigs() |
| 250 | initializeAnalyticsSink() |
| 251 | const context = createChromeContext() |
| 252 | |
| 253 | const server = createClaudeForChromeMcpServer(context) |
| 254 | const transport = new StdioServerTransport() |
| 255 | |
| 256 | // Exit when parent process dies (stdin pipe closes). |
| 257 | // Flush analytics before exiting so final-batch events (e.g. disconnect) aren't lost. |
| 258 | let exiting = false |
| 259 | const shutdownAndExit = async (): Promise<void> => { |
| 260 | if (exiting) { |
| 261 | return |
| 262 | } |
| 263 | exiting = true |
| 264 | await shutdown1PEventLogging() |
| 265 | await shutdownDatadog() |
| 266 | // eslint-disable-next-line custom-rules/no-process-exit |
| 267 | process.exit(0) |
| 268 | } |
| 269 | process.stdin.on('end', () => void shutdownAndExit()) |
| 270 | process.stdin.on('error', () => void shutdownAndExit()) |
| 271 | |
| 272 | logForDebugging('[Claude in Chrome] Starting MCP server') |
| 273 | await server.connect(transport) |
| 274 | logForDebugging('[Claude in Chrome] MCP server started') |
| 275 | } |
| 276 | |
| 277 | class DebugLogger implements Logger { |
| 278 | silly(message: string, ...args: unknown[]): void { |
no test coverage detected