@@ -46,7 +46,6 @@ import {
|
46 | 46 | } from "../tasks/task-registry.maintenance.js"; |
47 | 47 | import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js"; |
48 | 48 | import { resolveGatewayAuth } from "./auth.js"; |
49 | | -import { closeMcpLoopbackServer } from "./mcp-http.js"; |
50 | 49 | import { createGatewayAuxHandlers } from "./server-aux-handlers.js"; |
51 | 50 | import { createChannelManager } from "./server-channels.js"; |
52 | 51 | import { createGatewayCloseHandler, runGatewayClosePrelude } from "./server-close.js"; |
@@ -125,6 +124,11 @@ function getChannelRuntime() {
|
125 | 124 | return cachedChannelRuntime; |
126 | 125 | } |
127 | 126 | |
| 127 | +async function closeMcpLoopbackServerOnDemand(): Promise<void> { |
| 128 | +const { closeMcpLoopbackServer } = await import("./mcp-http.js"); |
| 129 | +await closeMcpLoopbackServer(); |
| 130 | +} |
| 131 | + |
128 | 132 | const logHealth = log.child("health"); |
129 | 133 | const logCron = log.child("cron"); |
130 | 134 | const logReload = log.child("reload"); |
@@ -593,7 +597,7 @@ export async function startGatewayServer(
|
593 | 597 | stopModelPricingRefresh: runtimeState.stopModelPricingRefresh, |
594 | 598 | stopChannelHealthMonitor: () => runtimeState?.channelHealthMonitor?.stop(), |
595 | 599 | clearSecretsRuntimeSnapshot, |
596 | | -closeMcpServer: async () => await closeMcpLoopbackServer(), |
| 600 | +closeMcpServer: closeMcpLoopbackServerOnDemand, |
597 | 601 | }); |
598 | 602 | const { getRuntimeSnapshot, startChannels, startChannel, stopChannel, markChannelLoggedOut } = |
599 | 603 | channelManager; |
|