(reason: McpShutdownReason, error?: unknown)
| 425 | }, |
| 426 | |
| 427 | async shutdown(reason: McpShutdownReason, error?: unknown): Promise<void> { |
| 428 | if (state.shutdownPromise) { |
| 429 | return state.shutdownPromise; |
| 430 | } |
| 431 | |
| 432 | state.shutdownRequested = true; |
| 433 | state.shutdownReason = reason; |
| 434 | const phaseAtShutdown = state.phase; |
| 435 | state.phase = 'shutting-down'; |
| 436 | |
| 437 | state.shutdownPromise = (async (): Promise<void> => { |
| 438 | const snapshot = await buildMcpLifecycleSnapshot({ |
| 439 | phase: phaseAtShutdown, |
| 440 | shutdownReason: state.shutdownReason, |
| 441 | startedAtMs: state.startedAtMs, |
| 442 | commandExecutor: options.commandExecutor, |
| 443 | }); |
| 444 | await options.onShutdown({ |
| 445 | reason, |
| 446 | error, |
| 447 | snapshot, |
| 448 | server: state.server, |
| 449 | }); |
| 450 | state.phase = 'stopped'; |
| 451 | })(); |
| 452 | |
| 453 | return state.shutdownPromise; |
| 454 | }, |
| 455 | }; |
| 456 | |
| 457 | return coordinator; |
nothing calls this directly
no test coverage detected