codemem 0.31.3 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3454,18 +3454,50 @@ function shortAge(iso) {
3454
3454
  }
3455
3455
  //#endregion
3456
3456
  //#region src/commands/mcp.ts
3457
- var mcpCmd = new Command("mcp").configureHelp(helpStyle).description("Start the MCP stdio server");
3457
+ var mcpCmd = new Command("mcp").configureHelp(helpStyle).description("Start an MCP server").summary("Start the MCP stdio server");
3458
3458
  addDbOption(mcpCmd);
3459
+ var mcpHttpCmd = new Command("http").configureHelp(helpStyle).description("Start the MCP Streamable HTTP server").option("--host <host>", "HTTP host").option("--port <port>", "HTTP port").option("--public-url <url>", "public MCP URL used in OAuth metadata").option("--unsafe-public", "allow non-loopback bind without auth");
3460
+ addDbOption(mcpHttpCmd);
3461
+ mcpHttpCmd.action(async () => {
3462
+ const opts = mcpHttpCmd.opts();
3463
+ try {
3464
+ const { startCodememMcpHttpServer } = await import("@codemem/mcp/http");
3465
+ const server = await startCodememMcpHttpServer({
3466
+ dbPath: resolveDbOpt(opts) ?? resolveDbOpt(mcpCmd.opts()),
3467
+ host: opts.host,
3468
+ port: opts.port,
3469
+ allowUnsafePublic: opts.unsafePublic,
3470
+ publicUrl: opts.publicUrl
3471
+ });
3472
+ console.error(`codemem MCP HTTP server listening at ${server.url}`);
3473
+ const shutdown = async () => {
3474
+ try {
3475
+ await server.close();
3476
+ } catch {}
3477
+ process.exit(0);
3478
+ };
3479
+ process.on("SIGINT", shutdown);
3480
+ process.on("SIGTERM", shutdown);
3481
+ } catch (err) {
3482
+ const message = err instanceof Error ? err.message : String(err);
3483
+ console.error(`Failed to start MCP HTTP server: ${message}`);
3484
+ process.exitCode = isMcpHttpUsageError(message) ? 2 : 1;
3485
+ }
3486
+ });
3487
+ mcpCmd.addCommand(mcpHttpCmd);
3459
3488
  var mcpCommand = mcpCmd.action(async (opts) => {
3460
3489
  const dbPath = resolveDbOpt(opts);
3461
3490
  if (dbPath) process.env.CODEMEM_DB = dbPath;
3462
3491
  try {
3463
- await import("@codemem/mcp");
3492
+ await import("@codemem/mcp/stdio");
3464
3493
  } catch (err) {
3465
3494
  console.error(`Failed to start MCP server: ${err instanceof Error ? err.message : String(err)}`);
3466
3495
  process.exitCode = 1;
3467
3496
  }
3468
3497
  });
3498
+ function isMcpHttpUsageError(message) {
3499
+ return message.includes("Invalid MCP HTTP host") || message.includes("Invalid MCP HTTP port") || message.includes("Invalid MCP HTTP public URL") || message.includes("Refusing unsafe MCP HTTP host");
3500
+ }
3469
3501
  //#endregion
3470
3502
  //#region src/commands/pack-shared.ts
3471
3503
  var PackUsageError = class extends Error {