@mcpc-tech/cli 0.1.51 → 0.1.53

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/server.cjs CHANGED
@@ -501,7 +501,7 @@ var require_cross_spawn = __commonJS({
501
501
  var cp = require("child_process");
502
502
  var parse2 = require_parse();
503
503
  var enoent = require_enoent();
504
- function spawn2(command, args, options) {
504
+ function spawn3(command, args, options) {
505
505
  const parsed = parse2(command, args, options);
506
506
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
507
507
  enoent.hookChildProcess(spawned, parsed);
@@ -513,8 +513,8 @@ var require_cross_spawn = __commonJS({
513
513
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
514
514
  return result;
515
515
  }
516
- module2.exports = spawn2;
517
- module2.exports.spawn = spawn2;
516
+ module2.exports = spawn3;
517
+ module2.exports.spawn = spawn3;
518
518
  module2.exports.sync = spawnSync;
519
519
  module2.exports._parse = parse2;
520
520
  module2.exports._enoent = enoent;
@@ -2575,15 +2575,17 @@ var Response2 = class _Response {
2575
2575
  this.#init = init;
2576
2576
  }
2577
2577
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2578
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2579
- this[cacheKey] = [init?.status || 200, body, headers];
2578
+ ;
2579
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2580
2580
  }
2581
2581
  }
2582
2582
  get headers() {
2583
2583
  const cache = this[cacheKey];
2584
2584
  if (cache) {
2585
2585
  if (!(cache[2] instanceof Headers)) {
2586
- cache[2] = new Headers(cache[2]);
2586
+ cache[2] = new Headers(
2587
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2588
+ );
2587
2589
  }
2588
2590
  return cache[2];
2589
2591
  }
@@ -2708,15 +2710,32 @@ var flushHeaders = (outgoing) => {
2708
2710
  };
2709
2711
  var responseViaCache = async (res, outgoing) => {
2710
2712
  let [status, body, header] = res[cacheKey];
2711
- if (header instanceof Headers) {
2713
+ let hasContentLength = false;
2714
+ if (!header) {
2715
+ header = { "content-type": "text/plain; charset=UTF-8" };
2716
+ } else if (header instanceof Headers) {
2717
+ hasContentLength = header.has("content-length");
2712
2718
  header = buildOutgoingHttpHeaders(header);
2719
+ } else if (Array.isArray(header)) {
2720
+ const headerObj = new Headers(header);
2721
+ hasContentLength = headerObj.has("content-length");
2722
+ header = buildOutgoingHttpHeaders(headerObj);
2723
+ } else {
2724
+ for (const key in header) {
2725
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
2726
+ hasContentLength = true;
2727
+ break;
2728
+ }
2729
+ }
2713
2730
  }
2714
- if (typeof body === "string") {
2715
- header["Content-Length"] = Buffer.byteLength(body);
2716
- } else if (body instanceof Uint8Array) {
2717
- header["Content-Length"] = body.byteLength;
2718
- } else if (body instanceof Blob) {
2719
- header["Content-Length"] = body.size;
2731
+ if (!hasContentLength) {
2732
+ if (typeof body === "string") {
2733
+ header["Content-Length"] = Buffer.byteLength(body);
2734
+ } else if (body instanceof Uint8Array) {
2735
+ header["Content-Length"] = body.byteLength;
2736
+ } else if (body instanceof Blob) {
2737
+ header["Content-Length"] = body.size;
2738
+ }
2720
2739
  }
2721
2740
  outgoing.writeHead(status, header);
2722
2741
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -3869,7 +3888,7 @@ function parseArgs(args, options) {
3869
3888
  var import_promises4 = require("node:fs/promises");
3870
3889
  var import_node_os3 = require("node:os");
3871
3890
  var import_node_path6 = require("node:path");
3872
- var import_node_process3 = __toESM(require("node:process"), 1);
3891
+ var import_node_process4 = __toESM(require("node:process"), 1);
3873
3892
 
3874
3893
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
3875
3894
  var import_promises = require("node:fs/promises");
@@ -4430,6 +4449,152 @@ Skill path: ${meta.basePath}
4430
4449
  };
4431
4450
  }
4432
4451
 
4452
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
4453
+ var import_node_child_process = require("node:child_process");
4454
+ var import_node_process = __toESM(require("node:process"), 1);
4455
+ var DEFAULT_MAX_BYTES = 1e5;
4456
+ var DEFAULT_MAX_LINES = 2e3;
4457
+ var DEFAULT_TIMEOUT_MS = 6e4;
4458
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
4459
+ const fullOutput = (stderr ? `STDERR:
4460
+ ${stderr}
4461
+
4462
+ STDOUT:
4463
+ ` : "") + stdout;
4464
+ const lines = fullOutput.split("\n");
4465
+ if (lines.length > maxLines) {
4466
+ const truncatedLines = lines.slice(-maxLines);
4467
+ return {
4468
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
4469
+
4470
+ ` + truncatedLines.join("\n"),
4471
+ truncated: true
4472
+ };
4473
+ }
4474
+ if (fullOutput.length > maxBytes) {
4475
+ const truncatedBytes = fullOutput.slice(-maxBytes);
4476
+ return {
4477
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
4478
+
4479
+ ` + truncatedBytes,
4480
+ truncated: true
4481
+ };
4482
+ }
4483
+ return {
4484
+ output: fullOutput,
4485
+ truncated: false
4486
+ };
4487
+ }
4488
+ function executeBash(command, cwd2, timeoutMs) {
4489
+ return new Promise((resolve5) => {
4490
+ const stdout = [];
4491
+ const stderr = [];
4492
+ const proc = (0, import_node_child_process.spawn)("bash", [
4493
+ "-c",
4494
+ command
4495
+ ], {
4496
+ cwd: cwd2,
4497
+ stdio: [
4498
+ "ignore",
4499
+ "pipe",
4500
+ "pipe"
4501
+ ]
4502
+ });
4503
+ proc.stdout?.on("data", (data) => {
4504
+ stdout.push(data.toString());
4505
+ });
4506
+ proc.stderr?.on("data", (data) => {
4507
+ stderr.push(data.toString());
4508
+ });
4509
+ proc.on("close", (code) => {
4510
+ resolve5({
4511
+ stdout: stdout.join(""),
4512
+ stderr: stderr.join(""),
4513
+ exitCode: code
4514
+ });
4515
+ });
4516
+ proc.on("error", (err) => {
4517
+ resolve5({
4518
+ stdout: "",
4519
+ stderr: err.message,
4520
+ exitCode: null
4521
+ });
4522
+ });
4523
+ setTimeout(() => {
4524
+ proc.kill("SIGTERM");
4525
+ resolve5({
4526
+ stdout: stdout.join(""),
4527
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
4528
+ exitCode: null
4529
+ });
4530
+ }, timeoutMs);
4531
+ });
4532
+ }
4533
+ function createBashPlugin(options = {}) {
4534
+ const { maxBytes, maxLines, timeoutMs } = {
4535
+ maxBytes: DEFAULT_MAX_BYTES,
4536
+ maxLines: DEFAULT_MAX_LINES,
4537
+ timeoutMs: DEFAULT_TIMEOUT_MS,
4538
+ ...options
4539
+ };
4540
+ let serverRef = null;
4541
+ return {
4542
+ name: "plugin-bash",
4543
+ version: "1.0.0",
4544
+ // Store server reference for tool registration
4545
+ configureServer: (server) => {
4546
+ serverRef = server;
4547
+ },
4548
+ // Register bash tool with agent name prefix
4549
+ composeStart: (context2) => {
4550
+ if (!serverRef) return;
4551
+ const agentName = context2.serverName;
4552
+ const toolName = `${agentName}__bash`;
4553
+ serverRef.tool(toolName, "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
4554
+ type: "object",
4555
+ properties: {
4556
+ command: {
4557
+ type: "string",
4558
+ description: "The bash command to execute"
4559
+ },
4560
+ cwd: {
4561
+ type: "string",
4562
+ description: "Optional: Working directory for the command (defaults to current directory)"
4563
+ }
4564
+ },
4565
+ required: [
4566
+ "command"
4567
+ ]
4568
+ }, async (args) => {
4569
+ const cwd2 = args.cwd || import_node_process.default.cwd();
4570
+ const result = await executeBash(args.command, cwd2, timeoutMs);
4571
+ const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
4572
+ let finalOutput = output;
4573
+ if (result.exitCode !== null && result.exitCode !== 0) {
4574
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
4575
+ ` + finalOutput;
4576
+ }
4577
+ if (truncated) {
4578
+ finalOutput += `
4579
+
4580
+ [Note: Output was truncated]`;
4581
+ }
4582
+ return {
4583
+ content: [
4584
+ {
4585
+ type: "text",
4586
+ text: finalOutput
4587
+ }
4588
+ ],
4589
+ isError: result.exitCode !== null && result.exitCode !== 0
4590
+ };
4591
+ }, {
4592
+ internal: true
4593
+ });
4594
+ }
4595
+ };
4596
+ }
4597
+
4433
4598
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
4434
4599
  var import_plugin_code_execution = require("@mcpc-tech/plugin-code-execution");
4435
4600
 
@@ -6409,10 +6574,10 @@ function parse(content, options = {}) {
6409
6574
  }
6410
6575
 
6411
6576
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
6412
- var import_node_process = __toESM(require("node:process"), 1);
6577
+ var import_node_process2 = __toESM(require("node:process"), 1);
6413
6578
  function replaceEnvVars(str2) {
6414
6579
  return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
6415
- const value = import_node_process.default.env[varName];
6580
+ const value = import_node_process2.default.env[varName];
6416
6581
  if (value !== void 0) {
6417
6582
  return value;
6418
6583
  }
@@ -6511,18 +6676,19 @@ var defaultPlugin = markdownLoaderPlugin();
6511
6676
 
6512
6677
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
6513
6678
  var import_node_path5 = require("node:path");
6514
- var import_node_process2 = __toESM(require("node:process"), 1);
6679
+ var import_node_process3 = __toESM(require("node:process"), 1);
6515
6680
  var DEFAULT_SKILLS_PATHS = [
6516
6681
  ".agent/skills"
6517
6682
  ];
6518
6683
  var DEFAULT_CODE_EXECUTION_TIMEOUT = 3e5;
6519
6684
  function getGlobalPlugins(skillsPaths) {
6520
- const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process2.default.cwd(), p2));
6685
+ const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process3.default.cwd(), p2));
6521
6686
  return [
6522
6687
  markdownLoaderPlugin(),
6523
6688
  createSkillsPlugin({
6524
6689
  paths: resolvedPaths
6525
- })
6690
+ }),
6691
+ createBashPlugin()
6526
6692
  ];
6527
6693
  }
6528
6694
  function getAgentPlugins() {
@@ -6551,7 +6717,7 @@ function getDefaultAgents() {
6551
6717
  }
6552
6718
 
6553
6719
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6554
- var CLI_VERSION = "0.1.51";
6720
+ var CLI_VERSION = "0.1.53";
6555
6721
  function extractServerName(command, commandArgs) {
6556
6722
  for (const arg of commandArgs) {
6557
6723
  if (!arg.startsWith("-")) {
@@ -6611,7 +6777,7 @@ async function saveUserConfig(config, newAgentName) {
6611
6777
  async function createWrapConfig(args) {
6612
6778
  if (!args.mcpServers || args.mcpServers.length === 0) {
6613
6779
  console.error("Error: --wrap/--add requires at least one MCP server\nExample: mcpc --wrap --mcp-stdio 'npx -y @wonderwhy-er/desktop-commander'\nMultiple: mcpc --add --mcp-stdio 'npx -y server1' --mcp-http 'https://api.example.com'");
6614
- import_node_process3.default.exit(1);
6780
+ import_node_process4.default.exit(1);
6615
6781
  }
6616
6782
  const mcpServers = {};
6617
6783
  const serverNames = [];
@@ -6734,7 +6900,7 @@ function parseMcpServer(cmdString, transportType) {
6734
6900
  };
6735
6901
  }
6736
6902
  function parseCLIArgs() {
6737
- const args = parseArgs(import_node_process3.default.argv.slice(2), {
6903
+ const args = parseArgs(import_node_process4.default.argv.slice(2), {
6738
6904
  boolean: [
6739
6905
  "help",
6740
6906
  "version",
@@ -6823,15 +6989,15 @@ async function loadConfig() {
6823
6989
  const args = parseCLIArgs();
6824
6990
  if (args.version) {
6825
6991
  printVersion();
6826
- import_node_process3.default.exit(0);
6992
+ import_node_process4.default.exit(0);
6827
6993
  }
6828
6994
  if (args.help) {
6829
6995
  printHelp();
6830
- import_node_process3.default.exit(0);
6996
+ import_node_process4.default.exit(0);
6831
6997
  }
6832
6998
  if (args.cwd) {
6833
- const targetCwd = (0, import_node_path6.resolve)(import_node_process3.default.cwd(), args.cwd);
6834
- import_node_process3.default.chdir(targetCwd);
6999
+ const targetCwd = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), args.cwd);
7000
+ import_node_process4.default.chdir(targetCwd);
6835
7001
  console.error(`Changed working directory to: ${targetCwd}`);
6836
7002
  }
6837
7003
  const mergeSkills = (config) => {
@@ -6843,7 +7009,7 @@ async function loadConfig() {
6843
7009
  ...args,
6844
7010
  saveConfig: true
6845
7011
  });
6846
- import_node_process3.default.exit(0);
7012
+ import_node_process4.default.exit(0);
6847
7013
  }
6848
7014
  if (args.wrap) {
6849
7015
  return mergeSkills(await createWrapConfig({
@@ -6860,16 +7026,16 @@ async function loadConfig() {
6860
7026
  throw error;
6861
7027
  }
6862
7028
  }
6863
- if (import_node_process3.default.env.MCPC_CONFIG) {
7029
+ if (import_node_process4.default.env.MCPC_CONFIG) {
6864
7030
  try {
6865
- const parsed = JSON.parse(import_node_process3.default.env.MCPC_CONFIG);
7031
+ const parsed = JSON.parse(import_node_process4.default.env.MCPC_CONFIG);
6866
7032
  return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
6867
7033
  } catch (error) {
6868
7034
  console.error("Failed to parse MCPC_CONFIG environment variable:", error);
6869
7035
  throw error;
6870
7036
  }
6871
7037
  }
6872
- const configUrl = args.configUrl || import_node_process3.default.env.MCPC_CONFIG_URL;
7038
+ const configUrl = args.configUrl || import_node_process4.default.env.MCPC_CONFIG_URL;
6873
7039
  if (configUrl) {
6874
7040
  try {
6875
7041
  const headers = {
@@ -6890,7 +7056,7 @@ async function loadConfig() {
6890
7056
  throw error;
6891
7057
  }
6892
7058
  }
6893
- const configFile = args.configFile || import_node_process3.default.env.MCPC_CONFIG_FILE;
7059
+ const configFile = args.configFile || import_node_process4.default.env.MCPC_CONFIG_FILE;
6894
7060
  if (configFile) {
6895
7061
  try {
6896
7062
  const config = await loadConfigFromFile(configFile);
@@ -6915,7 +7081,7 @@ async function loadConfig() {
6915
7081
  throw error;
6916
7082
  }
6917
7083
  }
6918
- const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process3.default.cwd(), "mcpc.config.json");
7084
+ const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), "mcpc.config.json");
6919
7085
  try {
6920
7086
  const config = await loadConfigFromFile(defaultJsonConfigPath);
6921
7087
  return mergeSkills(applyModeOverride(config, args.mode));
@@ -6930,7 +7096,7 @@ async function loadConfig() {
6930
7096
  }
6931
7097
  function replaceEnvVars2(str2) {
6932
7098
  return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
6933
- return import_node_process3.default.env[varName] || "";
7099
+ return import_node_process4.default.env[varName] || "";
6934
7100
  });
6935
7101
  }
6936
7102
  function isMarkdownFile2(path) {
@@ -6974,7 +7140,7 @@ function applyModeOverride(config, mode) {
6974
7140
  agent.options.mode = mode;
6975
7141
  if (mode === "ai_acp" && !agent.options.acpSettings) {
6976
7142
  agent.options.acpSettings = {
6977
- command: "claude-code-acp",
7143
+ command: "claude-agent-acp",
6978
7144
  args: [],
6979
7145
  session: {}
6980
7146
  };
@@ -9561,7 +9727,7 @@ var Client = class extends Protocol {
9561
9727
 
9562
9728
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
9563
9729
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
9564
- var import_node_process4 = __toESM(require("node:process"), 1);
9730
+ var import_node_process5 = __toESM(require("node:process"), 1);
9565
9731
  var import_node_stream = require("node:stream");
9566
9732
 
9567
9733
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
@@ -9593,7 +9759,7 @@ function serializeMessage(message) {
9593
9759
  }
9594
9760
 
9595
9761
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
9596
- var DEFAULT_INHERITED_ENV_VARS = import_node_process4.default.platform === "win32" ? [
9762
+ var DEFAULT_INHERITED_ENV_VARS = import_node_process5.default.platform === "win32" ? [
9597
9763
  "APPDATA",
9598
9764
  "HOMEDRIVE",
9599
9765
  "HOMEPATH",
@@ -9613,7 +9779,7 @@ var DEFAULT_INHERITED_ENV_VARS = import_node_process4.default.platform === "win3
9613
9779
  function getDefaultEnvironment() {
9614
9780
  const env = {};
9615
9781
  for (const key of DEFAULT_INHERITED_ENV_VARS) {
9616
- const value = import_node_process4.default.env[key];
9782
+ const value = import_node_process5.default.env[key];
9617
9783
  if (value === void 0) {
9618
9784
  continue;
9619
9785
  }
@@ -9649,7 +9815,7 @@ var StdioClientTransport = class {
9649
9815
  },
9650
9816
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
9651
9817
  shell: false,
9652
- windowsHide: import_node_process4.default.platform === "win32" && isElectron(),
9818
+ windowsHide: import_node_process5.default.platform === "win32" && isElectron(),
9653
9819
  cwd: this._serverParams.cwd
9654
9820
  });
9655
9821
  this._process.on("error", (error) => {
@@ -9757,7 +9923,7 @@ var StdioClientTransport = class {
9757
9923
  }
9758
9924
  };
9759
9925
  function isElectron() {
9760
- return "type" in import_node_process4.default;
9926
+ return "type" in import_node_process5.default;
9761
9927
  }
9762
9928
 
9763
9929
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
@@ -11681,8 +11847,8 @@ var InMemoryTransport = class _InMemoryTransport {
11681
11847
  };
11682
11848
 
11683
11849
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
11684
- var import_node_process5 = __toESM(require("node:process"), 1);
11685
- var GEMINI_PREFERRED_FORMAT = import_node_process5.default.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
11850
+ var import_node_process6 = __toESM(require("node:process"), 1);
11851
+ var GEMINI_PREFERRED_FORMAT = import_node_process6.default.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
11686
11852
 
11687
11853
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
11688
11854
  var import_jsonrepair2 = require("jsonrepair");
@@ -11754,8 +11920,8 @@ var cleanToolSchema = (schema) => {
11754
11920
  };
11755
11921
 
11756
11922
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
11757
- var import_node_process6 = require("node:process");
11758
- var import_node_process7 = __toESM(require("node:process"), 1);
11923
+ var import_node_process7 = require("node:process");
11924
+ var import_node_process8 = __toESM(require("node:process"), 1);
11759
11925
  var import_node_crypto = require("node:crypto");
11760
11926
  function createTransport(def) {
11761
11927
  const defAny = def;
@@ -11796,10 +11962,10 @@ function createTransport(def) {
11796
11962
  command: defAny.command,
11797
11963
  args: defAny.args,
11798
11964
  env: {
11799
- ...import_node_process7.default.env,
11965
+ ...import_node_process8.default.env,
11800
11966
  ...defAny.env ?? {}
11801
11967
  },
11802
- cwd: (0, import_node_process6.cwd)()
11968
+ cwd: (0, import_node_process7.cwd)()
11803
11969
  });
11804
11970
  }
11805
11971
  throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
@@ -12446,7 +12612,7 @@ function endSpan(span, error) {
12446
12612
  }
12447
12613
 
12448
12614
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
12449
- var import_node_process8 = __toESM(require("node:process"), 1);
12615
+ var import_node_process9 = __toESM(require("node:process"), 1);
12450
12616
  var AgenticExecutor = class {
12451
12617
  name;
12452
12618
  allToolNames;
@@ -12466,13 +12632,13 @@ var AgenticExecutor = class {
12466
12632
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
12467
12633
  this.toolSchemaMap = new Map(toolNameToDetailList);
12468
12634
  try {
12469
- this.tracingEnabled = import_node_process8.default.env.MCPC_TRACING_ENABLED === "true";
12635
+ this.tracingEnabled = import_node_process9.default.env.MCPC_TRACING_ENABLED === "true";
12470
12636
  if (this.tracingEnabled) {
12471
12637
  initializeTracing({
12472
12638
  enabled: true,
12473
12639
  serviceName: `mcpc-agentic-${name}`,
12474
- exportTo: import_node_process8.default.env.MCPC_TRACING_EXPORT ?? "otlp",
12475
- otlpEndpoint: import_node_process8.default.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
12640
+ exportTo: import_node_process9.default.env.MCPC_TRACING_EXPORT ?? "otlp",
12641
+ otlpEndpoint: import_node_process9.default.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
12476
12642
  });
12477
12643
  }
12478
12644
  } catch {
@@ -14529,6 +14695,7 @@ var ComposableMCPServer = class extends Server {
14529
14695
  toolManager;
14530
14696
  logger = createLogger("mcpc.compose");
14531
14697
  fileLoaders = /* @__PURE__ */ new Map();
14698
+ pluginsDisposed = false;
14532
14699
  // Legacy property for backward compatibility
14533
14700
  get toolNameMapping() {
14534
14701
  return this.toolManager.getToolNameMapping();
@@ -15004,11 +15171,21 @@ var ComposableMCPServer = class extends Server {
15004
15171
  async disposePlugins() {
15005
15172
  await this.pluginManager.dispose();
15006
15173
  }
15174
+ /**
15175
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
15176
+ */
15177
+ async disposePluginsOnce() {
15178
+ if (this.pluginsDisposed) {
15179
+ return;
15180
+ }
15181
+ this.pluginsDisposed = true;
15182
+ await this.disposePlugins();
15183
+ }
15007
15184
  /**
15008
15185
  * Close the server and ensure all plugins are disposed
15009
15186
  */
15010
15187
  async close() {
15011
- await this.disposePlugins();
15188
+ await this.disposePluginsOnce();
15012
15189
  await super.close();
15013
15190
  }
15014
15191
  async compose(name, description, depsConfig = {
@@ -15113,16 +15290,20 @@ var ComposableMCPServer = class extends Server {
15113
15290
  server: this,
15114
15291
  toolNames: Object.keys(allTools)
15115
15292
  });
15293
+ const previousOnClose = this.onclose;
15116
15294
  this.onclose = async () => {
15117
15295
  await cleanupClients();
15118
- await this.disposePlugins();
15296
+ await this.disposePluginsOnce();
15119
15297
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
15298
+ previousOnClose?.();
15120
15299
  };
15300
+ const previousOnError = this.onerror;
15121
15301
  this.onerror = async (error) => {
15122
15302
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
15123
15303
  await cleanupClients();
15124
- await this.disposePlugins();
15304
+ await this.disposePluginsOnce();
15125
15305
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
15306
+ previousOnError?.(error);
15126
15307
  };
15127
15308
  const toolNameToDetailList = Object.entries(allTools);
15128
15309
  const publicToolNames = this.getPublicToolNames();
@@ -15187,12 +15368,12 @@ var ComposableMCPServer = class extends Server {
15187
15368
  };
15188
15369
 
15189
15370
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
15190
- var import_node_process9 = __toESM(require("node:process"), 1);
15191
- var isSCF = () => Boolean(import_node_process9.default.env.SCF_RUNTIME || import_node_process9.default.env.PROD_SCF);
15371
+ var import_node_process10 = __toESM(require("node:process"), 1);
15372
+ var isSCF = () => Boolean(import_node_process10.default.env.SCF_RUNTIME || import_node_process10.default.env.PROD_SCF);
15192
15373
  if (isSCF()) {
15193
15374
  console.log({
15194
15375
  isSCF: isSCF(),
15195
- SCF_RUNTIME: import_node_process9.default.env.SCF_RUNTIME
15376
+ SCF_RUNTIME: import_node_process10.default.env.SCF_RUNTIME
15196
15377
  });
15197
15378
  }
15198
15379
 
@@ -15274,8 +15455,8 @@ var createApp = (config) => {
15274
15455
  };
15275
15456
 
15276
15457
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/server.ts
15277
- var import_node_process10 = __toESM(require("node:process"), 1);
15278
- var port = Number(import_node_process10.default.env.PORT || "3002");
15458
+ var import_node_process11 = __toESM(require("node:process"), 1);
15459
+ var port = Number(import_node_process11.default.env.PORT || "3002");
15279
15460
  var hostname = "0.0.0.0";
15280
15461
  async function main() {
15281
15462
  const config = await loadConfig();