(config: ExecutorMcpToolConfig)
| 379 | // --------------------------------------------------------------------------- |
| 380 | |
| 381 | export const runMcpStdioServer = async (config: ExecutorMcpToolConfig): Promise<void> => { |
| 382 | startIntegrationsRefresh(); |
| 383 | |
| 384 | const requestStateSigningKey = crypto.getRandomValues(new Uint8Array(32)); |
| 385 | const stdio = serveStdio(() => |
| 386 | Effect.runPromise( |
| 387 | buildMcpServer({ |
| 388 | ...config, |
| 389 | appsEnabled: config.restoredAppsEnabled ?? false, |
| 390 | requestStateSigningKey, |
| 391 | requestStatePrincipal: "local", |
| 392 | sessionful: true, |
| 393 | }), |
| 394 | ), |
| 395 | ); |
| 396 | |
| 397 | const waitForExit = () => |
| 398 | new Promise<void>((resolve) => { |
| 399 | const finish = () => { |
| 400 | process.off("SIGINT", finish); |
| 401 | process.off("SIGTERM", finish); |
| 402 | process.stdin.off("end", finish); |
| 403 | process.stdin.off("close", finish); |
| 404 | resolve(); |
| 405 | }; |
| 406 | process.once("SIGINT", finish); |
| 407 | process.once("SIGTERM", finish); |
| 408 | process.stdin.once("end", finish); |
| 409 | process.stdin.once("close", finish); |
| 410 | }); |
| 411 | |
| 412 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: stdio server lifetime uses Promise-based SDK/process APIs and always closes resources |
| 413 | try { |
| 414 | await waitForExit(); |
| 415 | } finally { |
| 416 | await ignoreClose(() => stdio.close()); |
| 417 | } |
| 418 | }; |
no test coverage detected