Skip to content

waitForShutdown

@tsed/cli

Usage ​

typescript
import { waitForShutdown } from "@tsed/cli/src/commands/mcp/utils/waitForShutdown";

See /packages/cli/src/commands/mcp/utils/waitForShutdown.ts.

Overview ​

ts
function waitForShutdown(mode: "stdio" | "streamable-http", stdin?: NodeJS.ReadableStream): Promise<void>;

Description ​

Keep the mcp command pending while the MCP server is running.

The CLI destroys the injector as soon as a command handler resolves. An MCP server keeps answering requests after the connection is established, so the handler must stay pending or every later tool call runs on an empty injector.

  • stdio: resolves when the client closes stdin.
  • streamable-http: never resolves, the HTTP server lives until the process is stopped.

Released under the MIT License.