@alcyone-labs/arg-parser 2.2.0 → 2.2.1

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.
Files changed (38) hide show
  1. package/README.md +97 -17
  2. package/dist/config/ConfigurationManager.d.ts.map +1 -1
  3. package/dist/config/plugins/ConfigPlugin.d.ts.map +1 -1
  4. package/dist/config/plugins/ConfigPluginRegistry.d.ts +1 -1
  5. package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +1 -1
  6. package/dist/config/plugins/TomlConfigPlugin.d.ts +1 -1
  7. package/dist/config/plugins/TomlConfigPlugin.d.ts.map +1 -1
  8. package/dist/config/plugins/YamlConfigPlugin.d.ts +1 -1
  9. package/dist/config/plugins/YamlConfigPlugin.d.ts.map +1 -1
  10. package/dist/config/plugins/index.d.ts +4 -4
  11. package/dist/config/plugins/index.d.ts.map +1 -1
  12. package/dist/core/ArgParser.d.ts +14 -3
  13. package/dist/core/ArgParser.d.ts.map +1 -1
  14. package/dist/core/ArgParserBase.d.ts.map +1 -1
  15. package/dist/core/log-path-utils.d.ts +59 -0
  16. package/dist/core/log-path-utils.d.ts.map +1 -0
  17. package/dist/core/types.d.ts +1 -1
  18. package/dist/core/types.d.ts.map +1 -1
  19. package/dist/dxt/DxtGenerator.d.ts +4 -0
  20. package/dist/dxt/DxtGenerator.d.ts.map +1 -1
  21. package/dist/index.cjs +722 -168
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.ts +5 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.min.mjs +4232 -3738
  26. package/dist/index.min.mjs.map +1 -1
  27. package/dist/index.mjs +722 -168
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/mcp/ArgParserMcp.d.ts.map +1 -1
  30. package/dist/mcp/mcp-notifications.d.ts +4 -4
  31. package/dist/mcp/mcp-notifications.d.ts.map +1 -1
  32. package/dist/mcp/mcp-prompts.d.ts.map +1 -1
  33. package/dist/mcp/mcp-protocol-versions.d.ts +11 -11
  34. package/dist/mcp/mcp-protocol-versions.d.ts.map +1 -1
  35. package/dist/mcp/mcp-resources.d.ts.map +1 -1
  36. package/dist/testing/fuzzy-test-cli.d.ts.map +1 -1
  37. package/dist/testing/fuzzy-tester.d.ts.map +1 -1
  38. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -325,7 +325,9 @@ class JsonConfigPlugin extends ConfigPlugin {
325
325
  const { _meta, ...config } = parsed;
326
326
  return config;
327
327
  } catch (error) {
328
- throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`);
328
+ throw new Error(
329
+ `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`
330
+ );
329
331
  }
330
332
  }
331
333
  generate(_config, flags, parsedArgs) {
@@ -541,7 +543,9 @@ function enableConfigPlugins(pluginNames) {
541
543
  globalConfigPluginRegistry.registerPlugin(tomlPlugin);
542
544
  }
543
545
  } catch (error) {
544
- console.warn(`Failed to enable TOML plugin: ${error instanceof Error ? error.message : String(error)}`);
546
+ console.warn(
547
+ `Failed to enable TOML plugin: ${error instanceof Error ? error.message : String(error)}`
548
+ );
545
549
  }
546
550
  break;
547
551
  case "yaml":
@@ -552,7 +556,9 @@ function enableConfigPlugins(pluginNames) {
552
556
  globalConfigPluginRegistry.registerPlugin(yamlPlugin);
553
557
  }
554
558
  } catch (error) {
555
- console.warn(`Failed to enable YAML plugin: ${error instanceof Error ? error.message : String(error)}`);
559
+ console.warn(
560
+ `Failed to enable YAML plugin: ${error instanceof Error ? error.message : String(error)}`
561
+ );
556
562
  }
557
563
  break;
558
564
  default:
@@ -576,14 +582,18 @@ class ConfigurationManager {
576
582
  } else if (appName && appName !== "Argument Parser") {
577
583
  baseName = appName;
578
584
  }
579
- baseName = baseName.split(/[\s-_]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
585
+ baseName = baseName.split(/[\s-_]+/).map(
586
+ (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
587
+ ).join("");
580
588
  return `${baseName}.env`;
581
589
  }
582
590
  /**
583
591
  * Handles the --s-save-to-env system flag at the final parser level
584
592
  */
585
593
  handleSaveToEnvFlag(processArgs, parserChain) {
586
- const saveToEnvIndex = processArgs.findIndex((arg) => arg === "--s-save-to-env");
594
+ const saveToEnvIndex = processArgs.findIndex(
595
+ (arg) => arg === "--s-save-to-env"
596
+ );
587
597
  if (saveToEnvIndex !== -1) {
588
598
  let filePath;
589
599
  if (saveToEnvIndex + 1 < processArgs.length) {
@@ -609,7 +619,11 @@ class ConfigurationManager {
609
619
  const finalParser = parserChain[parserChain.length - 1];
610
620
  const parsedArgs = finalParser.getLastParseResult();
611
621
  if (!parsedArgs) {
612
- console.log(simpleChalk.yellow("No parsed arguments available. Run the command first to generate configuration."));
622
+ console.log(
623
+ simpleChalk.yellow(
624
+ "No parsed arguments available. Run the command first to generate configuration."
625
+ )
626
+ );
613
627
  return;
614
628
  }
615
629
  const allFlags = [];
@@ -642,10 +656,18 @@ class ConfigurationManager {
642
656
  fs__namespace.writeFileSync(filePath, content, "utf8");
643
657
  console.log(simpleChalk.green(`✅ Configuration saved to: ${filePath}`));
644
658
  console.log(simpleChalk.gray(`Format: ${ext || ".env"}`));
645
- console.log(simpleChalk.gray(`Flags saved: ${Object.keys(parsedArgs.args).length}`));
659
+ console.log(
660
+ simpleChalk.gray(`Flags saved: ${Object.keys(parsedArgs.args).length}`)
661
+ );
646
662
  } catch (error) {
647
- console.error(simpleChalk.red(`❌ Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`));
648
- throw new Error(`Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`);
663
+ console.error(
664
+ simpleChalk.red(
665
+ `❌ Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`
666
+ )
667
+ );
668
+ throw new Error(
669
+ `Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`
670
+ );
649
671
  }
650
672
  }
651
673
  /**
@@ -682,7 +704,11 @@ class ConfigurationManager {
682
704
  }
683
705
  return this.convertConfigToFlagValues(rawConfig, parserChain);
684
706
  } catch (error) {
685
- console.warn(simpleChalk.yellow(`Warning: Could not load config file ${filePath}: ${error instanceof Error ? error.message : String(error)}`));
707
+ console.warn(
708
+ simpleChalk.yellow(
709
+ `Warning: Could not load config file ${filePath}: ${error instanceof Error ? error.message : String(error)}`
710
+ )
711
+ );
686
712
  return {};
687
713
  }
688
714
  }
@@ -716,7 +742,9 @@ class ConfigurationManager {
716
742
  if (plugin) {
717
743
  return plugin.parse(content);
718
744
  }
719
- console.warn("YAML plugin not available, using simple parser. Install js-yaml and enable YAML plugin for full support.");
745
+ console.warn(
746
+ "YAML plugin not available, using simple parser. Install js-yaml and enable YAML plugin for full support."
747
+ );
720
748
  const config = {};
721
749
  const lines = content.split("\n");
722
750
  let currentKey = null;
@@ -767,7 +795,9 @@ class ConfigurationManager {
767
795
  try {
768
796
  return JSON.parse(content) || {};
769
797
  } catch (error) {
770
- throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`);
798
+ throw new Error(
799
+ `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`
800
+ );
771
801
  }
772
802
  }
