Skip to content

Commit 428b2e9

Browse files
committed
fix(mcp): import checkbox lazily in pickClients
A top-level import of @inquirer/prompts is resolved at module load, which breaks integration tests that mock the module with a partial shape omitting checkbox. Defer it to call-time like doctor/update already do.
1 parent 89db039 commit 428b2e9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/cli-core/src/commands/mcp/shared.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Shared options and helpers for `clerk mcp` subcommands.
33
*/
44

5-
import { checkbox } from "@inquirer/prompts";
65
import { ttyContext } from "../../lib/listage.ts";
76
import { getMcpUrl } from "../../lib/environment.ts";
87
import { CliError, ERROR_CODE, errorMessage, throwUsageError } from "../../lib/errors.ts";
@@ -71,6 +70,10 @@ export function resolveClients(ids: readonly string[]): McpClient[] {
7170
export async function pickClients(detected: McpClient[]): Promise<McpClient[]> {
7271
if (detected.length === 0) return [];
7372
if (detected.length === 1) return detected;
73+
// Imported lazily (like `doctor`/`update` do): a top-level import of
74+
// `@inquirer/prompts` is resolved at module load, which breaks tests that
75+
// mock the module with a partial shape that omits `checkbox`.
76+
const { checkbox } = await import("@inquirer/prompts");
7477
const tty = ttyContext();
7578
try {
7679
const selected = await checkbox<ClientId>(

0 commit comments

Comments
 (0)