Make the MCP server port configurable via a flag in the dev command
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -62,6 +62,7 @@ export async function startDevSession({
|
||||
|
||||
if (rawArgs.mcp) {
|
||||
await startMcpServer({
|
||||
port: rawArgs.mcpPort,
|
||||
cliApiClient: client,
|
||||
devSession: {
|
||||
dashboardUrl,
|
||||
|
||||
@@ -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} ✨`);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user