773
803
  /**
@@ -778,7 +808,9 @@ class ConfigurationManager {
778
808
  if (plugin) {
779
809
  return plugin.parse(content);
780
810
  }
781
- console.warn("TOML plugin not available, using simple parser. Install smol-toml and enable TOML plugin for full support.");
811
+ console.warn(
812
+ "TOML plugin not available, using simple parser. Install smol-toml and enable TOML plugin for full support."
813
+ );
782
814
  const config = {};
783
815
  const lines = content.split("\n");
784
816
  for (const line of lines) {
@@ -809,13 +841,19 @@ class ConfigurationManager {
809
841
  for (const [key, value] of Object.entries(rawConfig)) {
810
842
  let flag = allFlags.find((f) => f["name"] === key);
811
843
  if (!flag) {
812
- flag = allFlags.find((f) => f["name"].toLowerCase() === key.toLowerCase());
844
+ flag = allFlags.find(
845
+ (f) => f["name"].toLowerCase() === key.toLowerCase()
846
+ );
813
847
  }
814
848
  if (flag) {
815
849
  try {
816
850
  flagValues[flag["name"]] = this.convertValueToFlagType(value, flag);
817
851
  } catch (error) {
818
- console.warn(simpleChalk.yellow(`Warning: Could not convert config value for flag '${key}': ${error instanceof Error ? error.message : String(error)}`));
852
+ console.warn(
853
+ simpleChalk.yellow(
854
+ `Warning: Could not convert config value for flag '${key}': ${error instanceof Error ? error.message : String(error)}`
855
+ )
856
+ );
819
857
  }
820
858
  }
821
859
  }
@@ -852,17 +890,23 @@ class ConfigurationManager {
852
890
  }
853
891
  const num = Number(value);
854
892
  if (isNaN(num)) {
855
- throw new Error(`Cannot convert '${value}' to number for flag '${flag["name"]}'`);
893
+ throw new Error(
894
+ `Cannot convert '${value}' to number for flag '${flag["name"]}'`
895
+ );
856
896
  }
857
897
  return num;
858
898
  } else if (isBooleanType) {
859
899
  if (typeof value === "boolean") return value;
860
900
  if (typeof value === "string") {
861
901
  const lower = value.toLowerCase();
862
- if (lower === "true" || lower === "1" || lower === "yes" || lower === "on") return true;
863
- if (lower === "false" || lower === "0" || lower === "no" || lower === "off") return false;
902
+ if (lower === "true" || lower === "1" || lower === "yes" || lower === "on")
903
+ return true;
904
+ if (lower === "false" || lower === "0" || lower === "no" || lower === "off")
905
+ return false;
864
906
  }
865
- throw new Error(`Cannot convert '${value}' to boolean for flag '${flag["name"]}'`);
907
+ throw new Error(
908
+ `Cannot convert '${value}' to boolean for flag '${flag["name"]}'`
909
+ );
866
910
  } else if (flagType === "table") {
867
911
  if (Array.isArray(value)) return value;
868
912
  if (typeof value === "string") {
@@ -873,13 +917,17 @@ class ConfigurationManager {
873
917
  return value.split(",").map((v) => v.trim());
874
918
  }
875
919
  }
876
- throw new Error(`Cannot convert '${value}' to table for flag '${flag["name"]}'`);
920
+ throw new Error(
921
+ `Cannot convert '${value}' to table for flag '${flag["name"]}'`
922
+ );
877
923
  } else {
878
924
  if (typeof flagType === "function") {
879
925
  try {
880
926
  return flagType(value);
881
927
  } catch (error) {
882
- throw new Error(`Custom type conversion failed for flag '${flag["name"]}': ${error instanceof Error ? error.message : String(error)}`);
928
+ throw new Error(
929
+ `Custom type conversion failed for flag '${flag["name"]}': ${error instanceof Error ? error.message : String(error)}`
930
+ );
883
931
  }
884
932
  }
885
933
  return String(value);
@@ -954,7 +1002,9 @@ class ConfigurationManager {
954
1002
  if (Array.isArray(value)) {
955
1003
  lines.push(`${flag["name"]}:`);
956
1004
  for (const item of value) {
957
- lines.push(` - ${typeof item === "string" && item.includes(" ") ? `"${item}"` : item}`);
1005
+ lines.push(
1006
+ ` - ${typeof item === "string" && item.includes(" ") ? `"${item}"` : item}`
1007
+ );
958
1008
  }
959
1009
  } else if (typeof value === "string" && value.includes(" ")) {
960
1010
  lines.push(`${flag["name"]}: "${value}"`);
@@ -1217,24 +1267,46 @@ class DxtGenerator {
1217
1267
  try {
1218
1268
  const isTestMode = process.env["NODE_ENV"] === "test" || ((_a = process.argv[0]) == null ? void 0 : _a.includes("vitest")) || ((_b = process.argv[1]) == null ? void 0 : _b.includes("vitest")) || ((_c = process.argv[1]) == null ? void 0 : _c.includes("tinypool"));
1219
1269
  if (isTestMode) {
1220
- return await this.handleTestModeDxtGeneration(processArgs, buildDxtIndex);
1270
+ return await this.handleTestModeDxtGeneration(
1271
+ processArgs,
1272
+ buildDxtIndex
1273
+ );
1221
1274
  }
1222
1275
  const entryPointFile = process.argv[1];
1223
1276
  if (!entryPointFile || !fs__namespace.existsSync(entryPointFile)) {
1224
- console.error(simpleChalk.red(`Error: Entry point file not found: ${entryPointFile}`));
1277
+ console.error(
1278
+ simpleChalk.red(`Error: Entry point file not found: ${entryPointFile}`)
1279
+ );
1225
1280
  return this._handleExit(1, "Entry point file not found", "error");
1226
1281
  }
1227
1282
  const outputDir = processArgs[buildDxtIndex + 1] || "./dxt";
1228
- console.log(simpleChalk.cyan(`
1229
- 🔧 Building DXT package for entry point: ${path__namespace.basename(entryPointFile)}`));
1283
+ console.log(
1284
+ simpleChalk.cyan(
1285
+ `
1286
+ 🔧 Building DXT package for entry point: ${path__namespace.basename(entryPointFile)}`
1287
+ )
1288
+ );
1230
1289
  console.log(simpleChalk.gray(`Output directory: ${outputDir}`));
1231
1290
  await this.buildDxtWithTsdown(entryPointFile, outputDir);
1232
1291
  console.log(simpleChalk.green(`
1233
1292
  ✅ DXT package generation completed!`));
1234
- return this._handleExit(0, "DXT package generation completed", "success", { entryPoint: entryPointFile, outputDir });
1293
+ return this._handleExit(
1294
+ 0,
1295
+ "DXT package generation completed",
1296
+ "success",
1297
+ { entryPoint: entryPointFile, outputDir }
1298
+ );
1235
1299
  } catch (error) {
1236
- console.error(simpleChalk.red(`Error generating DXT package: ${error instanceof Error ? error.message : String(error)}`));
1237
- return this._handleExit(1, `Error generating DXT package: ${error instanceof Error ? error.message : String(error)}`, "error");
1300
+ console.error(
1301
+ simpleChalk.red(
1302
+ `Error generating DXT package: ${error instanceof Error ? error.message : String(error)}`
1303
+ )
1304
+ );
1305
+ return this._handleExit(
1306
+ 1,
1307
+ `Error generating DXT package: ${error instanceof Error ? error.message : String(error)}`,
1308
+ "error"
1309
+ );
1238
1310
  }
1239
1311
  }
1240
1312
  /**
@@ -1274,7 +1346,10 @@ class DxtGenerator {
1274
1346
  })),
1275
1347
  icon: "logo.jpg"
1276
1348
  };
1277
- fs__namespace.writeFileSync(path__namespace.join(buildDir, "manifest.json"), JSON.stringify(manifest, null, 2));
1349
+ fs__namespace.writeFileSync(
1350
+ path__namespace.join(buildDir, "manifest.json"),
1351
+ JSON.stringify(manifest, null, 2)
1352
+ );
1278
1353
  const packageJson = {
1279
1354
  name: serverInfo.name,
1280
1355
  version: serverInfo.version,
@@ -1282,7 +1357,10 @@ class DxtGenerator {
1282
1357
  main: "index.mjs",
1283
1358
  type: "module"
1284
1359
  };
1285
- fs__namespace.writeFileSync(path__namespace.join(buildDir, "package.json"), JSON.stringify(packageJson, null, 2));
1360
+ fs__namespace.writeFileSync(
1361
+ path__namespace.join(buildDir, "package.json"),
1362
+ JSON.stringify(packageJson, null, 2)
1363
+ );
1286
1364
  const readme = `# ${serverInfo.name}
1287
1365
 
1288
1366
  ${serverInfo.description}
@@ -1291,13 +1369,25 @@ Generated by @alcyone-labs/arg-parser`;
1291
1369
  fs__namespace.writeFileSync(path__namespace.join(buildDir, "README.md"), readme);
1292
1370
  const buildScript = `#!/bin/bash
1293
1371
  echo "Mock DXT build script for ${serverInfo.name}"`;
1294
- fs__namespace.writeFileSync(path__namespace.join(buildDir, "build-dxt-package.sh"), buildScript);
1295
- return this._handleExit(0, "DXT package generation completed", "success", {
1296
- entryPoint: "test-mode",
1297
- outputDir: buildDir
1298
- });
1372
+ fs__namespace.writeFileSync(
1373
+ path__namespace.join(buildDir, "build-dxt-package.sh"),
1374
+ buildScript
1375
+ );
1376
+ return this._handleExit(
1377
+ 0,
1378
+ "DXT package generation completed",
1379
+ "success",
1380
+ {
1381
+ entryPoint: "test-mode",
1382
+ outputDir: buildDir
1383
+ }
1384
+ );
1299
1385
  } catch (error) {
1300
- return this._handleExit(1, `Test mode DXT generation failed: ${error instanceof Error ? error.message : String(error)}`, "error");
1386
+ return this._handleExit(
1387
+ 1,
1388
+ `Test mode DXT generation failed: ${error instanceof Error ? error.message : String(error)}`,
1389
+ "error"
1390
+ );
1301
1391
  }
1302
1392
  }
1303
1393
  /**
@@ -1318,9 +1408,17 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1318
1408
  fs__namespace.mkdirSync(serverDir, { recursive: true });
1319
1409
  }
1320
1410
  const logoFilename = await this.addLogoToFolder(buildDir, serverInfo);
1321
- const manifest = this.createDxtManifest(serverInfo, tools, mcpSubCommand, logoFilename);
1411
+ const manifest = this.createDxtManifest(
1412
+ serverInfo,
1413
+ tools,
1414
+ mcpSubCommand,
1415
+ logoFilename
1416
+ );
1322
1417
  this.validateDxtManifest(manifest);
1323
- fs__namespace.writeFileSync(path__namespace.join(buildDir, "manifest.json"), JSON.stringify(manifest, null, 2));
1418
+ fs__namespace.writeFileSync(
1419
+ path__namespace.join(buildDir, "manifest.json"),
1420
+ JSON.stringify(manifest, null, 2)
1421
+ );
1324
1422
  this.addOriginalCliToFolder(buildDir);
1325
1423
  const bundledCliPath = await this.bundleOriginalCliWithTsdown(serverDir);
1326
1424
  const serverScript = this.createServerScript(serverInfo, bundledCliPath);
@@ -1329,10 +1427,16 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1329
1427
  try {
1330
1428
  fs__namespace.chmodSync(serverScriptPath, 493);
1331
1429
  } catch (error) {
1332
- console.warn("⚠ Could not set executable permission on server script:", error instanceof Error ? error.message : String(error));
1430
+ console.warn(
1431
+ "⚠ Could not set executable permission on server script:",
1432
+ error instanceof Error ? error.message : String(error)
1433
+ );
1333
1434
  }
1334
1435
  const packageJson = this.createDxtPackageJson(serverInfo);
1335
- fs__namespace.writeFileSync(path__namespace.join(buildDir, "package.json"), JSON.stringify(packageJson, null, 2));
1436
+ fs__namespace.writeFileSync(
1437
+ path__namespace.join(buildDir, "package.json"),
1438
+ JSON.stringify(packageJson, null, 2)
1439
+ );
1336
1440
  const readme = this.createDxtReadme(serverInfo);
1337
1441
  fs__namespace.writeFileSync(path__namespace.join(buildDir, "README.md"), readme);
1338
1442
  const buildScript = this.createSimpleBuildScript(serverInfo);
@@ -1344,11 +1448,15 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1344
1448
  } catch (error) {
1345
1449
  }
1346
1450
  console.log(simpleChalk.green(` ✓ Generated DXT package folder: ${folderName}`));
1347
- console.log(simpleChalk.gray(` Server: ${serverInfo.name} v${serverInfo.version}`));
1451
+ console.log(
1452
+ simpleChalk.gray(` Server: ${serverInfo.name} v${serverInfo.version}`)
1453
+ );
1348
1454
  console.log(simpleChalk.gray(` Tools: ${tools.length} tool(s)`));
1349
1455
  console.log(simpleChalk.gray(` Location: ${buildDir}`));
1350
- console.log(simpleChalk.cyan(`
1351
- 📦 Creating DXT package using Anthropic's dxt pack...`));
1456
+ console.log(
1457
+ simpleChalk.cyan(`
1458
+ 📦 Creating DXT package using Anthropic's dxt pack...`)
1459
+ );
1352
1460
  console.log(simpleChalk.cyan(`
1353
1461
  📋 Manual steps to create your DXT package:`));
1354
1462
  console.log(simpleChalk.white(` cd ${path__namespace.relative(process.cwd(), buildDir)}`));
@@ -1411,7 +1519,9 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1411
1519
  toolOptions = mcpConfig.toolOptions;
1412
1520
  }
1413
1521
  }
1414
- const mcpTools = this.argParserInstance.toMcpTools(toolOptions);
1522
+ const mcpTools = this.argParserInstance.toMcpTools(
1523
+ toolOptions
1524
+ );
1415
1525
  return mcpTools.map((tool) => ({
1416
1526
  name: tool.name,
1417
1527
  description: tool.description
@@ -1435,16 +1545,24 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1435
1545
  });
1436
1546
  }
1437
1547
  }
1438
- return tools.length > 0 ? tools : [{
1439
- name: "main",
1440
- description: "Main command tool"
1441
- }];
1548
+ return tools.length > 0 ? tools : [
1549
+ {
1550
+ name: "main",
1551
+ description: "Main command tool"
1552
+ }
1553
+ ];
1442
1554
  } catch (error) {
1443
- console.warn(simpleChalk.yellow(`Warning: Could not generate detailed tool list: ${error instanceof Error ? error.message : String(error)}`));
1444
- return [{
1445
- name: "main",
1446
- description: "Main command tool"
1447
- }];
1555
+ console.warn(
1556
+ simpleChalk.yellow(
1557
+ `Warning: Could not generate detailed tool list: ${error instanceof Error ? error.message : String(error)}`
1558
+ )
1559
+ );
1560
+ return [
1561
+ {
1562
+ name: "main",
1563
+ description: "Main command tool"
1564
+ }
1565
+ ];
1448
1566
  }
1449
1567
  }
1450
1568
  createDxtManifest(serverInfo, tools, mcpSubCommand, logoFilename) {
@@ -1467,7 +1585,9 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1467
1585
  }
1468
1586
  }
1469
1587
  if (!author) {
1470
- throw new Error("DXT manifest requires author information. Please provide it via withMcp() serverInfo.author, addMcpSubCommand serverInfo.author, or in package.json");
1588
+ throw new Error(
1589
+ "DXT manifest requires author information. Please provide it via withMcp() serverInfo.author, addMcpSubCommand serverInfo.author, or in package.json"
1590
+ );
1471
1591
  }
1472
1592
  const cliArgs = this.generateCliArgsForDxt(mcpSubCommand);
1473
1593
  const { envVars, userConfig } = this.generateEnvAndUserConfig();
@@ -1510,31 +1630,41 @@ echo "Mock DXT build script for ${serverInfo.name}"`;
1510
1630
  }
1511
1631
  validateDxtManifest(manifest) {
1512
1632
  const errors = [];
1513
- if (!manifest.dxt_version) errors.push("Missing required field: dxt_version");
1633
+ if (!manifest.dxt_version)
1634
+ errors.push("Missing required field: dxt_version");
1514
1635
  if (!manifest.name) errors.push("Missing required field: name");
1515
1636
  if (!manifest.version) errors.push("Missing required field: version");
1516
1637
  if (!manifest.server) errors.push("Missing required field: server");
1517
1638
  if (!manifest.author) errors.push("Missing required field: author");
1518
1639
  if (manifest.server) {
1519
- if (!manifest.server.type) errors.push("Missing required field: server.type");
1520
- if (!manifest.server.entry_point) errors.push("Missing required field: server.entry_point");
1521
- if (!manifest.server.mcp_config) errors.push("Missing required field: server.mcp_config");
1640
+ if (!manifest.server.type)
1641
+ errors.push("Missing required field: server.type");
1642
+ if (!manifest.server.entry_point)
1643
+ errors.push("Missing required field: server.entry_point");
1644
+ if (!manifest.server.mcp_config)
1645
+ errors.push("Missing required field: server.mcp_config");
1522
1646
  if (manifest.server.mcp_config) {
1523
- if (!manifest.server.mcp_config.command) errors.push("Missing required field: server.mcp_config.command");
1647
+ if (!manifest.server.mcp_config.command)
1648
+ errors.push("Missing required field: server.mcp_config.command");
1524
1649
  if (!manifest.server.mcp_config.args || !Array.isArray(manifest.server.mcp_config.args)) {
1525
- errors.push("Missing or invalid field: server.mcp_config.args (must be array)");
1650
+ errors.push(
1651
+ "Missing or invalid field: server.mcp_config.args (must be array)"
1652
+ );
1526
1653
  }
1527
1654
  }
1528
1655
  }
1529
1656
  if (manifest.author && typeof manifest.author === "object") {
1530
- if (!manifest.author.name) errors.push("Missing required field: author.name");
1657
+ if (!manifest.author.name)
1658
+ errors.push("Missing required field: author.name");
1531
1659
  }
1532
1660
  if (manifest.dxt_version && manifest.dxt_version !== "0.1") {
1533
1661
  errors.push("Unsupported dxt_version: only '0.1' is currently supported");
1534
1662
  }
1535
1663
  if (errors.length > 0) {
1536
- throw new Error(`DXT manifest validation failed:
1537
- ${errors.map((e) => ` - ${e}`).join("\n")}`);
1664
+ throw new Error(
1665
+ `DXT manifest validation failed:
1666
+ ${errors.map((e) => ` - ${e}`).join("\n")}`
1667
+ );
1538
1668
  }
1539
1669
  }
1540
1670
  createServerScript(serverInfo, bundledCliPath) {
@@ -1578,27 +1708,34 @@ originalCli.parse(['--s-mcp-serve']);
1578
1708
  try {
1579
1709
  const originalPackageJsonPath = path__namespace.join(process.cwd(), "package.json");
1580
1710
  if (fs__namespace.existsSync(originalPackageJsonPath)) {
1581
- const originalPackageJson = JSON.parse(fs__namespace.readFileSync(originalPackageJsonPath, "utf8"));
1711
+ const originalPackageJson = JSON.parse(
1712
+ fs__namespace.readFileSync(originalPackageJsonPath, "utf8")
1713
+ );
1582
1714
  originalDependencies = originalPackageJson.dependencies || {};
1583
1715
  }
1584
1716
  } catch (error) {
1585
- console.warn("⚠ Could not read original package.json for dependencies:", error instanceof Error ? error.message : String(error));
1717
+ console.warn(
1718
+ "⚠ Could not read original package.json for dependencies:",
1719
+ error instanceof Error ? error.message : String(error)
1720
+ );
1586
1721
  }
1587
1722
  const dependencies2 = {
1588
1723
  ...originalDependencies,
1589
1724
  "@alcyone-labs/arg-parser": argParserDependency,
1590
1725
  "@alcyone-labs/simple-mcp-logger": "^1.0.0",
1591
1726
  "@modelcontextprotocol/sdk": "^1.15.0",
1592
- "zod": "^3.22.4"
1727
+ zod: "^3.22.4"
1593
1728
  };
1594
1729
  const devDependencies = {
1595
- "tsup": "^8.3.5"
1730
+ tsup: "^8.3.5"
1596
1731
  };
1597
1732
  Object.keys(dependencies2).forEach((key) => {
1598
1733
  const depValue = dependencies2[key];
1599
1734
  if (key !== "@alcyone-labs/arg-parser" && typeof depValue === "string" && depValue.startsWith("file:")) {
1600
1735
  delete dependencies2[key];
1601
- console.warn(`⚠ Removed file: dependency ${key} from DXT package (not suitable for distribution)`);
1736
+ console.warn(
1737
+ `⚠ Removed file: dependency ${key} from DXT package (not suitable for distribution)`
1738
+ );
1602
1739
  }
1603
1740
  });
1604
1741
  return {
@@ -1963,17 +2100,24 @@ For autonomous packages, follow the build instructions above.
1963
2100
  }
1964
2101
  console.log("✓ Downloaded logo from URL");
1965
2102
  } else {
1966
- console.warn(`⚠ Failed to download logo: HTTP ${response.status}`);
2103
+ console.warn(
2104
+ `⚠ Failed to download logo: HTTP ${response.status}`
2105
+ );
1967
2106
  }
1968
2107
  } catch (error) {
1969
- console.warn("⚠ Failed to download logo from URL:", error instanceof Error ? error.message : String(error));
2108
+ console.warn(
2109
+ "⚠ Failed to download logo from URL:",
2110
+ error instanceof Error ? error.message : String(error)
2111
+ );
1970
2112
  }
1971
2113
  } else {
1972
2114
  let logoPath;
1973
2115
  if (entryPointFile && !path__namespace.isAbsolute(customLogo)) {
1974
2116
  const entryDir = path__namespace.dirname(entryPointFile);
1975
2117
  logoPath = path__namespace.resolve(entryDir, customLogo);
1976
- console.log(`📍 Resolving logo path relative to entry point: ${logoPath}`);
2118
+ console.log(
2119
+ `📍 Resolving logo path relative to entry point: ${logoPath}`
2120
+ );
1977
2121
  } else {
1978
2122
  logoPath = path__namespace.resolve(customLogo);
1979
2123
  }
@@ -1990,17 +2134,32 @@ For autonomous packages, follow the build instructions above.
1990
2134
  const currentDir = path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname);
1991
2135
  let logoPath = path__namespace.join(currentDir, "assets", "logo_1_small.jpg");
1992
2136
  if (!fs__namespace.existsSync(logoPath)) {
1993
- logoPath = path__namespace.join(currentDir, "..", "docs", "MCP", "icons", "logo_1_small.jpg");
2137
+ logoPath = path__namespace.join(
2138
+ currentDir,
2139
+ "..",
2140
+ "docs",
2141
+ "MCP",
2142
+ "icons",
2143
+ "logo_1_small.jpg"
2144
+ );
1994
2145
  }
1995
2146
  if (!fs__namespace.existsSync(logoPath)) {
1996
- logoPath = path__namespace.join(process.cwd(), "docs", "MCP", "icons", "logo_1_small.jpg");
2147
+ logoPath = path__namespace.join(
2148
+ process.cwd(),
2149
+ "docs",
2150
+ "MCP",
2151
+ "icons",
2152
+ "logo_1_small.jpg"
2153
+ );
1997
2154
  }
1998
2155
  if (fs__namespace.existsSync(logoPath)) {
1999
2156
  logoBuffer = fs__namespace.readFileSync(logoPath);
2000
2157
  logoFilename = "logo.jpg";
2001
2158
  console.log("✓ Added default logo to build folder");
2002
2159
  } else {
2003
- console.warn("⚠ No logo found (custom or default), build folder will be created without icon");
2160
+ console.warn(
2161
+ "⚠ No logo found (custom or default), build folder will be created without icon"
2162
+ );
2004
2163
  return void 0;
2005
2164
  }
2006
2165
  }
@@ -2010,7 +2169,10 @@ For autonomous packages, follow the build instructions above.
2010
2169
  }
2011
2170
  return void 0;
2012
2171
  } catch (error) {
2013
- console.warn("⚠ Failed to add logo to build folder:", error instanceof Error ? error.message : String(error));
2172
+ console.warn(
2173
+ "⚠ Failed to add logo to build folder:",
2174
+ error instanceof Error ? error.message : String(error)
2175
+ );
2014
2176
  return void 0;
2015
2177
  }
2016
2178
  }
@@ -2060,7 +2222,12 @@ globalThis.console = {
2060
2222
  }
2061
2223
  }
2062
2224
  if (lastImportIndex >= 0) {
2063
- lines.splice(lastImportIndex + 1, 0, "", ...consoleReplacement.trim().split("\n"));
2225
+ lines.splice(
2226
+ lastImportIndex + 1,
2227
+ 0,
2228
+ "",
2229
+ ...consoleReplacement.trim().split("\n")
2230
+ );
2064
2231
  return lines.join("\n");
2065
2232
  } else {
2066
2233
  return consoleReplacement + cliSource;
@@ -2085,14 +2252,32 @@ globalThis.console = {
2085
2252
  path__namespace.join(process.cwd(), `${appCommandName}.js`),
2086
2253
  path__namespace.join(process.cwd(), `${appCommandName}.mjs`),
2087
2254
  // Look for files with the app command name (sanitized)
2088
- path__namespace.join(process.cwd(), `${appCommandName.replace(/[^a-zA-Z0-9-]/g, "-")}.js`),
2089
- path__namespace.join(process.cwd(), `${appCommandName.replace(/[^a-zA-Z0-9-]/g, "-")}.mjs`),
2255
+ path__namespace.join(
2256
+ process.cwd(),
2257
+ `${appCommandName.replace(/[^a-zA-Z0-9-]/g, "-")}.js`
2258
+ ),
2259
+ path__namespace.join(
2260
+ process.cwd(),
2261
+ `${appCommandName.replace(/[^a-zA-Z0-9-]/g, "-")}.mjs`
2262
+ ),
2090
2263
  // Look for files with app name patterns
2091
- path__namespace.join(process.cwd(), `${appName.toLowerCase().replace(/\s+/g, "-")}-cli.js`),
2092
- path__namespace.join(process.cwd(), `${appName.toLowerCase().replace(/\s+/g, "-")}-cli.mjs`),
2264
+ path__namespace.join(
2265
+ process.cwd(),
2266
+ `${appName.toLowerCase().replace(/\s+/g, "-")}-cli.js`
2267
+ ),
2268
+ path__namespace.join(
2269
+ process.cwd(),
2270
+ `${appName.toLowerCase().replace(/\s+/g, "-")}-cli.mjs`
2271
+ ),
2093
2272
  // Look for files with first word of app name + cli
2094
- path__namespace.join(process.cwd(), `${appName.split(" ")[0].toLowerCase()}-cli.js`),
2095
- path__namespace.join(process.cwd(), `${appName.split(" ")[0].toLowerCase()}-cli.mjs`)
2273
+ path__namespace.join(
2274
+ process.cwd(),
2275
+ `${appName.split(" ")[0].toLowerCase()}-cli.js`
2276
+ ),
2277
+ path__namespace.join(
2278
+ process.cwd(),
2279
+ `${appName.split(" ")[0].toLowerCase()}-cli.mjs`
2280
+ )
2096
2281
  ];
2097
2282
  let cliSourcePath = null;
2098
2283
  for (const filePath of possibleCliFiles) {
@@ -2112,7 +2297,9 @@ globalThis.console = {
2112
2297
  "import $1 from '@alcyone-labs/arg-parser';"
2113
2298
  );
2114
2299
  cliSource = this.processCliSourceForMcp(cliSource);
2115
- const parserVariableMatch = cliSource.match(/const\s+(\w+)\s*=\s*ArgParser\.withMcp\(/);
2300
+ const parserVariableMatch = cliSource.match(
2301
+ /const\s+(\w+)\s*=\s*ArgParser\.withMcp\(/
2302
+ );
2116
2303
  if (parserVariableMatch) {
2117
2304
  const parserVariable = parserVariableMatch[1];
2118
2305
  cliSource += `
@@ -2178,20 +2365,32 @@ if (process.argv.includes('serve')) {
2178
2365
  }
2179
2366
  `;
2180
2367
  } else {
2181
- console.warn("⚠ Could not find ArgParser instance in CLI source, MCP server may not work properly");
2368
+ console.warn(
2369
+ "⚠ Could not find ArgParser instance in CLI source, MCP server may not work properly"
2370
+ );
2182
2371
  }
2183
2372
  const serverDir = path__namespace.join(buildDir, "server");
2184
2373
  if (!fs__namespace.existsSync(serverDir)) {
2185
2374
  fs__namespace.mkdirSync(serverDir, { recursive: true });
2186
2375
  }
2187
2376
  fs__namespace.writeFileSync(path__namespace.join(serverDir, "original-cli.mjs"), cliSource);
2188
- console.log(`✓ Added original CLI source to build folder: ${path__namespace.basename(cliSourcePath)}`);
2377
+ console.log(
2378
+ `✓ Added original CLI source to build folder: ${path__namespace.basename(cliSourcePath)}`
2379
+ );
2189
2380
  } else {
2190
- console.warn("⚠ Original CLI source not found, handlers may not work properly");
2191
- console.warn(" Searched for:", possibleCliFiles.map((f) => path__namespace.basename(f)).join(", "));
2381
+ console.warn(
2382
+ " Original CLI source not found, handlers may not work properly"
2383
+ );
2384
+ console.warn(
2385
+ " Searched for:",
2386
+ possibleCliFiles.map((f) => path__namespace.basename(f)).join(", ")
2387
+ );
2192
2388
  }
2193
2389
  } catch (error) {
2194
- console.warn("⚠ Failed to add original CLI source:", error instanceof Error ? error.message : String(error));
2390
+ console.warn(
2391
+ "⚠ Failed to add original CLI source:",
2392
+ error instanceof Error ? error.message : String(error)
2393
+ );
2195
2394
  }
2196
2395
  }
2197
2396
  /**
@@ -2228,13 +2427,35 @@ if (process.argv.includes('serve')) {
2228
2427
  ...(() => {
2229
2428
  const possibleLogoPaths = [
2230
2429
  // From built library assets
2231
- path__namespace.join(path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname), "..", "assets", "logo_1_small.jpg"),
2430
+ path__namespace.join(
2431
+ path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname),
2432
+ "..",
2433
+ "assets",
2434
+ "logo_1_small.jpg"
2435
+ ),
2232
2436
  // From node_modules
2233
- path__namespace.join(process.cwd(), "node_modules", "@alcyone-labs", "arg-parser", "dist", "assets", "logo_1_small.jpg"),
2437
+ path__namespace.join(
2438
+ process.cwd(),
2439
+ "node_modules",
2440
+ "@alcyone-labs",
2441
+ "arg-parser",
2442
+ "dist",
2443
+ "assets",
2444
+ "logo_1_small.jpg"
2445
+ ),
2234
2446
  // From package root dist/assets (for local build)
2235
2447
  path__namespace.join(process.cwd(), "dist", "assets", "logo_1_small.jpg"),
2236
2448
  // From library root (development)
2237
- path__namespace.join(process.cwd(), "..", "..", "..", "docs", "MCP", "icons", "logo_1_small.jpg")
2449
+ path__namespace.join(
2450
+ process.cwd(),
2451
+ "..",
2452
+ "..",
2453
+ "..",
2454
+ "docs",
2455
+ "MCP",
2456
+ "icons",
2457
+ "logo_1_small.jpg"
2458
+ )
2238
2459
  ];
2239
2460
  for (const logoPath of possibleLogoPaths) {
2240
2461
  if (fs__namespace.existsSync(logoPath)) {
@@ -2242,7 +2463,9 @@ if (process.argv.includes('serve')) {
2242
2463
  return [{ from: logoPath, to: "logo.jpg" }];
2243
2464
  }
2244
2465
  }
2245
- console.log(simpleChalk.yellow("⚠ Logo not found in any expected location"));
2466
+ console.log(
2467
+ simpleChalk.yellow("⚠ Logo not found in any expected location")
2468
+ );
2246
2469
  return [];
2247
2470
  })()
2248
2471
  ],
@@ -2282,20 +2505,39 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2282
2505
  // To run manually:
2283
2506
  // npx tsdown -c tsdown.config.dxt.ts
2284
2507
  `;
2285
- fs__namespace.writeFileSync(path__namespace.join("dxt", "tsdown.config.dxt.ts"), configContent);
2286
- console.log(simpleChalk.gray("📝 Debug config written to dxt/tsdown.config.dxt.ts"));
2508
+ fs__namespace.writeFileSync(
2509
+ path__namespace.join("dxt", "tsdown.config.dxt.ts"),
2510
+ configContent
2511
+ );
2512
+ console.log(
2513
+ simpleChalk.gray("📝 Debug config written to dxt/tsdown.config.dxt.ts")
2514
+ );
2287
2515
  }
2288
2516
  await build(buildConfig);
2289
2517
  console.log(simpleChalk.green("✅ TSDown bundling completed"));
2518
+ const actualOutputFilename = this.detectTsdownOutputFile(
2519
+ outputDir,
2520
+ entryFileName
2521
+ );
2290
2522
  await this.copyLogoManually(outputDir);
2291
- await this.setupDxtPackageFiles(entryPointFile, outputDir);
2523
+ await this.setupDxtPackageFiles(
2524
+ entryPointFile,
2525
+ outputDir,
2526
+ actualOutputFilename ?? void 0
2527
+ );
2292
2528
  console.log(simpleChalk.cyan("📦 DXT package ready for packing"));
2293
- console.log(simpleChalk.gray(`To complete the process, run: npx @anthropic-ai/dxt pack ${outputDir}/`));
2529
+ console.log(
2530
+ simpleChalk.gray(
2531
+ `To complete the process, run: npx @anthropic-ai/dxt pack ${outputDir}/`
2532
+ )
2533
+ );
2294
2534
  } finally {
2295
2535
  process.chdir(originalCwd);
2296
2536
  }
2297
2537
  } catch (error) {
2298
- throw new Error(`TSDown DXT build failed: ${error instanceof Error ? error.message : String(error)}`);
2538
+ throw new Error(
2539
+ `TSDown DXT build failed: ${error instanceof Error ? error.message : String(error)}`
2540
+ );
2299
2541
  }
2300
2542
  }
2301
2543
  /**
@@ -2304,13 +2546,17 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2304
2546
  async bundleOriginalCliWithTsdown(serverDir) {
2305
2547
  try {
2306
2548
  const { build } = await import("tsdown");
2307
- console.log(simpleChalk.cyan("🔧 Bundling CLI with TSDown for autonomous execution..."));
2549
+ console.log(
2550
+ simpleChalk.cyan("🔧 Bundling CLI with TSDown for autonomous execution...")
2551
+ );
2308
2552
  const configContent = this.getTsdownConfigContent();
2309
2553
  const localConfigPath = path__namespace.join(serverDir, "tsdown.config.mjs");
2310
2554
  fs__namespace.writeFileSync(localConfigPath, configContent);
2311
2555
  const originalCliPath = path__namespace.join(serverDir, "original-cli.mjs");
2312
2556
  if (!fs__namespace.existsSync(originalCliPath)) {
2313
- console.warn(simpleChalk.yellow("⚠ Original CLI not found, skipping TSDown bundling"));
2557
+ console.warn(
2558
+ simpleChalk.yellow("⚠ Original CLI not found, skipping TSDown bundling")
2559
+ );
2314
2560
  return null;
2315
2561
  }
2316
2562
  const buildOptions = {
@@ -2331,7 +2577,10 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2331
2577
  outExtension: () => ({ js: ".bundled.mjs" }),
2332
2578
  alias: {
2333
2579
  // Alias chalk to SimpleChalk for autonomous builds
2334
- chalk: path__namespace.resolve(process.cwd(), "node_modules/@alcyone-labs/arg-parser/dist/SimpleChalk.mjs")
2580
+ chalk: path__namespace.resolve(
2581
+ process.cwd(),
2582
+ "node_modules/@alcyone-labs/arg-parser/dist/SimpleChalk.mjs"
2583
+ )
2335
2584
  },
2336
2585
  external: [
2337
2586
  // Only Node.js built-ins - everything else gets bundled for true autonomy
@@ -2423,8 +2672,15 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2423
2672
  }
2424
2673
  }
2425
2674
  if (bundledPath && bundledFileName) {
2426
- console.log(simpleChalk.green(`✅ TSDown bundling completed successfully: ${bundledFileName}`));
2427
- const expectedBundledPath = path__namespace.join(serverDir, "original-cli.bundled.mjs");
2675
+ console.log(
2676
+ simpleChalk.green(
2677
+ `✅ TSDown bundling completed successfully: ${bundledFileName}`
2678
+ )
2679
+ );
2680
+ const expectedBundledPath = path__namespace.join(
2681
+ serverDir,
2682
+ "original-cli.bundled.mjs"
2683
+ );
2428
2684
  if (bundledPath !== expectedBundledPath) {
2429
2685
  fs__namespace.renameSync(bundledPath, expectedBundledPath);
2430
2686
  bundledFileName = "original-cli.bundled.mjs";
@@ -2436,15 +2692,24 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2436
2692
  try {
2437
2693
  fs__namespace.chmodSync(expectedBundledPath, 493);
2438
2694
  } catch (error) {
2439
- console.warn("⚠ Could not set executable permission on bundled file:", error instanceof Error ? error.message : String(error));
2695
+ console.warn(
2696
+ "⚠ Could not set executable permission on bundled file:",
2697
+ error instanceof Error ? error.message : String(error)
2698
+ );
2440
2699
  }
2441
2700
  return bundledFileName;
2442
2701
  } else {
2443
- console.warn(simpleChalk.yellow("⚠ TSDown bundling failed, bundled file not found"));
2702
+ console.warn(
2703
+ simpleChalk.yellow("⚠ TSDown bundling failed, bundled file not found")
2704
+ );
2444
2705
  return null;
2445
2706
  }
2446
2707
  } catch (error) {
2447
- console.warn(simpleChalk.yellow(`⚠ TSDown bundling failed: ${error instanceof Error ? error.message : String(error)}`));
2708
+ console.warn(
2709
+ simpleChalk.yellow(
2710
+ `⚠ TSDown bundling failed: ${error instanceof Error ? error.message : String(error)}`
2711
+ )
2712
+ );
2448
2713
  console.log(simpleChalk.gray(" Falling back to non-bundled approach"));
2449
2714
  return null;
2450
2715
  }
@@ -2499,22 +2764,44 @@ export default ${JSON.stringify(buildConfig, null, 2)};
2499
2764
  */
