Make the MCP server port configurable via a flag in the dev command

This commit is contained in:
saadi
2025-03-11 14:47:11 +01:00
parent af3af9ca17
commit 2e7b1a7b1c
3 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -21,6 +21,7 @@ const DevCommandOptions = CommonCommandOptions.extend({
keepTmpFiles: z.boolean().default(false),
maxConcurrentRuns: z.coerce.number().optional(),
mcp: z.boolean().default(false),
mcpPort: z.coerce.number().optional().default(3333),
});
export type DevCommandOptions = z.infer<typeof DevCommandOptions>;
@@ -50,7 +51,8 @@ export function configureDevCommand(program: Command) {
"Keep temporary files after the dev session ends, helpful for debugging"
)
// TODO: add a more detailed description, maybe a pointer to the docs on how to use MCP
.option("--mcp", "Run an MCP server")
.option("--mcp", "Start the MCP server")
.option("--mcp-port", "The port to run the MCP server on", "3333")
).action(async (options) => {
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
await devCommand(opts);
+1
View File
@@ -62,6 +62,7 @@ export async function startDevSession({
if (rawArgs.mcp) {
await startMcpServer({
port: rawArgs.mcpPort,
cliApiClient: client,
devSession: {
dashboardUrl,
+3 -4
View File
@@ -145,6 +145,7 @@ app.post("/messages", (req, res) => {
});
export const startMcpServer = async (options: {
port: number;
cliApiClient: CliApiClient;
devSession: {
dashboardUrl: string;
@@ -162,9 +163,7 @@ export const startMcpServer = async (options: {
projectRef = options.devSession.projectRef;
dashboardUrl = options.devSession.dashboardUrl;
// TODO: make the port configurable
const port = 3333;
app.listen(port, () => {
logger.info(`Trigger.dev MCP Server is now running on port ${port}`);
app.listen(options.port, () => {
logger.info(`Trigger.dev MCP Server is now running on port ${options.port}`);
});
};