Skip to content

Commit a5ec559

Browse files
committed
Add install mcp prompt to init and dev, and add support for codex-cli with toml config
1 parent e5af3ec commit a5ec559

File tree

8 files changed

+367
-37
lines changed

8 files changed

+367
-37
lines changed

packages/cli-v3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"dependencies": {
8383
"@clack/prompts": "0.11.0",
8484
"@depot/cli": "0.0.1-cli.2.80.0",
85+
"@iarna/toml": "^2.2.5",
8586
"@modelcontextprotocol/sdk": "^1.17.0",
8687
"@opentelemetry/api": "1.9.0",
8788
"@opentelemetry/api-logs": "0.203.0",

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import { runtimeChecks } from "../utilities/runtimeCheck.js";
1313
import { getProjectClient, LoginResultOk } from "../utilities/session.js";
1414
import { login } from "./login.js";
1515
import { updateTriggerPackages } from "./update.js";
16+
import {
17+
readConfigHasSeenMCPInstallPrompt,
18+
writeConfigHasSeenMCPInstallPrompt,
19+
} from "../utilities/configFiles.js";
20+
import { confirm, isCancel, log } from "@clack/prompts";
21+
import { installMcpServer } from "./install-mcp.js";
22+
import { tryCatch } from "@trigger.dev/core/utils";
23+
import { VERSION } from "@trigger.dev/core";
1624

1725
const DevCommandOptions = CommonCommandOptions.extend({
1826
debugOtel: z.boolean().default(false),
@@ -70,6 +78,33 @@ export function configureDevCommand(program: Command) {
7078
export async function devCommand(options: DevCommandOptions) {
7179
runtimeChecks();
7280

81+
const hasSeenMCPInstallPrompt = readConfigHasSeenMCPInstallPrompt();
82+
83+
if (!hasSeenMCPInstallPrompt) {
84+
const installChoice = await confirm({
85+
message: "Would you like to install the Trigger.dev MCP server?",
86+
initialValue: true,
87+
});
88+
89+
const skipInstall = isCancel(installChoice) || !installChoice;
90+
91+
if (!skipInstall) {
92+
log.step("Welcome to the Trigger.dev MCP server install wizard 🧙");
93+
94+
const [installError] = await tryCatch(
95+
installMcpServer({
96+
yolo: false,
97+
tag: VERSION as string,
98+
logLevel: options.logLevel,
99+
})
100+
);
101+
102+
if (installError) {
103+
log.error(`Failed to install MCP server: ${installError.message}`);
104+
}
105+
}
106+
}
107+
73108
const authorization = await login({
74109
embedded: true,
75110
silent: true,

packages/cli-v3/src/commands/init.ts

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { intro, isCancel, log, outro, select, text } from "@clack/prompts";
22
import { context, trace } from "@opentelemetry/api";
3-
import { GetProjectResponseBody, LogLevel, flattenAttributes } from "@trigger.dev/core/v3";
3+
import {
4+
GetProjectResponseBody,
5+
LogLevel,
6+
flattenAttributes,
7+
tryCatch,
8+
} from "@trigger.dev/core/v3";
49
import { recordSpanException } from "@trigger.dev/core/v3/workers";
510
import chalk from "chalk";
611
import { Command, Option as CommandOption } from "commander";
@@ -33,6 +38,11 @@ import { logger } from "../utilities/logger.js";
3338
import { spinner } from "../utilities/windows.js";
3439
import { VERSION } from "../version.js";
3540
import { login } from "./login.js";
41+
import {
42+
readConfigHasSeenMCPInstallPrompt,
43+
writeConfigHasSeenMCPInstallPrompt,
44+
} from "../utilities/configFiles.js";
45+
import { installMcpServer } from "./install-mcp.js";
3646

3747
const cliVersion = VERSION as string;
3848
const cliTag = cliVersion.includes("v4-beta") ? "v4-beta" : "latest";
@@ -108,6 +118,43 @@ async function _initCommand(dir: string, options: InitCommandOptions) {
108118
throw new Error("--project-ref is required when using --yes flag");
109119
}
110120

121+
const hasSeenMCPInstallPrompt = readConfigHasSeenMCPInstallPrompt();
122+
123+
if (!hasSeenMCPInstallPrompt) {
124+
const installChoice = await select({
125+
message: "Choose how you want to initialize your project:",
126+
options: [
127+
{
128+
value: "mcp",
129+
label: "Trigger.dev MCP",
130+
hint: "Automatically install the Trigger.dev MCP server and then vibe your way to a new project.",
131+
},
132+
{ value: "cli", label: "CLI", hint: "Continue with the CLI" },
133+
],
134+
});
135+
136+
const continueWithCLI = isCancel(installChoice) || installChoice === "cli";
137+
138+
if (!continueWithCLI) {
139+
log.step("Welcome to the Trigger.dev MCP server install wizard 🧙");
140+
141+
const [installError] = await tryCatch(
142+
installMcpServer({
143+
yolo: false,
144+
tag: options.tag,
145+
logLevel: options.logLevel,
146+
})
147+
);
148+
149+
if (installError) {
150+
outro(`Failed to install MCP server: ${installError.message}`);
151+
return;
152+
}
153+
154+
return;
155+
}
156+
}
157+
111158
intro("Initializing project");
112159

113160
const cwd = resolve(process.cwd(), dir);
@@ -204,7 +251,7 @@ async function _initCommand(dir: string, options: InitCommandOptions) {
204251
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
205252
);
206253

207-
log.success("Successfully initialized project for Trigger.dev v3 🫡");
254+
log.success("Successfully initialized your Trigger.dev project 🫡");
208255
log.info("Next steps:");
209256
log.info(
210257
` 1. To start developing, run ${chalk.green(

0 commit comments

Comments
 (0)