2500
2765
  getTsdownConfigContent() {
2501
2766
  const currentDir = path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname);
2502
- const assetsConfigPath = path__namespace.join(currentDir, "..", "assets", "tsdown.dxt.config.ts");
2767
+ const assetsConfigPath = path__namespace.join(
2768
+ currentDir,
2769
+ "..",
2770
+ "assets",
2771
+ "tsdown.dxt.config.ts"
2772
+ );
2503
2773
  if (fs__namespace.existsSync(assetsConfigPath)) {
2504
2774
  try {
2505
2775
  const content = fs__namespace.readFileSync(assetsConfigPath, "utf-8");
2506
- return content.replace('/// <reference types="tsdown" />', "").replace('import { defineConfig } from "tsdown/config";', 'import { defineConfig } from "tsdown";').replace("export default defineConfig(", "export default defineConfig(");
2776
+ return content.replace('/// <reference types="tsdown" />', "").replace(
2777
+ 'import { defineConfig } from "tsdown/config";',
2778
+ 'import { defineConfig } from "tsdown";'
2779
+ ).replace(
2780
+ "export default defineConfig(",
2781
+ "export default defineConfig("
2782
+ );
2507
2783
  } catch (error) {
2508
- console.warn(simpleChalk.yellow("⚠ Could not read TSDown config from assets, using fallback"));
2784
+ console.warn(
2785
+ simpleChalk.yellow(
2786
+ "⚠ Could not read TSDown config from assets, using fallback"
2787
+ )
2788
+ );
2509
2789
  }
2510
2790
  }
