Skip to content

Commit 9cd6d40

Browse files
committed
Shut down the MCP server when the dev session stops
1 parent 2e7b1a7 commit 9cd6d40

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/cli-v3/src/dev/devSession.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { logger } from "../utilities/logger.js";
2323
import { clearTmpDirs, EphemeralDirectory, getTmpDir } from "../utilities/tempDirectories.js";
2424
import { startDevOutput } from "./devOutput.js";
2525
import { startWorkerRuntime } from "./devSupervisor.js";
26-
import { startMcpServer } from "./mcpServer.js";
26+
import { startMcpServer, stopMcpServer } from "./mcpServer.js";
2727

2828
export type DevSessionOptions = {
2929
name: string | undefined;
@@ -202,7 +202,7 @@ export async function startDevSession({
202202
stopBundling?.().catch((error) => {});
203203
runtime.shutdown().catch((error) => {});
204204
stopOutput();
205-
// TODO: stop MCP server
205+
stopMcpServer();
206206
},
207207
};
208208
}

packages/cli-v3/src/dev/mcpServer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,9 @@ export const startMcpServer = async (options: {
167167
logger.info(`Trigger.dev MCP Server is now running on port ${options.port} ✨`);
168168
});
169169
};
170+
171+
export const stopMcpServer = () => {
172+
app.server?.close(() => {
173+
logger.info(`Trigger.dev MCP Server is now stopped`);
174+
});
175+
};

0 commit comments

Comments
 (0)