@mcpc-tech/cli 0.1.52 → 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/app.cjs CHANGED
@@ -9807,6 +9807,7 @@ var ComposableMCPServer = class extends Server {
9807
9807
  toolManager;
9808
9808
  logger = createLogger("mcpc.compose");
9809
9809
  fileLoaders = /* @__PURE__ */ new Map();
9810
+ pluginsDisposed = false;
9810
9811
  // Legacy property for backward compatibility
9811
9812
  get toolNameMapping() {
9812
9813
  return this.toolManager.getToolNameMapping();
@@ -10282,11 +10283,21 @@ var ComposableMCPServer = class extends Server {
10282
10283
  async disposePlugins() {
10283
10284
  await this.pluginManager.dispose();
10284
10285
  }
10286
+ /**
10287
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
10288
+ */
10289
+ async disposePluginsOnce() {
10290
+ if (this.pluginsDisposed) {
10291
+ return;
10292
+ }
10293
+ this.pluginsDisposed = true;
10294
+ await this.disposePlugins();
10295
+ }
10285
10296
  /**
10286
10297
  * Close the server and ensure all plugins are disposed
10287
10298
  */
10288
10299
  async close() {
10289
- await this.disposePlugins();
10300
+ await this.disposePluginsOnce();
10290
10301
  await super.close();
10291
10302
  }
10292
10303
  async compose(name, description, depsConfig = {
@@ -10391,16 +10402,20 @@ var ComposableMCPServer = class extends Server {
10391
10402
  server: this,
10392
10403
  toolNames: Object.keys(allTools)
10393
10404
  });
10405
+ const previousOnClose = this.onclose;
10394
10406
  this.onclose = async () => {
10395
10407
  await cleanupClients();
10396
- await this.disposePlugins();
10408
+ await this.disposePluginsOnce();
10397
10409
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
10410
+ previousOnClose?.();
10398
10411
  };
10412
+ const previousOnError = this.onerror;
10399
10413
  this.onerror = async (error) => {
10400
10414
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
10401
10415
  await cleanupClients();
10402
- await this.disposePlugins();
10416
+ await this.disposePluginsOnce();
10403
10417
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
10418
+ previousOnError?.(error);
10404
10419
  };
10405
10420
  const toolNameToDetailList = Object.entries(allTools);
10406
10421
  const publicToolNames = this.getPublicToolNames();
@@ -13596,15 +13611,17 @@ var Response2 = class _Response {
13596
13611
  this.#init = init;
13597
13612
  }
13598
13613
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
13599
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
13600
- this[cacheKey] = [init?.status || 200, body, headers];
13614
+ ;
13615
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
13601
13616
  }
13602
13617
  }
13603
13618
  get headers() {
13604
13619
  const cache = this[cacheKey];
13605
13620
  if (cache) {
13606
13621
  if (!(cache[2] instanceof Headers)) {
13607
- cache[2] = new Headers(cache[2]);
13622
+ cache[2] = new Headers(
13623
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
13624
+ );
13608
13625
  }
13609
13626
  return cache[2];
13610
13627
  }
@@ -13729,15 +13746,32 @@ var flushHeaders = (outgoing) => {
13729
13746
  };
13730
13747
  var responseViaCache = async (res, outgoing) => {
13731
13748
  let [status, body, header] = res[cacheKey];
13732
- if (header instanceof Headers) {
13749
+ let hasContentLength = false;
13750
+ if (!header) {
13751
+ header = { "content-type": "text/plain; charset=UTF-8" };
13752
+ } else if (header instanceof Headers) {
13753
+ hasContentLength = header.has("content-length");
13733
13754
  header = buildOutgoingHttpHeaders(header);
13755
+ } else if (Array.isArray(header)) {
13756
+ const headerObj = new Headers(header);
13757
+ hasContentLength = headerObj.has("content-length");
13758
+ header = buildOutgoingHttpHeaders(headerObj);
13759
+ } else {
13760
+ for (const key in header) {
13761
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
13762
+ hasContentLength = true;
13763
+ break;
13764
+ }
13765
+ }
13734
13766
  }
13735
- if (typeof body === "string") {
13736
- header["Content-Length"] = Buffer.byteLength(body);
13737
- } else if (body instanceof Uint8Array) {
13738
- header["Content-Length"] = body.byteLength;
13739
- } else if (body instanceof Blob) {
13740
- header["Content-Length"] = body.size;
13767
+ if (!hasContentLength) {
13768
+ if (typeof body === "string") {
13769
+ header["Content-Length"] = Buffer.byteLength(body);
13770
+ } else if (body instanceof Uint8Array) {
13771
+ header["Content-Length"] = body.byteLength;
13772
+ } else if (body instanceof Blob) {
13773
+ header["Content-Length"] = body.size;
13774
+ }
13741
13775
  }
13742
13776
  outgoing.writeHead(status, header);
13743
13777
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -14891,7 +14925,7 @@ var import_promises4 = require("node:fs/promises");
14891
14925
  var import_node_os3 = require("node:os");
14892
14926
  var import_node_path6 = require("node:path");
14893
14927
  var import_node_process10 = __toESM(require("node:process"), 1);
14894
- var CLI_VERSION = "0.1.52";
14928
+ var CLI_VERSION = "0.1.53";
14895
14929
  function extractServerName(command, commandArgs) {
14896
14930
  for (const arg of commandArgs) {
14897
14931
  if (!arg.startsWith("-")) {
@@ -15314,7 +15348,7 @@ function applyModeOverride(config, mode) {
15314
15348
  agent.options.mode = mode;
15315
15349
  if (mode === "ai_acp" && !agent.options.acpSettings) {
15316
15350
  agent.options.acpSettings = {
15317
- command: "claude-code-acp",
15351
+ command: "claude-agent-acp",
15318
15352
  args: [],
15319
15353
  session: {}
15320
15354
  };
package/app.mjs CHANGED
@@ -9803,6 +9803,7 @@ var ComposableMCPServer = class extends Server {
9803
9803
  toolManager;
9804
9804
  logger = createLogger("mcpc.compose");
9805
9805
  fileLoaders = /* @__PURE__ */ new Map();
9806
+ pluginsDisposed = false;
9806
9807
  // Legacy property for backward compatibility
9807
9808
  get toolNameMapping() {
9808
9809
  return this.toolManager.getToolNameMapping();
@@ -10278,11 +10279,21 @@ var ComposableMCPServer = class extends Server {
10278
10279
  async disposePlugins() {
10279
10280
  await this.pluginManager.dispose();
10280
10281
  }
10282
+ /**
10283
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
10284
+ */
10285
+ async disposePluginsOnce() {
10286
+ if (this.pluginsDisposed) {
10287
+ return;
10288
+ }
10289
+ this.pluginsDisposed = true;
10290
+ await this.disposePlugins();
10291
+ }
10281
10292
  /**
10282
10293
  * Close the server and ensure all plugins are disposed
10283
10294
  */
10284
10295
  async close() {
10285
- await this.disposePlugins();
10296
+ await this.disposePluginsOnce();
10286
10297
  await super.close();
10287
10298
  }
10288
10299
  async compose(name, description, depsConfig = {
@@ -10387,16 +10398,20 @@ var ComposableMCPServer = class extends Server {
10387
10398
  server: this,
10388
10399
  toolNames: Object.keys(allTools)
10389
10400
  });
10401
+ const previousOnClose = this.onclose;
10390
10402
  this.onclose = async () => {
10391
10403
  await cleanupClients();
10392
- await this.disposePlugins();
10404
+ await this.disposePluginsOnce();
10393
10405
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
10406
+ previousOnClose?.();
10394
10407
  };
10408
+ const previousOnError = this.onerror;
10395
10409
  this.onerror = async (error) => {
10396
10410
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
10397
10411
  await cleanupClients();
10398
- await this.disposePlugins();
10412
+ await this.disposePluginsOnce();
10399
10413
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
10414
+ previousOnError?.(error);
10400
10415
  };
10401
10416
  const toolNameToDetailList = Object.entries(allTools);
10402
10417
  const publicToolNames = this.getPublicToolNames();
@@ -13592,15 +13607,17 @@ var Response2 = class _Response {
13592
13607
  this.#init = init;
13593
13608
  }
13594
13609
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
13595
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
13596
- this[cacheKey] = [init?.status || 200, body, headers];
13610
+ ;
13611
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
13597
13612
  }
13598
13613
  }
13599
13614
  get headers() {
13600
13615
  const cache = this[cacheKey];
13601
13616
  if (cache) {
13602
13617
  if (!(cache[2] instanceof Headers)) {
13603
- cache[2] = new Headers(cache[2]);
13618
+ cache[2] = new Headers(
13619
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
13620
+ );
13604
13621
  }
13605
13622
  return cache[2];
13606
13623
  }
@@ -13725,15 +13742,32 @@ var flushHeaders = (outgoing) => {
13725
13742
  };
13726
13743
  var responseViaCache = async (res, outgoing) => {
13727
13744
  let [status, body, header] = res[cacheKey];
13728
- if (header instanceof Headers) {
13745
+ let hasContentLength = false;
13746
+ if (!header) {
13747
+ header = { "content-type": "text/plain; charset=UTF-8" };
13748
+ } else if (header instanceof Headers) {
13749
+ hasContentLength = header.has("content-length");
13729
13750
  header = buildOutgoingHttpHeaders(header);
13751
+ } else if (Array.isArray(header)) {
13752
+ const headerObj = new Headers(header);
13753
+ hasContentLength = headerObj.has("content-length");
13754
+ header = buildOutgoingHttpHeaders(headerObj);
13755
+ } else {
13756
+ for (const key in header) {
13757
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
13758
+ hasContentLength = true;
13759
+ break;
13760
+ }
13761
+ }
13730
13762
  }
13731
- if (typeof body === "string") {
13732
- header["Content-Length"] = Buffer.byteLength(body);
13733
- } else if (body instanceof Uint8Array) {
13734
- header["Content-Length"] = body.byteLength;
13735
- } else if (body instanceof Blob) {
13736
- header["Content-Length"] = body.size;
13763
+ if (!hasContentLength) {
13764
+ if (typeof body === "string") {
13765
+ header["Content-Length"] = Buffer.byteLength(body);
13766
+ } else if (body instanceof Uint8Array) {
13767
+ header["Content-Length"] = body.byteLength;
13768
+ } else if (body instanceof Blob) {
13769
+ header["Content-Length"] = body.size;
13770
+ }
13737
13771
  }
13738
13772
  outgoing.writeHead(status, header);
13739
13773
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -14887,7 +14921,7 @@ import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/p
14887
14921
  import { homedir } from "node:os";
14888
14922
  import { dirname, join as join3, resolve as resolve4 } from "node:path";
14889
14923
  import process10 from "node:process";
14890
- var CLI_VERSION = "0.1.52";
14924
+ var CLI_VERSION = "0.1.53";
14891
14925
  function extractServerName(command, commandArgs) {
14892
14926
  for (const arg of commandArgs) {
14893
14927
  if (!arg.startsWith("-")) {
@@ -15310,7 +15344,7 @@ function applyModeOverride(config, mode) {
15310
15344
  agent.options.mode = mode;
15311
15345
  if (mode === "ai_acp" && !agent.options.acpSettings) {
15312
15346
  agent.options.acpSettings = {
15313
- command: "claude-code-acp",
15347
+ command: "claude-agent-acp",
15314
15348
  args: [],
15315
15349
  session: {}
15316
15350
  };
package/bin/mcpc.cjs CHANGED
@@ -2334,15 +2334,17 @@ var Response2 = class _Response {
2334
2334
  this.#init = init;
2335
2335
  }
2336
2336
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2337
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2338
- this[cacheKey] = [init?.status || 200, body, headers];
2337
+ ;
2338
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2339
2339
  }
2340
2340
  }
2341
2341
  get headers() {
2342
2342
  const cache = this[cacheKey];
2343
2343
  if (cache) {
2344
2344
  if (!(cache[2] instanceof Headers)) {
2345
- cache[2] = new Headers(cache[2]);
2345
+ cache[2] = new Headers(
2346
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2347
+ );
2346
2348
  }
2347
2349
  return cache[2];
2348
2350
  }
@@ -5479,7 +5481,7 @@ function getDefaultAgents() {
5479
5481
  }
5480
5482
 
5481
5483
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5482
- var CLI_VERSION = "0.1.52";
5484
+ var CLI_VERSION = "0.1.53";
5483
5485
  function extractServerName(command, commandArgs) {
5484
5486
  for (const arg of commandArgs) {
5485
5487
  if (!arg.startsWith("-")) {
@@ -5902,7 +5904,7 @@ function applyModeOverride(config, mode) {
5902
5904
  agent.options.mode = mode;
5903
5905
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5904
5906
  agent.options.acpSettings = {
5905
- command: "claude-code-acp",
5907
+ command: "claude-agent-acp",
5906
5908
  args: [],
5907
5909
  session: {}
5908
5910
  };
@@ -13366,6 +13368,7 @@ var ComposableMCPServer = class extends Server {
13366
13368
  toolManager;
13367
13369
  logger = createLogger("mcpc.compose");
13368
13370
  fileLoaders = /* @__PURE__ */ new Map();
13371
+ pluginsDisposed = false;
13369
13372
  // Legacy property for backward compatibility
13370
13373
  get toolNameMapping() {
13371
13374
  return this.toolManager.getToolNameMapping();
@@ -13841,11 +13844,21 @@ var ComposableMCPServer = class extends Server {
13841
13844
  async disposePlugins() {
13842
13845
  await this.pluginManager.dispose();
13843
13846
  }
13847
+ /**
13848
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
13849
+ */
13850
+ async disposePluginsOnce() {
13851
+ if (this.pluginsDisposed) {
13852
+ return;
13853
+ }
13854
+ this.pluginsDisposed = true;
13855
+ await this.disposePlugins();
13856
+ }
13844
13857
  /**
13845
13858
  * Close the server and ensure all plugins are disposed
13846
13859
  */
13847
13860
  async close() {
13848
- await this.disposePlugins();
13861
+ await this.disposePluginsOnce();
13849
13862
  await super.close();
13850
13863
  }
13851
13864
  async compose(name, description, depsConfig = {
@@ -13950,16 +13963,20 @@ var ComposableMCPServer = class extends Server {
13950
13963
  server: this,
13951
13964
  toolNames: Object.keys(allTools)
13952
13965
  });
13966
+ const previousOnClose = this.onclose;
13953
13967
  this.onclose = async () => {
13954
13968
  await cleanupClients();
13955
- await this.disposePlugins();
13969
+ await this.disposePluginsOnce();
13956
13970
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
13971
+ previousOnClose?.();
13957
13972
  };
13973
+ const previousOnError = this.onerror;
13958
13974
  this.onerror = async (error) => {
13959
13975
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13960
13976
  await cleanupClients();
13961
- await this.disposePlugins();
13977
+ await this.disposePluginsOnce();
13962
13978
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
13979
+ previousOnError?.(error);
13963
13980
  };
13964
13981
  const toolNameToDetailList = Object.entries(allTools);
13965
13982
  const publicToolNames = this.getPublicToolNames();
package/bin/mcpc.mjs CHANGED
@@ -2342,15 +2342,17 @@ var Response2 = class _Response {
2342
2342
  this.#init = init;
2343
2343
  }
2344
2344
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2345
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2346
- this[cacheKey] = [init?.status || 200, body, headers];
2345
+ ;
2346
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2347
2347
  }
2348
2348
  }
2349
2349
  get headers() {
2350
2350
  const cache = this[cacheKey];
2351
2351
  if (cache) {
2352
2352
  if (!(cache[2] instanceof Headers)) {
2353
- cache[2] = new Headers(cache[2]);
2353
+ cache[2] = new Headers(
2354
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2355
+ );
2354
2356
  }
2355
2357
  return cache[2];
2356
2358
  }
@@ -5487,7 +5489,7 @@ function getDefaultAgents() {
5487
5489
  }
5488
5490
 
5489
5491
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5490
- var CLI_VERSION = "0.1.52";
5492
+ var CLI_VERSION = "0.1.53";
5491
5493
  function extractServerName(command, commandArgs) {
5492
5494
  for (const arg of commandArgs) {
5493
5495
  if (!arg.startsWith("-")) {
@@ -5910,7 +5912,7 @@ function applyModeOverride(config, mode) {
5910
5912
  agent.options.mode = mode;
5911
5913
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5912
5914
  agent.options.acpSettings = {
5913
- command: "claude-code-acp",
5915
+ command: "claude-agent-acp",
5914
5916
  args: [],
5915
5917
  session: {}
5916
5918
  };
@@ -13373,6 +13375,7 @@ var ComposableMCPServer = class extends Server {
13373
13375
  toolManager;
13374
13376
  logger = createLogger("mcpc.compose");
13375
13377
  fileLoaders = /* @__PURE__ */ new Map();
13378
+ pluginsDisposed = false;
13376
13379
  // Legacy property for backward compatibility
13377
13380
  get toolNameMapping() {
13378
13381
  return this.toolManager.getToolNameMapping();
@@ -13848,11 +13851,21 @@ var ComposableMCPServer = class extends Server {
13848
13851
  async disposePlugins() {
13849
13852
  await this.pluginManager.dispose();
13850
13853
  }
13854
+ /**
13855
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
13856
+ */
13857
+ async disposePluginsOnce() {
13858
+ if (this.pluginsDisposed) {
13859
+ return;
13860
+ }
13861
+ this.pluginsDisposed = true;
13862
+ await this.disposePlugins();
13863
+ }
13851
13864
  /**
13852
13865
  * Close the server and ensure all plugins are disposed
13853
13866
  */
13854
13867
  async close() {
13855
- await this.disposePlugins();
13868
+ await this.disposePluginsOnce();
13856
13869
  await super.close();
13857
13870
  }
13858
13871
  async compose(name, description, depsConfig = {
@@ -13957,16 +13970,20 @@ var ComposableMCPServer = class extends Server {
13957
13970
  server: this,
13958
13971
  toolNames: Object.keys(allTools)
13959
13972
  });
13973
+ const previousOnClose = this.onclose;
13960
13974
  this.onclose = async () => {
13961
13975
  await cleanupClients();
13962
- await this.disposePlugins();
13976
+ await this.disposePluginsOnce();
13963
13977
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
13978
+ previousOnClose?.();
13964
13979
  };
13980
+ const previousOnError = this.onerror;
13965
13981
  this.onerror = async (error) => {
13966
13982
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13967
13983
  await cleanupClients();
13968
- await this.disposePlugins();
13984
+ await this.disposePluginsOnce();
13969
13985
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
13986
+ previousOnError?.(error);
13970
13987
  };
13971
13988
  const toolNameToDetailList = Object.entries(allTools);
13972
13989
  const publicToolNames = this.getPublicToolNames();
package/bin.cjs CHANGED
@@ -2333,15 +2333,17 @@ var Response2 = class _Response {
2333
2333
  this.#init = init;
2334
2334
  }
2335
2335
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2336
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2337
- this[cacheKey] = [init?.status || 200, body, headers];
2336
+ ;
2337
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2338
2338
  }
2339
2339
  }
2340
2340
  get headers() {
2341
2341
  const cache = this[cacheKey];
2342
2342
  if (cache) {
2343
2343
  if (!(cache[2] instanceof Headers)) {
2344
- cache[2] = new Headers(cache[2]);
2344
+ cache[2] = new Headers(
2345
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2346
+ );
2345
2347
  }
2346
2348
  return cache[2];
2347
2349
  }
@@ -5478,7 +5480,7 @@ function getDefaultAgents() {
5478
5480
  }
5479
5481
 
5480
5482
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5481
- var CLI_VERSION = "0.1.52";
5483
+ var CLI_VERSION = "0.1.53";
5482
5484
  function extractServerName(command, commandArgs) {
5483
5485
  for (const arg of commandArgs) {
5484
5486
  if (!arg.startsWith("-")) {
@@ -5901,7 +5903,7 @@ function applyModeOverride(config, mode) {
5901
5903
  agent.options.mode = mode;
5902
5904
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5903
5905
  agent.options.acpSettings = {
5904
- command: "claude-code-acp",
5906
+ command: "claude-agent-acp",
5905
5907
  args: [],
5906
5908
  session: {}
5907
5909
  };
@@ -13365,6 +13367,7 @@ var ComposableMCPServer = class extends Server {
13365
13367
  toolManager;
13366
13368
  logger = createLogger("mcpc.compose");
13367
13369
  fileLoaders = /* @__PURE__ */ new Map();
13370
+ pluginsDisposed = false;
13368
13371
  // Legacy property for backward compatibility
13369
13372
  get toolNameMapping() {
13370
13373
  return this.toolManager.getToolNameMapping();
@@ -13840,11 +13843,21 @@ var ComposableMCPServer = class extends Server {
13840
13843
  async disposePlugins() {
13841
13844
  await this.pluginManager.dispose();
13842
13845
  }
13846
+ /**
13847
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
13848
+ */
13849
+ async disposePluginsOnce() {
13850
+ if (this.pluginsDisposed) {
13851
+ return;
13852
+ }
13853
+ this.pluginsDisposed = true;
13854
+ await this.disposePlugins();
13855
+ }
13843
13856
  /**
13844
13857
  * Close the server and ensure all plugins are disposed
13845
13858
  */
13846
13859
  async close() {
13847
- await this.disposePlugins();
13860
+ await this.disposePluginsOnce();
13848
13861
  await super.close();
13849
13862
  }
13850
13863
  async compose(name, description, depsConfig = {
@@ -13949,16 +13962,20 @@ var ComposableMCPServer = class extends Server {
13949
13962
  server: this,
13950
13963
  toolNames: Object.keys(allTools)
13951
13964
  });
13965
+ const previousOnClose = this.onclose;
13952
13966
  this.onclose = async () => {
13953
13967
  await cleanupClients();
13954
- await this.disposePlugins();
13968
+ await this.disposePluginsOnce();
13955
13969
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
13970
+ previousOnClose?.();
13956
13971
  };
13972
+ const previousOnError = this.onerror;
13957
13973
  this.onerror = async (error) => {
13958
13974
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13959
13975
  await cleanupClients();
13960
- await this.disposePlugins();
13976
+ await this.disposePluginsOnce();
13961
13977
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
13978
+ previousOnError?.(error);
13962
13979
  };
13963
13980
  const toolNameToDetailList = Object.entries(allTools);
13964
13981
  const publicToolNames = this.getPublicToolNames();
package/bin.mjs CHANGED
@@ -2341,15 +2341,17 @@ var Response2 = class _Response {
2341
2341
  this.#init = init;
2342
2342
  }
2343
2343
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2344
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2345
- this[cacheKey] = [init?.status || 200, body, headers];
2344
+ ;
2345
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2346
2346
  }
2347
2347
  }
2348
2348
  get headers() {
2349
2349
  const cache = this[cacheKey];
2350
2350
  if (cache) {
2351
2351
  if (!(cache[2] instanceof Headers)) {
2352
- cache[2] = new Headers(cache[2]);
2352
+ cache[2] = new Headers(
2353
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2354
+ );
2353
2355
  }
2354
2356
  return cache[2];
2355
2357
  }
@@ -5486,7 +5488,7 @@ function getDefaultAgents() {
5486
5488
  }
5487
5489
 
5488
5490
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5489
- var CLI_VERSION = "0.1.52";
5491
+ var CLI_VERSION = "0.1.53";
5490
5492
  function extractServerName(command, commandArgs) {
5491
5493
  for (const arg of commandArgs) {
5492
5494
  if (!arg.startsWith("-")) {
@@ -5909,7 +5911,7 @@ function applyModeOverride(config, mode) {
5909
5911
  agent.options.mode = mode;
5910
5912
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5911
5913
  agent.options.acpSettings = {
5912
- command: "claude-code-acp",
5914
+ command: "claude-agent-acp",
5913
5915
  args: [],
5914
5916
  session: {}
5915
5917
  };
@@ -13372,6 +13374,7 @@ var ComposableMCPServer = class extends Server {
13372
13374
  toolManager;
13373
13375
  logger = createLogger("mcpc.compose");
13374
13376
  fileLoaders = /* @__PURE__ */ new Map();
13377
+ pluginsDisposed = false;
13375
13378
  // Legacy property for backward compatibility
13376
13379
  get toolNameMapping() {
13377
13380
  return this.toolManager.getToolNameMapping();
@@ -13847,11 +13850,21 @@ var ComposableMCPServer = class extends Server {
13847
13850
  async disposePlugins() {
13848
13851
  await this.pluginManager.dispose();
13849
13852
  }
13853
+ /**
13854
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
13855
+ */
13856
+ async disposePluginsOnce() {
13857
+ if (this.pluginsDisposed) {
13858
+ return;
13859
+ }
13860
+ this.pluginsDisposed = true;
13861
+ await this.disposePlugins();
13862
+ }
13850
13863
  /**
13851
13864
  * Close the server and ensure all plugins are disposed
13852
13865
  */
13853
13866
  async close() {
13854
- await this.disposePlugins();
13867
+ await this.disposePluginsOnce();
13855
13868
  await super.close();
13856
13869
  }
13857
13870
  async compose(name, description, depsConfig = {
@@ -13956,16 +13969,20 @@ var ComposableMCPServer = class extends Server {
13956
13969
  server: this,
13957
13970
  toolNames: Object.keys(allTools)
13958
13971
  });
13972
+ const previousOnClose = this.onclose;
13959
13973
  this.onclose = async () => {
13960
13974
  await cleanupClients();
13961
- await this.disposePlugins();
13975
+ await this.disposePluginsOnce();
13962
13976
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
13977
+ previousOnClose?.();
13963
13978
  };
13979
+ const previousOnError = this.onerror;
13964
13980
  this.onerror = async (error) => {
13965
13981
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13966
13982
  await cleanupClients();
13967
- await this.disposePlugins();
13983
+ await this.disposePluginsOnce();
13968
13984
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
13985
+ previousOnError?.(error);
13969
13986
  };
13970
13987
  const toolNameToDetailList = Object.entries(allTools);
13971
13988
  const publicToolNames = this.getPublicToolNames();
package/index.cjs CHANGED
@@ -2587,15 +2587,17 @@ var Response2 = class _Response {
2587
2587
  this.#init = init;
2588
2588
  }
2589
2589
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2590
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2591
- this[cacheKey] = [init?.status || 200, body, headers];
2590
+ ;
2591
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2592
2592
  }
2593
2593
  }
2594
2594
  get headers() {
2595
2595
  const cache = this[cacheKey];
2596
2596
  if (cache) {
2597
2597
  if (!(cache[2] instanceof Headers)) {
2598
- cache[2] = new Headers(cache[2]);
2598
+ cache[2] = new Headers(
2599
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2600
+ );
2599
2601
  }
2600
2602
  return cache[2];
2601
2603
  }
@@ -2720,15 +2722,32 @@ var flushHeaders = (outgoing) => {
2720
2722
  };
2721
2723
  var responseViaCache = async (res, outgoing) => {
2722
2724
  let [status, body, header] = res[cacheKey];
2723
- if (header instanceof Headers) {
2725
+ let hasContentLength = false;
2726
+ if (!header) {
2727
+ header = { "content-type": "text/plain; charset=UTF-8" };
2728
+ } else if (header instanceof Headers) {
2729
+ hasContentLength = header.has("content-length");
2724
2730
  header = buildOutgoingHttpHeaders(header);
2731
+ } else if (Array.isArray(header)) {
2732
+ const headerObj = new Headers(header);
2733
+ hasContentLength = headerObj.has("content-length");
2734
+ header = buildOutgoingHttpHeaders(headerObj);
2735
+ } else {
2736
+ for (const key in header) {
2737
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
2738
+ hasContentLength = true;
2739
+ break;
2740
+ }
2741
+ }
2725
2742
  }
2726
- if (typeof body === "string") {
2727
- header["Content-Length"] = Buffer.byteLength(body);
2728
- } else if (body instanceof Uint8Array) {
2729
- header["Content-Length"] = body.byteLength;
2730
- } else if (body instanceof Blob) {
2731
- header["Content-Length"] = body.size;
2743
+ if (!hasContentLength) {
2744
+ if (typeof body === "string") {
2745
+ header["Content-Length"] = Buffer.byteLength(body);
2746
+ } else if (body instanceof Uint8Array) {
2747
+ header["Content-Length"] = body.byteLength;
2748
+ } else if (body instanceof Blob) {
2749
+ header["Content-Length"] = body.size;
2750
+ }
2732
2751
  }
2733
2752
  outgoing.writeHead(status, header);
2734
2753
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -6710,7 +6729,7 @@ function getDefaultAgents() {
6710
6729
  }
6711
6730
 
6712
6731
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6713
- var CLI_VERSION = "0.1.52";
6732
+ var CLI_VERSION = "0.1.53";
6714
6733
  function extractServerName(command, commandArgs) {
6715
6734
  for (const arg of commandArgs) {
6716
6735
  if (!arg.startsWith("-")) {
@@ -7133,7 +7152,7 @@ function applyModeOverride(config, mode) {
7133
7152
  agent.options.mode = mode;
7134
7153
  if (mode === "ai_acp" && !agent.options.acpSettings) {
7135
7154
  agent.options.acpSettings = {
7136
- command: "claude-code-acp",
7155
+ command: "claude-agent-acp",
7137
7156
  args: [],
7138
7157
  session: {}
7139
7158
  };
@@ -14699,6 +14718,7 @@ var ComposableMCPServer = class extends Server {
14699
14718
  toolManager;
14700
14719
  logger = createLogger("mcpc.compose");
14701
14720
  fileLoaders = /* @__PURE__ */ new Map();
14721
+ pluginsDisposed = false;
14702
14722
  // Legacy property for backward compatibility
14703
14723
  get toolNameMapping() {
14704
14724
  return this.toolManager.getToolNameMapping();
@@ -15174,11 +15194,21 @@ var ComposableMCPServer = class extends Server {
15174
15194
  async disposePlugins() {
15175
15195
  await this.pluginManager.dispose();
15176
15196
  }
15197
+ /**
15198
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
15199
+ */
15200
+ async disposePluginsOnce() {
15201
+ if (this.pluginsDisposed) {
15202
+ return;
15203
+ }
15204
+ this.pluginsDisposed = true;
15205
+ await this.disposePlugins();
15206
+ }
15177
15207
  /**
15178
15208
  * Close the server and ensure all plugins are disposed
15179
15209
  */
15180
15210
  async close() {
15181
- await this.disposePlugins();
15211
+ await this.disposePluginsOnce();
15182
15212
  await super.close();
15183
15213
  }
15184
15214
  async compose(name, description, depsConfig = {
@@ -15283,16 +15313,20 @@ var ComposableMCPServer = class extends Server {
15283
15313
  server: this,
15284
15314
  toolNames: Object.keys(allTools)
15285
15315
  });
15316
+ const previousOnClose = this.onclose;
15286
15317
  this.onclose = async () => {
15287
15318
  await cleanupClients();
15288
- await this.disposePlugins();
15319
+ await this.disposePluginsOnce();
15289
15320
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
15321
+ previousOnClose?.();
15290
15322
  };
15323
+ const previousOnError = this.onerror;
15291
15324
  this.onerror = async (error) => {
15292
15325
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
15293
15326
  await cleanupClients();
15294
- await this.disposePlugins();
15327
+ await this.disposePluginsOnce();
15295
15328
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
15329
+ previousOnError?.(error);
15296
15330
  };
15297
15331
  const toolNameToDetailList = Object.entries(allTools);
15298
15332
  const publicToolNames = this.getPublicToolNames();
package/index.mjs CHANGED
@@ -2580,15 +2580,17 @@ var Response2 = class _Response {
2580
2580
  this.#init = init;
2581
2581
  }
2582
2582
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2583
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2584
- this[cacheKey] = [init?.status || 200, body, headers];
2583
+ ;
2584
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2585
2585
  }
2586
2586
  }
2587
2587
  get headers() {
2588
2588
  const cache = this[cacheKey];
2589
2589
  if (cache) {
2590
2590
  if (!(cache[2] instanceof Headers)) {
2591
- cache[2] = new Headers(cache[2]);
2591
+ cache[2] = new Headers(
2592
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2593
+ );
2592
2594
  }
2593
2595
  return cache[2];
2594
2596
  }
@@ -2713,15 +2715,32 @@ var flushHeaders = (outgoing) => {
2713
2715
  };
2714
2716
  var responseViaCache = async (res, outgoing) => {
2715
2717
  let [status, body, header] = res[cacheKey];
2716
- if (header instanceof Headers) {
2718
+ let hasContentLength = false;
2719
+ if (!header) {
2720
+ header = { "content-type": "text/plain; charset=UTF-8" };
2721
+ } else if (header instanceof Headers) {
2722
+ hasContentLength = header.has("content-length");
2717
2723
  header = buildOutgoingHttpHeaders(header);
2724
+ } else if (Array.isArray(header)) {
2725
+ const headerObj = new Headers(header);
2726
+ hasContentLength = headerObj.has("content-length");
2727
+ header = buildOutgoingHttpHeaders(headerObj);
2728
+ } else {
2729
+ for (const key in header) {
2730
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
2731
+ hasContentLength = true;
2732
+ break;
2733
+ }
2734
+ }
2718
2735
  }
2719
- if (typeof body === "string") {
2720
- header["Content-Length"] = Buffer.byteLength(body);
2721
- } else if (body instanceof Uint8Array) {
2722
- header["Content-Length"] = body.byteLength;
2723
- } else if (body instanceof Blob) {
2724
- header["Content-Length"] = body.size;
2736
+ if (!hasContentLength) {
2737
+ if (typeof body === "string") {
2738
+ header["Content-Length"] = Buffer.byteLength(body);
2739
+ } else if (body instanceof Uint8Array) {
2740
+ header["Content-Length"] = body.byteLength;
2741
+ } else if (body instanceof Blob) {
2742
+ header["Content-Length"] = body.size;
2743
+ }
2725
2744
  }
2726
2745
  outgoing.writeHead(status, header);
2727
2746
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -6703,7 +6722,7 @@ function getDefaultAgents() {
6703
6722
  }
6704
6723
 
6705
6724
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6706
- var CLI_VERSION = "0.1.52";
6725
+ var CLI_VERSION = "0.1.53";
6707
6726
  function extractServerName(command, commandArgs) {
6708
6727
  for (const arg of commandArgs) {
6709
6728
  if (!arg.startsWith("-")) {
@@ -7126,7 +7145,7 @@ function applyModeOverride(config, mode) {
7126
7145
  agent.options.mode = mode;
7127
7146
  if (mode === "ai_acp" && !agent.options.acpSettings) {
7128
7147
  agent.options.acpSettings = {
7129
- command: "claude-code-acp",
7148
+ command: "claude-agent-acp",
7130
7149
  args: [],
7131
7150
  session: {}
7132
7151
  };
@@ -14691,6 +14710,7 @@ var ComposableMCPServer = class extends Server {
14691
14710
  toolManager;
14692
14711
  logger = createLogger("mcpc.compose");
14693
14712
  fileLoaders = /* @__PURE__ */ new Map();
14713
+ pluginsDisposed = false;
14694
14714
  // Legacy property for backward compatibility
14695
14715
  get toolNameMapping() {
14696
14716
  return this.toolManager.getToolNameMapping();
@@ -15166,11 +15186,21 @@ var ComposableMCPServer = class extends Server {
15166
15186
  async disposePlugins() {
15167
15187
  await this.pluginManager.dispose();
15168
15188
  }
15189
+ /**
15190
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
15191
+ */
15192
+ async disposePluginsOnce() {
15193
+ if (this.pluginsDisposed) {
15194
+ return;
15195
+ }
15196
+ this.pluginsDisposed = true;
15197
+ await this.disposePlugins();
15198
+ }
15169
15199
  /**
15170
15200
  * Close the server and ensure all plugins are disposed
15171
15201
  */
15172
15202
  async close() {
15173
- await this.disposePlugins();
15203
+ await this.disposePluginsOnce();
15174
15204
  await super.close();
15175
15205
  }
15176
15206
  async compose(name, description, depsConfig = {
@@ -15275,16 +15305,20 @@ var ComposableMCPServer = class extends Server {
15275
15305
  server: this,
15276
15306
  toolNames: Object.keys(allTools)
15277
15307
  });
15308
+ const previousOnClose = this.onclose;
15278
15309
  this.onclose = async () => {
15279
15310
  await cleanupClients();
15280
- await this.disposePlugins();
15311
+ await this.disposePluginsOnce();
15281
15312
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
15313
+ previousOnClose?.();
15282
15314
  };
15315
+ const previousOnError = this.onerror;
15283
15316
  this.onerror = async (error) => {
15284
15317
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
15285
15318
  await cleanupClients();
15286
- await this.disposePlugins();
15319
+ await this.disposePluginsOnce();
15287
15320
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
15321
+ previousOnError?.(error);
15288
15322
  };
15289
15323
  const toolNameToDetailList = Object.entries(allTools);
15290
15324
  const publicToolNames = this.getPublicToolNames();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "dependencies": {
6
6
  "@hono/zod-openapi": "^0.19.2",
@@ -8,7 +8,7 @@
8
8
  "@modelcontextprotocol/sdk": "^1.8.0",
9
9
  "zod": "^3.24.2",
10
10
  "@ai-sdk/provider": "^2.0.0",
11
- "@mcpc-tech/acp-ai-provider": "^0.1.20",
11
+ "@mcpc-tech/acp-ai-provider": "^0.1.52",
12
12
  "@mcpc-tech/ripgrep-napi": "^0.0.4",
13
13
  "@opentelemetry/api": "^1.9.0",
14
14
  "@opentelemetry/exporter-trace-otlp-http": "^0.56.0",
package/server.cjs CHANGED
@@ -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) {
@@ -6698,7 +6717,7 @@ function getDefaultAgents() {
6698
6717
  }
6699
6718
 
6700
6719
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6701
- var CLI_VERSION = "0.1.52";
6720
+ var CLI_VERSION = "0.1.53";
6702
6721
  function extractServerName(command, commandArgs) {
6703
6722
  for (const arg of commandArgs) {
6704
6723
  if (!arg.startsWith("-")) {
@@ -7121,7 +7140,7 @@ function applyModeOverride(config, mode) {
7121
7140
  agent.options.mode = mode;
7122
7141
  if (mode === "ai_acp" && !agent.options.acpSettings) {
7123
7142
  agent.options.acpSettings = {
7124
- command: "claude-code-acp",
7143
+ command: "claude-agent-acp",
7125
7144
  args: [],
7126
7145
  session: {}
7127
7146
  };
@@ -14676,6 +14695,7 @@ var ComposableMCPServer = class extends Server {
14676
14695
  toolManager;
14677
14696
  logger = createLogger("mcpc.compose");
14678
14697
  fileLoaders = /* @__PURE__ */ new Map();
14698
+ pluginsDisposed = false;
14679
14699
  // Legacy property for backward compatibility
14680
14700
  get toolNameMapping() {
14681
14701
  return this.toolManager.getToolNameMapping();
@@ -15151,11 +15171,21 @@ var ComposableMCPServer = class extends Server {
15151
15171
  async disposePlugins() {
15152
15172
  await this.pluginManager.dispose();
15153
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
+ }
15154
15184
  /**
15155
15185
  * Close the server and ensure all plugins are disposed
15156
15186
  */
15157
15187
  async close() {
15158
- await this.disposePlugins();
15188
+ await this.disposePluginsOnce();
15159
15189
  await super.close();
15160
15190
  }
15161
15191
  async compose(name, description, depsConfig = {
@@ -15260,16 +15290,20 @@ var ComposableMCPServer = class extends Server {
15260
15290
  server: this,
15261
15291
  toolNames: Object.keys(allTools)
15262
15292
  });
15293
+ const previousOnClose = this.onclose;
15263
15294
  this.onclose = async () => {
15264
15295
  await cleanupClients();
15265
- await this.disposePlugins();
15296
+ await this.disposePluginsOnce();
15266
15297
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
15298
+ previousOnClose?.();
15267
15299
  };
15300
+ const previousOnError = this.onerror;
15268
15301
  this.onerror = async (error) => {
15269
15302
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
15270
15303
  await cleanupClients();
15271
- await this.disposePlugins();
15304
+ await this.disposePluginsOnce();
15272
15305
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
15306
+ previousOnError?.(error);
15273
15307
  };
15274
15308
  const toolNameToDetailList = Object.entries(allTools);
15275
15309
  const publicToolNames = this.getPublicToolNames();
package/server.mjs CHANGED
@@ -2583,15 +2583,17 @@ var Response2 = class _Response {
2583
2583
  this.#init = init;
2584
2584
  }
2585
2585
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
2586
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
2587
- this[cacheKey] = [init?.status || 200, body, headers];
2586
+ ;
2587
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2588
2588
  }
2589
2589
  }
2590
2590
  get headers() {
2591
2591
  const cache = this[cacheKey];
2592
2592
  if (cache) {
2593
2593
  if (!(cache[2] instanceof Headers)) {
2594
- cache[2] = new Headers(cache[2]);
2594
+ cache[2] = new Headers(
2595
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2596
+ );
2595
2597
  }
2596
2598
  return cache[2];
2597
2599
  }
@@ -2716,15 +2718,32 @@ var flushHeaders = (outgoing) => {
2716
2718
  };
2717
2719
  var responseViaCache = async (res, outgoing) => {
2718
2720
  let [status, body, header] = res[cacheKey];
2719
- if (header instanceof Headers) {
2721
+ let hasContentLength = false;
2722
+ if (!header) {
2723
+ header = { "content-type": "text/plain; charset=UTF-8" };
2724
+ } else if (header instanceof Headers) {
2725
+ hasContentLength = header.has("content-length");
2720
2726
  header = buildOutgoingHttpHeaders(header);
2727
+ } else if (Array.isArray(header)) {
2728
+ const headerObj = new Headers(header);
2729
+ hasContentLength = headerObj.has("content-length");
2730
+ header = buildOutgoingHttpHeaders(headerObj);
2731
+ } else {
2732
+ for (const key in header) {
2733
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
2734
+ hasContentLength = true;
2735
+ break;
2736
+ }
2737
+ }
2721
2738
  }
2722
- if (typeof body === "string") {
2723
- header["Content-Length"] = Buffer.byteLength(body);
2724
- } else if (body instanceof Uint8Array) {
2725
- header["Content-Length"] = body.byteLength;
2726
- } else if (body instanceof Blob) {
2727
- header["Content-Length"] = body.size;
2739
+ if (!hasContentLength) {
2740
+ if (typeof body === "string") {
2741
+ header["Content-Length"] = Buffer.byteLength(body);
2742
+ } else if (body instanceof Uint8Array) {
2743
+ header["Content-Length"] = body.byteLength;
2744
+ } else if (body instanceof Blob) {
2745
+ header["Content-Length"] = body.size;
2746
+ }
2728
2747
  }
2729
2748
  outgoing.writeHead(status, header);
2730
2749
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -6706,7 +6725,7 @@ function getDefaultAgents() {
6706
6725
  }
6707
6726
 
6708
6727
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6709
- var CLI_VERSION = "0.1.52";
6728
+ var CLI_VERSION = "0.1.53";
6710
6729
  function extractServerName(command, commandArgs) {
6711
6730
  for (const arg of commandArgs) {
6712
6731
  if (!arg.startsWith("-")) {
@@ -7129,7 +7148,7 @@ function applyModeOverride(config, mode) {
7129
7148
  agent.options.mode = mode;
7130
7149
  if (mode === "ai_acp" && !agent.options.acpSettings) {
7131
7150
  agent.options.acpSettings = {
7132
- command: "claude-code-acp",
7151
+ command: "claude-agent-acp",
7133
7152
  args: [],
7134
7153
  session: {}
7135
7154
  };
@@ -14683,6 +14702,7 @@ var ComposableMCPServer = class extends Server {
14683
14702
  toolManager;
14684
14703
  logger = createLogger("mcpc.compose");
14685
14704
  fileLoaders = /* @__PURE__ */ new Map();
14705
+ pluginsDisposed = false;
14686
14706
  // Legacy property for backward compatibility
14687
14707
  get toolNameMapping() {
14688
14708
  return this.toolManager.getToolNameMapping();
@@ -15158,11 +15178,21 @@ var ComposableMCPServer = class extends Server {
15158
15178
  async disposePlugins() {
15159
15179
  await this.pluginManager.dispose();
15160
15180
  }
15181
+ /**
15182
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
15183
+ */
15184
+ async disposePluginsOnce() {
15185
+ if (this.pluginsDisposed) {
15186
+ return;
15187
+ }
15188
+ this.pluginsDisposed = true;
15189
+ await this.disposePlugins();
15190
+ }
15161
15191
  /**
15162
15192
  * Close the server and ensure all plugins are disposed
15163
15193
  */
15164
15194
  async close() {
15165
- await this.disposePlugins();
15195
+ await this.disposePluginsOnce();
15166
15196
  await super.close();
15167
15197
  }
15168
15198
  async compose(name, description, depsConfig = {
@@ -15267,16 +15297,20 @@ var ComposableMCPServer = class extends Server {
15267
15297
  server: this,
15268
15298
  toolNames: Object.keys(allTools)
15269
15299
  });
15300
+ const previousOnClose = this.onclose;
15270
15301
  this.onclose = async () => {
15271
15302
  await cleanupClients();
15272
- await this.disposePlugins();
15303
+ await this.disposePluginsOnce();
15273
15304
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
15305
+ previousOnClose?.();
15274
15306
  };
15307
+ const previousOnError = this.onerror;
15275
15308
  this.onerror = async (error) => {
15276
15309
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
15277
15310
  await cleanupClients();
15278
- await this.disposePlugins();
15311
+ await this.disposePluginsOnce();
15279
15312
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
15313
+ previousOnError?.(error);
15280
15314
  };
15281
15315
  const toolNameToDetailList = Object.entries(allTools);
15282
15316
  const publicToolNames = this.getPublicToolNames();