2511
2791
  const rootConfigPath = path__namespace.join(process.cwd(), "tsdown.dxt.config.ts");
2512
2792
  if (fs__namespace.existsSync(rootConfigPath)) {
2513
2793
  try {
2514
2794
  const content = fs__namespace.readFileSync(rootConfigPath, "utf-8");
2515
- return content.replace('/// <reference types="tsdown" />', "").replace('import { defineConfig } from "tsdown/config";', 'import { defineConfig } from "tsdown";');
2795
+ return content.replace('/// <reference types="tsdown" />', "").replace(
2796
+ 'import { defineConfig } from "tsdown/config";',
2797
+ 'import { defineConfig } from "tsdown";'
2798
+ );
2516
2799
  } catch (error) {
2517
- console.warn(simpleChalk.yellow("⚠ Could not read TSDown config from root, using default"));
2800
+ console.warn(
2801
+ simpleChalk.yellow(
2802
+ "⚠ Could not read TSDown config from root, using default"
2803
+ )
2804
+ );
2518
2805
  }
2519
2806
  }
2520
2807
  return `import { defineConfig } from "tsdown";
@@ -2545,9 +2832,22 @@ export default defineConfig({
2545
2832
  getDxtIgnoreTemplatePath() {
2546
2833
  const possiblePaths = [
2547
2834
  // 1. From the built library assets (when installed via npm)
2548
- path__namespace.join(path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname), "..", "assets", ".dxtignore.template"),
2835
+ path__namespace.join(
2836
+ path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname),
2837
+ "..",
2838
+ "assets",
2839
+ ".dxtignore.template"
2840
+ ),
2549
2841
  // 2. From node_modules/@alcyone-labs/arg-parser/dist/assets (when installed via npm)
2550
- path__namespace.join(process.cwd(), "node_modules", "@alcyone-labs", "arg-parser", "dist", "assets", ".dxtignore.template"),
2842
+ path__namespace.join(
2843
+ process.cwd(),
2844
+ "node_modules",
2845
+ "@alcyone-labs",
2846
+ "arg-parser",
2847
+ "dist",
2848
+ "assets",
2849
+ ".dxtignore.template"
2850
+ ),
2551
2851
  // 3. From the root directory (development/local build)
2552
2852
  path__namespace.join(process.cwd(), ".dxtignore.template"),
2553
2853
  // 4. From the library root (when using local file dependency)
@@ -2565,7 +2865,7 @@ export default defineConfig({
2565
2865
  /**
2566
2866
  * Sets up DXT package files (manifest.json) in the output directory
2567
2867
  */
2568
- async setupDxtPackageFiles(entryPointFile, outputDir = "./dxt") {
2868
+ async setupDxtPackageFiles(entryPointFile, outputDir = "./dxt", actualOutputFilename) {
2569
2869
  var _a, _b, _c, _d, _e;
2570
2870
  const dxtDir = path__namespace.resolve(process.cwd(), outputDir);
2571
2871
  if (!fs__namespace.existsSync(dxtDir)) {
@@ -2588,7 +2888,11 @@ export default defineConfig({
2588
2888
  description: tool.description
2589
2889
  }));
2590
2890
  } catch (error) {
2591
- console.warn(simpleChalk.yellow(`Warning: Could not generate unified tool list: ${error instanceof Error ? error.message : String(error)}`));
2891
+ console.warn(
2892
+ simpleChalk.yellow(
2893
+ `Warning: Could not generate unified tool list: ${error instanceof Error ? error.message : String(error)}`
2894
+ )
2895
+ );
2592
2896
  const mainFlags2 = this.argParserInstance.flags;
2593
2897
  const properties2 = {};
2594
2898
  const required2 = [];
@@ -2609,10 +2913,12 @@ export default defineConfig({
2609
2913
  }
2610
2914
  }
2611
2915
  const commandName = this.argParserInstance.getAppCommandName();
2612
- tools = [{
2613
- name: commandName || packageInfo.name || "cli-tool",
2614
- description: packageInfo.description || this.argParserInstance.getDescription() || "CLI tool"
2615
- }];
2916
+ tools = [
2917
+ {
2918
+ name: commandName || packageInfo.name || "cli-tool",
2919
+ description: packageInfo.description || this.argParserInstance.getDescription() || "CLI tool"
2920
+ }
2921
+ ];
2616
2922
  }
2617
2923
  const envVars = {};
2618
2924
  const userConfig = {};
@@ -2656,12 +2962,16 @@ export default defineConfig({
2656
2962
  const serverInfo = this.extractMcpServerInfo();
2657
2963
  let logoFilename = "logo.jpg";
2658
2964
  if (serverInfo == null ? void 0 : serverInfo.logo) {
2659
- const customLogoFilename = await this.addLogoToFolder(dxtDir, serverInfo, entryPointFile);
2965
+ const customLogoFilename = await this.addLogoToFolder(
2966
+ dxtDir,
2967
+ serverInfo,
2968
+ entryPointFile
2969
+ );
2660
2970
  if (customLogoFilename) {
2661
2971
  logoFilename = customLogoFilename;
2662
2972
  }
2663
2973
  }
2664
- const entryFileName = path__namespace.basename(entryPointFile);
2974
+ const entryFileName = actualOutputFilename || path__namespace.basename(entryPointFile).replace(/\.ts$/, ".js");
2665
2975
  const manifest = {
2666
2976
  dxt_version: "0.1",
2667
2977
  name: serverInfo.name || packageInfo.name || "mcp-server",
@@ -2677,10 +2987,7 @@ export default defineConfig({
2677
2987
  entry_point: entryFileName,
2678
2988
  mcp_config: {
2679
2989
  command: "node",
2680
- args: [
2681
- `\${__dirname}/${entryFileName}`,
2682
- "--s-mcp-serve"
2683
- ],
2990
+ args: [`\${__dirname}/${entryFileName}`, "--s-mcp-serve"],
2684
2991
  env: envVars
2685
2992
  }
2686
2993
  },
@@ -2693,7 +3000,10 @@ export default defineConfig({
2693
3000
  },
2694
3001
  license: packageInfo.license || "MIT"
2695
3002
  };
2696
- fs__namespace.writeFileSync(path__namespace.join(dxtDir, "manifest.json"), JSON.stringify(manifest, null, 2));
3003
+ fs__namespace.writeFileSync(
3004
+ path__namespace.join(dxtDir, "manifest.json"),
3005
+ JSON.stringify(manifest, null, 2)
3006
+ );
2697
3007
  console.log(simpleChalk.gray("✅ DXT package files set up"));
2698
3008
  }
2699
3009
  /**
@@ -2702,18 +3012,44 @@ export default defineConfig({
2702
3012
  async copyLogoManually(outputDir = "./dxt") {
2703
3013
  const dxtDir = path__namespace.resolve(process.cwd(), outputDir);
2704
3014
  if (!fs__namespace.existsSync(dxtDir)) {
2705
- console.warn(simpleChalk.yellow(`⚠ Output directory (${outputDir}) not found, skipping logo copy`));
3015
+ console.warn(
3016
+ simpleChalk.yellow(
3017
+ `⚠ Output directory (${outputDir}) not found, skipping logo copy`
3018
+ )
3019
+ );
2706
3020
  return;
2707
3021
  }
2708
3022
  const possibleLogoPaths = [
2709
3023
  // From built library assets
2710
- path__namespace.join(path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname), "..", "assets", "logo_1_small.jpg"),
3024
+ path__namespace.join(
3025
+ path__namespace.dirname(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href).pathname),
3026
+ "..",
3027
+ "assets",
3028
+ "logo_1_small.jpg"
3029
+ ),
2711
3030
  // From node_modules
2712
- path__namespace.join(process.cwd(), "node_modules", "@alcyone-labs", "arg-parser", "dist", "assets", "logo_1_small.jpg"),
3031
+ path__namespace.join(
3032
+ process.cwd(),
3033
+ "node_modules",
3034
+ "@alcyone-labs",
3035
+ "arg-parser",
3036
+ "dist",
3037
+ "assets",
3038
+ "logo_1_small.jpg"
3039
+ ),
2713
3040
  // From package root dist/assets (for local build)
2714
3041
  path__namespace.join(process.cwd(), "dist", "assets", "logo_1_small.jpg"),
2715
3042
  // From library root (development)
2716
- path__namespace.join(process.cwd(), "..", "..", "..", "docs", "MCP", "icons", "logo_1_small.jpg")
3043
+ path__namespace.join(
3044
+ process.cwd(),
3045
+ "..",
3046
+ "..",
3047
+ "..",
3048
+ "docs",
3049
+ "MCP",
3050
+ "icons",
3051
+ "logo_1_small.jpg"
3052
+ )
2717
3053
  ];
2718
3054
  for (const logoPath of possibleLogoPaths) {
2719
3055
  if (fs__namespace.existsSync(logoPath)) {
@@ -2722,12 +3058,78 @@ export default defineConfig({
2722
3058
  console.log(simpleChalk.gray(`✅ Logo copied from: ${logoPath}`));
2723
3059
  return;
2724
3060
  } catch (error) {
2725
- console.warn(simpleChalk.yellow(`⚠ Failed to copy logo from ${logoPath}: ${error}`));
3061
+ console.warn(
3062
+ simpleChalk.yellow(`⚠ Failed to copy logo from ${logoPath}: ${error}`)
3063
+ );
2726
3064
  }
2727
3065
  }
2728
3066
  }
2729
3067
  console.warn(simpleChalk.yellow("⚠ Logo not found in any expected location"));
2730
3068
  }
3069
+ /**
3070
+ * Detects the actual output filename generated by TSDown
3071
+ */
3072
+ detectTsdownOutputFile(outputDir, expectedBaseName) {
3073
+ try {
3074
+ const dxtDir = path__namespace.resolve(process.cwd(), outputDir);
3075
+ if (!fs__namespace.existsSync(dxtDir)) {
3076
+ console.warn(
3077
+ simpleChalk.yellow(`⚠ Output directory (${outputDir}) not found`)
3078
+ );
3079
+ return null;
3080
+ }
3081
+ const files = fs__namespace.readdirSync(dxtDir).filter(
3082
+ (file) => (file.endsWith(".js") || file.endsWith(".mjs")) && !file.includes("chunk-") && !file.includes("dist-") && !file.startsWith(".")
3083
+ );
3084
+ const baseNameWithoutExt = path__namespace.parse(expectedBaseName).name;
3085
+ for (const ext of [".js", ".mjs"]) {
3086
+ const exactMatch = `${baseNameWithoutExt}${ext}`;
3087
+ if (files.includes(exactMatch)) {
3088
+ console.log(simpleChalk.gray(`✓ Detected TSDown output: ${exactMatch}`));
3089
+ return exactMatch;
3090
+ }
3091
+ }
3092
+ const mainFiles = files.filter(
3093
+ (file) => !file.includes("chunk") && !file.includes("dist") && file !== "logo.jpg" && file !== "manifest.json"
3094
+ );
3095
+ if (mainFiles.length === 1) {
3096
+ console.log(simpleChalk.gray(`✓ Detected TSDown output: ${mainFiles[0]}`));
3097
+ return mainFiles[0];
3098
+ }
3099
+ if (mainFiles.length > 1) {
3100
+ let bestMatch = mainFiles[0];
3101
+ let bestScore = 0;
3102
+ for (const file of mainFiles) {
3103
+ const filePath = path__namespace.join(dxtDir, file);
3104
+ const stats = fs__namespace.statSync(filePath);
3105
+ const nameScore = file.includes(baseNameWithoutExt) ? 100 : 0;
3106
+ const sizeScore = Math.min(stats.size / 1e3, 50);
3107
+ const totalScore = nameScore + sizeScore;
3108
+ if (totalScore > bestScore) {
3109
+ bestScore = totalScore;
3110
+ bestMatch = file;
3111
+ }
3112
+ }
3113
+ console.log(
3114
+ simpleChalk.gray(
3115
+ `✓ Detected TSDown output: ${bestMatch} (best match from ${mainFiles.length} candidates)`
3116
+ )
3117
+ );
3118
+ return bestMatch;
3119
+ }
3120
+ console.warn(
3121
+ simpleChalk.yellow(`⚠ Could not detect TSDown output file in ${outputDir}`)
3122
+ );
3123
+ return null;
3124
+ } catch (error) {
3125
+ console.warn(
3126
+ simpleChalk.yellow(
3127
+ `⚠ Error detecting TSDown output: ${error instanceof Error ? error.message : String(error)}`
3128
+ )
3129
+ );
3130
+ return null;
3131
+ }
3132
+ }
2731
3133
  }
2732
3134
  class McpNotificationsManager {
2733
3135
  constructor() {
@@ -2881,10 +3283,16 @@ class McpNotificationsManager {
2881
3283
  sendNotificationToClient(client, type2) {
2882
3284
  try {
2883
3285
  if (client.connection && typeof client.connection.sendNotification === "function") {
2884
- client.connection.sendNotification(`notifications/${type2}/list_changed`, {});
3286
+ client.connection.sendNotification(
3287
+ `notifications/${type2}/list_changed`,
3288
+ {}
3289
+ );
2885
3290
  }
2886
3291
  } catch (error) {
2887
- console.error(`Error sending notification to client ${client.clientId}:`, error);
3292
+ console.error(
3293
+ `Error sending notification to client ${client.clientId}:`,
3294
+ error
3295
+ );
2888
3296
  this.removeClient(client.clientId);
2889
3297
  }
2890
3298
  }
@@ -2973,7 +3381,9 @@ class McpPromptsManager {
2973
3381
  return await entry.config.handler(validatedArgs);
2974
3382
  } catch (error) {
2975
3383
  if (error instanceof zod.z.ZodError) {
2976
- throw new Error(`Invalid arguments for prompt '${name}': ${error.message}`);
3384
+ throw new Error(
3385
+ `Invalid arguments for prompt '${name}': ${error.message}`
3386
+ );
2977
3387
  }
2978
3388
  throw error;
2979
3389
  }
@@ -3173,7 +3583,9 @@ class McpResourcesManager {
3173
3583
  try {
3174
3584
  new ResourceTemplateParser(config.uriTemplate);
3175
3585
  } catch (error) {
3176
- throw new Error(`Invalid URI template '${config.uriTemplate}': ${error instanceof Error ? error.message : String(error)}`);
3586
+ throw new Error(
3587
+ `Invalid URI template '${config.uriTemplate}': ${error instanceof Error ? error.message : String(error)}`
3588
+ );
3177
3589
  }
3178
3590
  }
3179
3591
  /**
@@ -3278,6 +3690,97 @@ const _FlagManager = class _FlagManager {
3278
3690
  __flags = new WeakMap();
3279
3691
  _throwForDuplicateFlags = new WeakMap();
3280
3692
  let FlagManager = _FlagManager;
3693
+ function detectEntryPoint() {
3694
+ try {
3695
+ if (process.argv[1] && fs__namespace.existsSync(process.argv[1])) {
3696
+ return process.argv[1];
3697
+ }
3698
+ if (typeof require !== "undefined" && require.main && require.main.filename) {
3699
+ return require.main.filename;
3700
+ }
3701
+ return null;
3702
+ } catch {
3703
+ return null;
3704
+ }
3705
+ }
3706
+ function getEntryPointFromImportMeta(importMetaUrl) {
3707
+ if (importMetaUrl.startsWith("file://")) {
3708
+ return decodeURIComponent(importMetaUrl.replace("file://", ""));
3709
+ }
3710
+ return importMetaUrl;
3711
+ }
3712
+ function normalizePath(path2) {
3713
+ return path2.trim();
3714
+ }
3715
+ function resolveLogPath(logPath, fallbackEntryPoint) {
3716
+ if (typeof logPath === "string") {
3717
+ const normalizedPath2 = normalizePath(logPath);
3718
+ if (path__namespace.isAbsolute(normalizedPath2)) {
3719
+ return normalizedPath2;
3720
+ }
3721
+ if (normalizedPath2.startsWith("cwd:")) {
3722
+ const relativePath = normalizedPath2.slice(4);
3723
+ return path__namespace.resolve(process.cwd(), relativePath);
3724
+ }
3725
+ const entryPoint = detectEntryPoint() || fallbackEntryPoint;
3726
+ if (entryPoint) {
3727
+ return path__namespace.resolve(path__namespace.dirname(entryPoint), normalizedPath2);
3728
+ }
3729
+ console.warn(
3730
+ `Warning: Could not detect entry point for log path resolution. Using process.cwd() as fallback. Path: ${normalizedPath2}`
3731
+ );
3732
+ return path__namespace.resolve(process.cwd(), normalizedPath2);
3733
+ }
3734
+ const { path: logFilePath, relativeTo = "entry", basePath } = logPath;
3735
+ const normalizedPath = normalizePath(logFilePath);
3736
+ switch (relativeTo) {
3737
+ case "absolute":
3738
+ if (basePath) {
3739
+ return path__namespace.resolve(basePath, normalizedPath);
3740
+ }
3741
+ if (path__namespace.isAbsolute(normalizedPath)) {
3742
+ return normalizedPath;
3743
+ }
3744
+ console.warn(
3745
+ `Warning: relativeTo 'absolute' specified but no basePath provided and path is not absolute. Using process.cwd() as fallback. Path: ${normalizedPath}`
3746
+ );
3747
+ return path__namespace.resolve(process.cwd(), normalizedPath);
3748
+ case "cwd":
3749
+ return path__namespace.resolve(process.cwd(), normalizedPath);
3750
+ case "entry":
3751
+ default:
3752
+ const entryPoint = detectEntryPoint() || fallbackEntryPoint;
3753
+ if (entryPoint) {
3754
+ return path__namespace.resolve(path__namespace.dirname(entryPoint), normalizedPath);
3755
+ }
3756
+ console.warn(
3757
+ `Warning: Could not detect entry point for log path resolution. Using process.cwd() as fallback. Path: ${normalizedPath}`
3758
+ );
3759
+ return path__namespace.resolve(process.cwd(), normalizedPath);
3760
+ }
3761
+ }
3762
+ function entryRelative(path2) {
3763
+ return {
3764
+ path: path2,
3765
+ relativeTo: "entry"
3766
+ };
3767
+ }
3768
+ function cwdRelative(path2) {
3769
+ return {
3770
+ path: path2,
3771
+ relativeTo: "cwd"
3772
+ };
3773
+ }
3774
+ function absolutePath(path2, basePath) {
3775
+ return {
3776
+ path: path2,
3777
+ relativeTo: "absolute",
3778
+ basePath
3779
+ };
3780
+ }
3781
+ function legacyCwdPath(path2) {
3782
+ return `cwd:${path2}`;
3783
+ }
3281
3784
  class ArgParserError extends Error {
3282
3785
  constructor(message, cmdChain = []) {
3283
3786
  super(message);
@@ -4675,15 +5178,16 @@ _handleBuildDxtFlag_fn = async function(processArgs, buildDxtIndex) {
4675
5178
  };
4676
5179
  _handleMcpServeFlag_fn = async function(processArgs, _mcpServeIndex) {
4677
5180
  var _a;
5181
+ const transportOptions = __privateMethod(this, _ArgParserBase_instances, _parseMcpTransportOptions_fn).call(this, processArgs);
5182
+ const mcpServerConfig = __privateMethod(this, _ArgParserBase_instances, _getMcpServerConfiguration_fn).call(this);
5183
+ const effectiveLogPath = transportOptions.logPath || (mcpServerConfig == null ? void 0 : mcpServerConfig.logPath) || "./logs/mcp.log";
5184
+ const resolvedLogPath = resolveLogPath(effectiveLogPath);
4678
5185
  let mcpLogger;
4679
5186
  try {
4680
5187
  const mcpLoggerModule = await Function(
4681
5188
  'return import("@alcyone-labs/simple-mcp-logger")'
4682
5189
  )();
4683
- mcpLogger = mcpLoggerModule.createMcpLogger(
4684
- "MCP Serve",
4685
- "./logs/mcp.log"
4686
- );
5190
+ mcpLogger = mcpLoggerModule.createMcpLogger("MCP Serve", resolvedLogPath);
4687
5191
  globalThis.console = mcpLogger;
4688
5192
  } catch {
4689
5193
  mcpLogger = {
@@ -4694,7 +5198,6 @@ _handleMcpServeFlag_fn = async function(processArgs, _mcpServeIndex) {
4694
5198
  mcpLogger.mcpError(
4695
5199
  "Starting --s-mcp-serve system flag handler - console hijacked for MCP safety"
4696
5200
  );
4697
- const mcpServerConfig = __privateMethod(this, _ArgParserBase_instances, _getMcpServerConfiguration_fn).call(this);
4698
5201
  if (!mcpServerConfig) {
4699
5202
  mcpLogger.mcpError(
4700
5203
  "No MCP server configuration found. Use withMcp() or addMcpSubCommand() to configure MCP server."
@@ -4708,13 +5211,16 @@ _handleMcpServeFlag_fn = async function(processArgs, _mcpServeIndex) {
4708
5211
  mcpLogger.mcpError(
4709
5212
  `Found MCP server configuration: ${((_a = mcpServerConfig.serverInfo) == null ? void 0 : _a.name) || "unnamed"}`
4710
5213
  );
4711
- const transportOptions = __privateMethod(this, _ArgParserBase_instances, _parseMcpTransportOptions_fn).call(this, processArgs);
5214
+ mcpLogger.mcpError(`Using log path: ${resolvedLogPath}`);
4712
5215
  mcpLogger.mcpError(
4713
5216
  `Transport options: ${JSON.stringify(transportOptions)}`
4714
5217
  );
4715
5218
  try {
4716
5219
  mcpLogger.mcpError("Starting unified MCP server with all tools");
4717
- await __privateMethod(this, _ArgParserBase_instances, _startUnifiedMcpServer_fn).call(this, mcpServerConfig, transportOptions);
5220
+ await __privateMethod(this, _ArgParserBase_instances, _startUnifiedMcpServer_fn).call(this, mcpServerConfig, {
5221
+ ...transportOptions,
5222
+ logPath: resolvedLogPath
5223
+ });
4718
5224
  mcpLogger.mcpError("Successfully started unified MCP server");
4719
5225
  } catch (error) {
4720
5226
  mcpLogger.mcpError(
@@ -4783,7 +5289,8 @@ _startUnifiedMcpServer_fn = async function(mcpServerConfig, transportOptions) {
4783
5289
  await mcpParser.startMcpServerWithMultipleTransports(
4784
5290
  serverInfo,
4785
5291
  transportConfigs,
4786
- toolOptions
5292
+ toolOptions,
5293
+ transportOptions.logPath
4787
5294
  );
4788
5295
  } catch (error) {
4789
5296
  throw new Error(
@@ -4794,7 +5301,8 @@ _startUnifiedMcpServer_fn = async function(mcpServerConfig, transportOptions) {
4794
5301
  await mcpParser.startMcpServerWithMultipleTransports(
4795
5302
  serverInfo,
4796
5303
  defaultTransports,
4797
- toolOptions
5304
+ toolOptions,
5305
+ transportOptions.logPath
4798
5306
  );
4799
5307
  } else if (defaultTransport) {
4800
5308
  await mcpParser.startMcpServerWithTransport(
@@ -4806,7 +5314,8 @@ _startUnifiedMcpServer_fn = async function(mcpServerConfig, transportOptions) {
4806
5314
  path: defaultTransport.path,
4807
5315
  sessionIdGenerator: defaultTransport.sessionIdGenerator
4808
5316
  },
4809
- toolOptions
5317
+ toolOptions,
5318
+ transportOptions.logPath
4810
5319
  );
4811
5320
  } else {
4812
5321
  const transportType = transportOptions.transportType || "stdio";
@@ -4819,7 +5328,8 @@ _startUnifiedMcpServer_fn = async function(mcpServerConfig, transportOptions) {
4819
5328
  serverInfo,
4820
5329
  transportType,
4821
5330
  finalTransportOptions,
4822
- toolOptions
5331
+ toolOptions,
5332
+ transportOptions.logPath
4823
5333
  );
4824
5334
  }
4825
5335
  };
@@ -4886,6 +5396,12 @@ _parseMcpTransportOptions_fn = function(processArgs) {
4886
5396
  i++;
4887
5397
  }
4888
5398
  break;
5399
+ case "--s-mcp-log-path":
5400
+ if (nextArg && !nextArg.startsWith("-")) {
5401
+ options.logPath = nextArg;
5402
+ i++;
5403
+ }
5404
+ break;
4889
5405
  // Backward compatibility: support old flags but with deprecation warning
4890
5406
  case "--transport":
4891
5407
  case "--port":
@@ -6171,11 +6687,14 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6171
6687
  * @param toolOptions Optional MCP tool generation options
6172
6688
  * @returns Configured MCP server instance
6173
6689
  */
6174
- async createMcpServer(serverInfo, toolOptions) {
6175
- var _a;
6176
- const logger = simpleMcpLogger.createMcpLogger("MCP Server Creation", "./logs/mcp.log");
6690
+ async createMcpServer(serverInfo, toolOptions, logPath) {
6691
+ var _a, _b;
6692
+ const resolvedLogPath = resolveLogPath(
6693
+ logPath || ((_a = this._mcpServerConfig) == null ? void 0 : _a.logPath) || "./logs/mcp.log"
6694
+ );
6695
+ const logger = simpleMcpLogger.createMcpLogger("MCP Server Creation", resolvedLogPath);
6177
6696
  try {
6178
- const effectiveServerInfo = serverInfo || ((_a = this._mcpServerConfig) == null ? void 0 : _a.serverInfo);
6697
+ const effectiveServerInfo = serverInfo || ((_b = this._mcpServerConfig) == null ? void 0 : _b.serverInfo);
6179
6698
  if (!effectiveServerInfo) {
6180
6699
  throw new Error(
6181
6700
  "No MCP server configuration found. Use withMcp() to configure server info or provide serverInfo parameter."
@@ -6356,11 +6875,11 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6356
6875
  * @param toolOptions Optional MCP tool generation options
6357
6876
  * @returns Promise that resolves when all servers are started
6358
6877
  */
6359
- async startMcpServerWithMultipleTransports(serverInfo, transports, toolOptions) {
6360
- const server = await this.createMcpServer(serverInfo, toolOptions);
6878
+ async startMcpServerWithMultipleTransports(serverInfo, transports, toolOptions, logPath) {
6879
+ const server = await this.createMcpServer(serverInfo, toolOptions, logPath);
6361
6880
  const startPromises = [];
6362
6881
  for (const transportConfig of transports) {
6363
- const promise = __privateMethod(this, _ArgParser_instances, _startSingleTransport_fn).call(this, server, serverInfo, transportConfig);
6882
+ const promise = __privateMethod(this, _ArgParser_instances, _startSingleTransport_fn).call(this, server, serverInfo, transportConfig, logPath);
6364
6883
  startPromises.push(promise);
6365
6884
  }
6366
6885
  await Promise.all(startPromises);
@@ -6373,12 +6892,12 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6373
6892
  * @param toolOptions Optional MCP tool generation options
6374
6893
  * @returns Promise that resolves when server is connected
6375
6894
  */
6376
- async startMcpServerWithTransport(serverInfo, transportType, transportOptions = {}, toolOptions) {
6377
- const server = await this.createMcpServer(serverInfo, toolOptions);
6895
+ async startMcpServerWithTransport(serverInfo, transportType, transportOptions = {}, toolOptions, logPath) {
6896
+ const server = await this.createMcpServer(serverInfo, toolOptions, logPath);
6378
6897
  await __privateMethod(this, _ArgParser_instances, _startSingleTransport_fn).call(this, server, serverInfo, {
6379
6898
  type: transportType,
6380
6899
  ...transportOptions
6381
- });
6900
+ }, logPath);
6382
6901
  }
6383
6902
  async parse(processArgs, options) {
6384
6903
  let result = await ArgParserBase.prototype.parse.call(
@@ -6640,8 +7159,9 @@ registerToolAsSubCommand_fn = function(toolConfig) {
6640
7159
  handler: toolConfig.handler
6641
7160
  });
6642
7161
  };
6643
- _startSingleTransport_fn = async function(server, serverInfo, transportConfig) {
6644
- const logger = simpleMcpLogger.createMcpLogger("MCP Transport", "./logs/mcp.log");
7162
+ _startSingleTransport_fn = async function(server, serverInfo, transportConfig, logPath) {
7163
+ const resolvedLogPath = resolveLogPath(logPath || "./logs/mcp.log");
7164
+ const logger = simpleMcpLogger.createMcpLogger("MCP Transport", resolvedLogPath);
6645
7165
  try {
6646
7166
  logger.mcpError(
6647
7167
  `Starting ${transportConfig.type} transport for server: ${serverInfo.name}`
@@ -6817,7 +7337,9 @@ class TomlConfigPlugin extends ConfigPlugin {
6817
7337
  }
6818
7338
  return parsed;
6819
7339
  } catch (error) {
6820
- throw new Error(`Failed to parse TOML: ${error instanceof Error ? error.message : String(error)}`);
7340
+ throw new Error(
7341
+ `Failed to parse TOML: ${error instanceof Error ? error.message : String(error)}`
7342
+ );
6821
7343
  }
6822
7344
  }
6823
7345
  generate(_config, flags, parsedArgs) {
@@ -6857,7 +7379,9 @@ class TomlConfigPlugin extends ConfigPlugin {
6857
7379
  const tomlContent = this.tomlModule.stringify(configWithValues);
6858
7380
  return lines.join("\n") + "\n" + tomlContent;
6859
7381
  } catch (error) {
6860
- throw new Error(`Failed to generate TOML: ${error instanceof Error ? error.message : String(error)}`);
7382
+ throw new Error(
7383
+ `Failed to generate TOML: ${error instanceof Error ? error.message : String(error)}`
7384
+ );
6861
7385
  }
6862
7386
  }
6863
7387
  /**
@@ -6893,7 +7417,10 @@ function createTomlPlugin() {
6893
7417
  try {
6894
7418
  return new TomlConfigPlugin();
6895
7419
  } catch (error) {
6896
- console.warn("TOML plugin not available:", error instanceof Error ? error.message : String(error));
7420
+ console.warn(
7421
+ "TOML plugin not available:",
7422
+ error instanceof Error ? error.message : String(error)
7423
+ );
6897
7424
  return null;
6898
7425
  }
6899
7426
  }
@@ -6909,7 +7436,10 @@ async function createTomlPluginAsync() {
6909
7436
  const tomlModule = await Promise.resolve().then(() => index$1);
6910
7437
  return new TomlConfigPlugin(tomlModule);
6911
7438
  } catch (error) {
6912
- console.warn("TOML plugin not available:", error instanceof Error ? error.message : String(error));
7439
+ console.warn(
7440
+ "TOML plugin not available:",
7441
+ error instanceof Error ? error.message : String(error)
7442
+ );
6913
7443
  return null;
6914
7444
  }
6915
7445
  }
@@ -6955,7 +7485,9 @@ class YamlConfigPlugin extends ConfigPlugin {
6955
7485
  }
6956
7486
  return parsed;
6957
7487
  } catch (error) {
6958
- throw new Error(`Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`);
7488
+ throw new Error(
7489
+ `Failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`
7490
+ );
6959
7491
  }
6960
7492
  }
6961
7493
  generate(_config, flags, parsedArgs) {
@@ -6989,7 +7521,9 @@ class YamlConfigPlugin extends ConfigPlugin {
6989
7521
  });
6990
7522
  return lines.join("\n") + "\n" + yamlContent;
6991
7523
  } catch (error) {
6992
- throw new Error(`Failed to generate YAML: ${error instanceof Error ? error.message : String(error)}`);
7524
+ throw new Error(
7525
+ `Failed to generate YAML: ${error instanceof Error ? error.message : String(error)}`
7526
+ );
6993
7527
  }
6994
7528
  }
6995
7529
  /**
@@ -7019,7 +7553,10 @@ function createYamlPlugin() {
7019
7553
  try {
7020
7554
  return new YamlConfigPlugin();
7021
7555
  } catch (error) {
7022
- console.warn("YAML plugin not available:", error instanceof Error ? error.message : String(error));
7556
+ console.warn(
7557
+ "YAML plugin not available:",
7558
+ error instanceof Error ? error.message : String(error)
7559
+ );
7023
7560
  return null;
7024
7561
  }
7025
7562
  }
@@ -7035,7 +7572,10 @@ async function createYamlPluginAsync() {
7035
7572
  const yamlModule = await import("js-yaml");
7036
7573
  return new YamlConfigPlugin(yamlModule);
7037
7574
  } catch (error) {
7038
- console.warn("YAML plugin not available:", error instanceof Error ? error.message : String(error));
7575
+ console.warn(
7576
+ "YAML plugin not available:",
7577
+ error instanceof Error ? error.message : String(error)
7578
+ );
7039
7579
  return null;
7040
7580
  }
7041
7581
  }
@@ -7064,7 +7604,9 @@ class ArgParserFuzzyTester {
7064
7604
  const results = [];
7065
7605
  if (this.options.verbose) {
7066
7606
  console.log(`Discovered ${commandPaths.length} command paths:`);
7067
- commandPaths.forEach((path2) => console.log(` ${path2.join(" ") || "(root)"}`));
7607
+ commandPaths.forEach(
7608
+ (path2) => console.log(` ${path2.join(" ") || "(root)"}`)
7609
+ );
7068
7610
  }
7069
7611
  for (const commandPath of commandPaths) {
7070
7612
  const pathResults = await this.testCommandPath(commandPath);
@@ -7090,7 +7632,12 @@ class ArgParserFuzzyTester {
7090
7632
  for (const [subCommandName, subCommand] of subCommands) {
7091
7633
  const newPath = [...currentPath, subCommandName];
7092
7634
  allPaths.push(newPath);
7093
- this.discoverSubCommandPaths(subCommand.parser, newPath, allPaths, depth + 1);
7635
+ this.discoverSubCommandPaths(
7636
+ subCommand.parser,
7637
+ newPath,
7638
+ allPaths,
7639
+ depth + 1
7640
+ );
7094
7641
  }
7095
7642
  }
7096
7643
  /**
@@ -24996,6 +25543,7 @@ exports.OutputSchemaPatterns = OutputSchemaPatterns;
24996
25543
  exports.SimpleChalk = simpleChalk;
24997
25544
  exports.TomlConfigPlugin = TomlConfigPlugin;
24998
25545
  exports.YamlConfigPlugin = YamlConfigPlugin;
25546
+ exports.absolutePath = absolutePath;
24999
25547
  exports.convertFlagToJsonSchemaProperty = convertFlagToJsonSchemaProperty;
25000
25548
  exports.convertFlagsToJsonSchema = convertFlagsToJsonSchema;
25001
25549
  exports.convertFlagsToZodSchema = convertFlagsToZodSchema;
@@ -25007,12 +25555,18 @@ exports.createTomlPlugin = createTomlPlugin;
25007
25555
  exports.createTomlPluginAsync = createTomlPluginAsync;
25008
25556
  exports.createYamlPlugin = createYamlPlugin;
25009
25557
  exports.createYamlPluginAsync = createYamlPluginAsync;
25558
+ exports.cwdRelative = cwdRelative;
25559
+ exports.detectEntryPoint = detectEntryPoint;
25010
25560
  exports.enableConfigPlugins = enableConfigPlugins;
25011
25561
  exports.enableOptionalConfigPlugins = enableOptionalConfigPlugins;
25012
25562
  exports.enableOptionalConfigPluginsAsync = enableOptionalConfigPluginsAsync;
25563
+ exports.entryRelative = entryRelative;
25013
25564
  exports.extractSimplifiedResponse = extractSimplifiedResponse;
25014
25565
  exports.generateMcpToolsFromArgParser = generateMcpToolsFromArgParser;
25566
+ exports.getEntryPointFromImportMeta = getEntryPointFromImportMeta;
25015
25567
  exports.getJsonSchemaTypeFromFlag = getJsonSchemaTypeFromFlag;
25016
25568
  exports.globalConfigPluginRegistry = globalConfigPluginRegistry;
25569
+ exports.legacyCwdPath = legacyCwdPath;
25570
+ exports.resolveLogPath = resolveLogPath;
25017
25571
  exports.zodFlagSchema = zodFlagSchema;
25018
25572
  //# sourceMappingURL=index.cjs.map