Skip to content

Commit 2e7b1a7

Browse files
committed
Make the MCP server port configurable via a flag in the dev command
1 parent af3af9c commit 2e7b1a7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const DevCommandOptions = CommonCommandOptions.extend({
2121
keepTmpFiles: z.boolean().default(false),
2222
maxConcurrentRuns: z.coerce.number().optional(),
2323
mcp: z.boolean().default(false),
24+
mcpPort: z.coerce.number().optional().default(3333),
2425
});
2526

2627
export type DevCommandOptions = z.infer<typeof DevCommandOptions>;
@@ -50,7 +51,8 @@ export function configureDevCommand(program: Command) {
5051
"Keep temporary files after the dev session ends, helpful for debugging"
5152
)
5253
// TODO: add a more detailed description, maybe a pointer to the docs on how to use MCP
53-
.option("--mcp", "Run an MCP server")
54+
.option("--mcp", "Start the MCP server")
55+
.option("--mcp-port", "The port to run the MCP server on", "3333")
5456
).action(async (options) => {
5557
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
5658
await devCommand(opts);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export async function startDevSession({
6262

6363
if (rawArgs.mcp) {
6464
await startMcpServer({
65+
port: rawArgs.mcpPort,
6566
cliApiClient: client,
6667
devSession: {
6768
dashboardUrl,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ app.post("/messages", (req, res) => {
145145
});
146146

147147
export const startMcpServer = async (options: {
148+
port: number;
148149
cliApiClient: CliApiClient;
149150
devSession: {
150151
dashboardUrl: string;
@@ -162,9 +163,7 @@ export const startMcpServer = async (options: {
162163
projectRef = options.devSession.projectRef;
163164
dashboardUrl = options.devSession.dashboardUrl;
164165

165-
// TODO: make the port configurable
166-
const port = 3333;
167-
app.listen(port, () => {
168-
logger.info(`Trigger.dev MCP Server is now running on port ${port} ✨`);
166+
app.listen(options.port, () => {
167+
logger.info(`Trigger.dev MCP Server is now running on port ${options.port} ✨`);
169168
});
170169
};

0 commit comments

Comments
 (0)