@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/bin.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;
@@ -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
  }
@@ -2649,7 +2651,7 @@ function parseArgs(args, options) {
2649
2651
  var import_promises4 = require("node:fs/promises");
2650
2652
  var import_node_os3 = require("node:os");
2651
2653
  var import_node_path6 = require("node:path");
2652
- var import_node_process4 = __toESM(require("node:process"), 1);
2654
+ var import_node_process5 = __toESM(require("node:process"), 1);
2653
2655
 
2654
2656
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
2655
2657
  var import_promises = require("node:fs/promises");
@@ -3210,6 +3212,152 @@ Skill path: ${meta.basePath}
3210
3212
  };
3211
3213
  }
3212
3214
 
3215
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
3216
+ var import_node_child_process = require("node:child_process");
3217
+ var import_node_process2 = __toESM(require("node:process"), 1);
3218
+ var DEFAULT_MAX_BYTES = 1e5;
3219
+ var DEFAULT_MAX_LINES = 2e3;
3220
+ var DEFAULT_TIMEOUT_MS = 6e4;
3221
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
3222
+ const fullOutput = (stderr ? `STDERR:
3223
+ ${stderr}
3224
+
3225
+ STDOUT:
3226
+ ` : "") + stdout;
3227
+ const lines = fullOutput.split("\n");
3228
+ if (lines.length > maxLines) {
3229
+ const truncatedLines = lines.slice(-maxLines);
3230
+ return {
3231
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
3232
+
3233
+ ` + truncatedLines.join("\n"),
3234
+ truncated: true
3235
+ };
3236
+ }
3237
+ if (fullOutput.length > maxBytes) {
3238
+ const truncatedBytes = fullOutput.slice(-maxBytes);
3239
+ return {
3240
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
3241
+
3242
+ ` + truncatedBytes,
3243
+ truncated: true
3244
+ };
3245
+ }
3246
+ return {
3247
+ output: fullOutput,
3248
+ truncated: false
3249
+ };
3250
+ }
3251
+ function executeBash(command, cwd2, timeoutMs) {
3252
+ return new Promise((resolve5) => {
3253
+ const stdout = [];
3254
+ const stderr = [];
3255
+ const proc = (0, import_node_child_process.spawn)("bash", [
3256
+ "-c",
3257
+ command
3258
+ ], {
3259
+ cwd: cwd2,
3260
+ stdio: [
3261
+ "ignore",
3262
+ "pipe",
3263
+ "pipe"
3264
+ ]
3265
+ });
3266
+ proc.stdout?.on("data", (data) => {
3267
+ stdout.push(data.toString());
3268
+ });
3269
+ proc.stderr?.on("data", (data) => {
3270
+ stderr.push(data.toString());
3271
+ });
3272
+ proc.on("close", (code) => {
3273
+ resolve5({
3274
+ stdout: stdout.join(""),
3275
+ stderr: stderr.join(""),
3276
+ exitCode: code
3277
+ });
3278
+ });
3279
+ proc.on("error", (err) => {
3280
+ resolve5({
3281
+ stdout: "",
3282
+ stderr: err.message,
3283
+ exitCode: null
3284
+ });
3285
+ });
3286
+ setTimeout(() => {
3287
+ proc.kill("SIGTERM");
3288
+ resolve5({
3289
+ stdout: stdout.join(""),
3290
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
3291
+ exitCode: null
3292
+ });
3293
+ }, timeoutMs);
3294
+ });
3295
+ }
3296
+ function createBashPlugin(options = {}) {
3297
+ const { maxBytes, maxLines, timeoutMs } = {
3298
+ maxBytes: DEFAULT_MAX_BYTES,
3299
+ maxLines: DEFAULT_MAX_LINES,
3300
+ timeoutMs: DEFAULT_TIMEOUT_MS,
3301
+ ...options
3302
+ };
3303
+ let serverRef = null;
3304
+ return {
3305
+ name: "plugin-bash",
3306
+ version: "1.0.0",
3307
+ // Store server reference for tool registration
3308
+ configureServer: (server) => {
3309
+ serverRef = server;
3310
+ },
3311
+ // Register bash tool with agent name prefix
3312
+ composeStart: (context2) => {
3313
+ if (!serverRef) return;
3314
+ const agentName = context2.serverName;
3315
+ const toolName = `${agentName}__bash`;
3316
+ 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.", {
3317
+ type: "object",
3318
+ properties: {
3319
+ command: {
3320
+ type: "string",
3321
+ description: "The bash command to execute"
3322
+ },
3323
+ cwd: {
3324
+ type: "string",
3325
+ description: "Optional: Working directory for the command (defaults to current directory)"
3326
+ }
3327
+ },
3328
+ required: [
3329
+ "command"
3330
+ ]
3331
+ }, async (args) => {
3332
+ const cwd2 = args.cwd || import_node_process2.default.cwd();
3333
+ const result = await executeBash(args.command, cwd2, timeoutMs);
3334
+ const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
3335
+ let finalOutput = output;
3336
+ if (result.exitCode !== null && result.exitCode !== 0) {
3337
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
3338
+ ` + finalOutput;
3339
+ }
3340
+ if (truncated) {
3341
+ finalOutput += `
3342
+
3343
+ [Note: Output was truncated]`;
3344
+ }
3345
+ return {
3346
+ content: [
3347
+ {
3348
+ type: "text",
3349
+ text: finalOutput
3350
+ }
3351
+ ],
3352
+ isError: result.exitCode !== null && result.exitCode !== 0
3353
+ };
3354
+ }, {
3355
+ internal: true
3356
+ });
3357
+ }
3358
+ };
3359
+ }
3360
+
3213
3361
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
3214
3362
  var import_plugin_code_execution = require("@mcpc-tech/plugin-code-execution");
3215
3363
 
@@ -5189,10 +5337,10 @@ function parse(content, options = {}) {
5189
5337
  }
5190
5338
 
5191
5339
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
5192
- var import_node_process2 = __toESM(require("node:process"), 1);
5340
+ var import_node_process3 = __toESM(require("node:process"), 1);
5193
5341
  function replaceEnvVars(str2) {
5194
5342
  return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
5195
- const value = import_node_process2.default.env[varName];
5343
+ const value = import_node_process3.default.env[varName];
5196
5344
  if (value !== void 0) {
5197
5345
  return value;
5198
5346
  }
@@ -5291,18 +5439,19 @@ var defaultPlugin = markdownLoaderPlugin();
5291
5439
 
5292
5440
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
5293
5441
  var import_node_path5 = require("node:path");
5294
- var import_node_process3 = __toESM(require("node:process"), 1);
5442
+ var import_node_process4 = __toESM(require("node:process"), 1);
5295
5443
  var DEFAULT_SKILLS_PATHS = [
5296
5444
  ".agent/skills"
5297
5445
  ];
5298
5446
  var DEFAULT_CODE_EXECUTION_TIMEOUT = 3e5;
5299
5447
  function getGlobalPlugins(skillsPaths) {
5300
- const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process3.default.cwd(), p2));
5448
+ const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process4.default.cwd(), p2));
5301
5449
  return [
5302
5450
  markdownLoaderPlugin(),
5303
5451
  createSkillsPlugin({
5304
5452
  paths: resolvedPaths
5305
- })
5453
+ }),
5454
+ createBashPlugin()
5306
5455
  ];
5307
5456
  }
5308
5457
  function getAgentPlugins() {
@@ -5331,7 +5480,7 @@ function getDefaultAgents() {
5331
5480
  }
5332
5481
 
5333
5482
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5334
- var CLI_VERSION = "0.1.51";
5483
+ var CLI_VERSION = "0.1.53";
5335
5484
  function extractServerName(command, commandArgs) {
5336
5485
  for (const arg of commandArgs) {
5337
5486
  if (!arg.startsWith("-")) {
@@ -5391,7 +5540,7 @@ async function saveUserConfig(config, newAgentName) {
5391
5540
  async function createWrapConfig(args) {
5392
5541
  if (!args.mcpServers || args.mcpServers.length === 0) {
5393
5542
  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'");
5394
- import_node_process4.default.exit(1);
5543
+ import_node_process5.default.exit(1);
5395
5544
  }
5396
5545
  const mcpServers = {};
5397
5546
  const serverNames = [];
@@ -5514,7 +5663,7 @@ function parseMcpServer(cmdString, transportType) {
5514
5663
  };
5515
5664
  }
5516
5665
  function parseCLIArgs() {
5517
- const args = parseArgs(import_node_process4.default.argv.slice(2), {
5666
+ const args = parseArgs(import_node_process5.default.argv.slice(2), {
5518
5667
  boolean: [
5519
5668
  "help",
5520
5669
  "version",
@@ -5603,15 +5752,15 @@ async function loadConfig() {
5603
5752
  const args = parseCLIArgs();
5604
5753
  if (args.version) {
5605
5754
  printVersion();
5606
- import_node_process4.default.exit(0);
5755
+ import_node_process5.default.exit(0);
5607
5756
  }
5608
5757
  if (args.help) {
5609
5758
  printHelp();
5610
- import_node_process4.default.exit(0);
5759
+ import_node_process5.default.exit(0);
5611
5760
  }
5612
5761
  if (args.cwd) {
5613
- const targetCwd = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), args.cwd);
5614
- import_node_process4.default.chdir(targetCwd);
5762
+ const targetCwd = (0, import_node_path6.resolve)(import_node_process5.default.cwd(), args.cwd);
5763
+ import_node_process5.default.chdir(targetCwd);
5615
5764
  console.error(`Changed working directory to: ${targetCwd}`);
5616
5765
  }
5617
5766
  const mergeSkills = (config) => {
@@ -5623,7 +5772,7 @@ async function loadConfig() {
5623
5772
  ...args,
5624
5773
  saveConfig: true
5625
5774
  });
5626
- import_node_process4.default.exit(0);
5775
+ import_node_process5.default.exit(0);
5627
5776
  }
5628
5777
  if (args.wrap) {
5629
5778
  return mergeSkills(await createWrapConfig({
@@ -5640,16 +5789,16 @@ async function loadConfig() {
5640
5789
  throw error;
5641
5790
  }
5642
5791
  }
5643
- if (import_node_process4.default.env.MCPC_CONFIG) {
5792
+ if (import_node_process5.default.env.MCPC_CONFIG) {
5644
5793
  try {
5645
- const parsed = JSON.parse(import_node_process4.default.env.MCPC_CONFIG);
5794
+ const parsed = JSON.parse(import_node_process5.default.env.MCPC_CONFIG);
5646
5795
  return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
5647
5796
  } catch (error) {
5648
5797
  console.error("Failed to parse MCPC_CONFIG environment variable:", error);
5649
5798
  throw error;
5650
5799
  }
5651
5800
  }
5652
- const configUrl = args.configUrl || import_node_process4.default.env.MCPC_CONFIG_URL;
5801
+ const configUrl = args.configUrl || import_node_process5.default.env.MCPC_CONFIG_URL;
5653
5802
  if (configUrl) {
5654
5803
  try {
5655
5804
  const headers = {
@@ -5670,7 +5819,7 @@ async function loadConfig() {
5670
5819
  throw error;
5671
5820
  }
5672
5821
  }
5673
- const configFile = args.configFile || import_node_process4.default.env.MCPC_CONFIG_FILE;
5822
+ const configFile = args.configFile || import_node_process5.default.env.MCPC_CONFIG_FILE;
5674
5823
  if (configFile) {
5675
5824
  try {
5676
5825
  const config = await loadConfigFromFile(configFile);
@@ -5695,7 +5844,7 @@ async function loadConfig() {
5695
5844
  throw error;
5696
5845
  }
5697
5846
  }
5698
- const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), "mcpc.config.json");
5847
+ const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process5.default.cwd(), "mcpc.config.json");
5699
5848
  try {
5700
5849
  const config = await loadConfigFromFile(defaultJsonConfigPath);
5701
5850
  return mergeSkills(applyModeOverride(config, args.mode));
@@ -5710,7 +5859,7 @@ async function loadConfig() {
5710
5859
  }
5711
5860
  function replaceEnvVars2(str2) {
5712
5861
  return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
5713
- return import_node_process4.default.env[varName] || "";
5862
+ return import_node_process5.default.env[varName] || "";
5714
5863
  });
5715
5864
  }
5716
5865
  function isMarkdownFile2(path) {
@@ -5754,7 +5903,7 @@ function applyModeOverride(config, mode) {
5754
5903
  agent.options.mode = mode;
5755
5904
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5756
5905
  agent.options.acpSettings = {
5757
- command: "claude-code-acp",
5906
+ command: "claude-agent-acp",
5758
5907
  args: [],
5759
5908
  session: {}
5760
5909
  };
@@ -8280,9 +8429,9 @@ var Client = class extends Protocol {
8280
8429
 
8281
8430
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
8282
8431
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
8283
- var import_node_process5 = __toESM(require("node:process"), 1);
8432
+ var import_node_process6 = __toESM(require("node:process"), 1);
8284
8433
  var import_node_stream = require("node:stream");
8285
- var DEFAULT_INHERITED_ENV_VARS = import_node_process5.default.platform === "win32" ? [
8434
+ var DEFAULT_INHERITED_ENV_VARS = import_node_process6.default.platform === "win32" ? [
8286
8435
  "APPDATA",
8287
8436
  "HOMEDRIVE",
8288
8437
  "HOMEPATH",
@@ -8302,7 +8451,7 @@ var DEFAULT_INHERITED_ENV_VARS = import_node_process5.default.platform === "win3
8302
8451
  function getDefaultEnvironment() {
8303
8452
  const env = {};
8304
8453
  for (const key of DEFAULT_INHERITED_ENV_VARS) {
8305
- const value = import_node_process5.default.env[key];
8454
+ const value = import_node_process6.default.env[key];
8306
8455
  if (value === void 0) {
8307
8456
  continue;
8308
8457
  }
@@ -8338,7 +8487,7 @@ var StdioClientTransport = class {
8338
8487
  },
8339
8488
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
8340
8489
  shell: false,
8341
- windowsHide: import_node_process5.default.platform === "win32" && isElectron(),
8490
+ windowsHide: import_node_process6.default.platform === "win32" && isElectron(),
8342
8491
  cwd: this._serverParams.cwd
8343
8492
  });
8344
8493
  this._process.on("error", (error) => {
@@ -8446,7 +8595,7 @@ var StdioClientTransport = class {
8446
8595
  }
8447
8596
  };
8448
8597
  function isElectron() {
8449
- return "type" in import_node_process5.default;
8598
+ return "type" in import_node_process6.default;
8450
8599
  }
8451
8600
 
8452
8601
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
@@ -10370,8 +10519,8 @@ var InMemoryTransport = class _InMemoryTransport {
10370
10519
  };
10371
10520
 
10372
10521
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
10373
- var import_node_process6 = __toESM(require("node:process"), 1);
10374
- var GEMINI_PREFERRED_FORMAT = import_node_process6.default.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
10522
+ var import_node_process7 = __toESM(require("node:process"), 1);
10523
+ var GEMINI_PREFERRED_FORMAT = import_node_process7.default.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
10375
10524
 
10376
10525
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
10377
10526
  var import_jsonrepair2 = require("jsonrepair");
@@ -10443,8 +10592,8 @@ var cleanToolSchema = (schema) => {
10443
10592
  };
10444
10593
 
10445
10594
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
10446
- var import_node_process7 = require("node:process");
10447
- var import_node_process8 = __toESM(require("node:process"), 1);
10595
+ var import_node_process8 = require("node:process");
10596
+ var import_node_process9 = __toESM(require("node:process"), 1);
10448
10597
  var import_node_crypto = require("node:crypto");
10449
10598
  function createTransport(def) {
10450
10599
  const defAny = def;
@@ -10485,10 +10634,10 @@ function createTransport(def) {
10485
10634
  command: defAny.command,
10486
10635
  args: defAny.args,
10487
10636
  env: {
10488
- ...import_node_process8.default.env,
10637
+ ...import_node_process9.default.env,
10489
10638
  ...defAny.env ?? {}
10490
10639
  },
10491
- cwd: (0, import_node_process7.cwd)()
10640
+ cwd: (0, import_node_process8.cwd)()
10492
10641
  });
10493
10642
  }
10494
10643
  throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
@@ -11135,7 +11284,7 @@ function endSpan(span, error) {
11135
11284
  }
11136
11285
 
11137
11286
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
11138
- var import_node_process9 = __toESM(require("node:process"), 1);
11287
+ var import_node_process10 = __toESM(require("node:process"), 1);
11139
11288
  var AgenticExecutor = class {
11140
11289
  name;
11141
11290
  allToolNames;
@@ -11155,13 +11304,13 @@ var AgenticExecutor = class {
11155
11304
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
11156
11305
  this.toolSchemaMap = new Map(toolNameToDetailList);
11157
11306
  try {
11158
- this.tracingEnabled = import_node_process9.default.env.MCPC_TRACING_ENABLED === "true";
11307
+ this.tracingEnabled = import_node_process10.default.env.MCPC_TRACING_ENABLED === "true";
11159
11308
  if (this.tracingEnabled) {
11160
11309
  initializeTracing({
11161
11310
  enabled: true,
11162
11311
  serviceName: `mcpc-agentic-${name}`,
11163
- exportTo: import_node_process9.default.env.MCPC_TRACING_EXPORT ?? "otlp",
11164
- otlpEndpoint: import_node_process9.default.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
11312
+ exportTo: import_node_process10.default.env.MCPC_TRACING_EXPORT ?? "otlp",
11313
+ otlpEndpoint: import_node_process10.default.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
11165
11314
  });
11166
11315
  }
11167
11316
  } catch {
@@ -13218,6 +13367,7 @@ var ComposableMCPServer = class extends Server {
13218
13367
  toolManager;
13219
13368
  logger = createLogger("mcpc.compose");
13220
13369
  fileLoaders = /* @__PURE__ */ new Map();
13370
+ pluginsDisposed = false;
13221
13371
  // Legacy property for backward compatibility
13222
13372
  get toolNameMapping() {
13223
13373
  return this.toolManager.getToolNameMapping();
@@ -13693,11 +13843,21 @@ var ComposableMCPServer = class extends Server {
13693
13843
  async disposePlugins() {
13694
13844
  await this.pluginManager.dispose();
13695
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
+ }
13696
13856
  /**
13697
13857
  * Close the server and ensure all plugins are disposed
13698
13858
  */
13699
13859
  async close() {
13700
- await this.disposePlugins();
13860
+ await this.disposePluginsOnce();
13701
13861
  await super.close();
13702
13862
  }
13703
13863
  async compose(name, description, depsConfig = {
@@ -13802,16 +13962,20 @@ var ComposableMCPServer = class extends Server {
13802
13962
  server: this,
13803
13963
  toolNames: Object.keys(allTools)
13804
13964
  });
13965
+ const previousOnClose = this.onclose;
13805
13966
  this.onclose = async () => {
13806
13967
  await cleanupClients();
13807
- await this.disposePlugins();
13968
+ await this.disposePluginsOnce();
13808
13969
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
13970
+ previousOnClose?.();
13809
13971
  };
13972
+ const previousOnError = this.onerror;
13810
13973
  this.onerror = async (error) => {
13811
13974
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13812
13975
  await cleanupClients();
13813
- await this.disposePlugins();
13976
+ await this.disposePluginsOnce();
13814
13977
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
13978
+ previousOnError?.(error);
13815
13979
  };
13816
13980
  const toolNameToDetailList = Object.entries(allTools);
13817
13981
  const publicToolNames = this.getPublicToolNames();
@@ -13876,12 +14040,12 @@ var ComposableMCPServer = class extends Server {
13876
14040
  };
13877
14041
 
13878
14042
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
13879
- var import_node_process10 = __toESM(require("node:process"), 1);
13880
- var isSCF = () => Boolean(import_node_process10.default.env.SCF_RUNTIME || import_node_process10.default.env.PROD_SCF);
14043
+ var import_node_process11 = __toESM(require("node:process"), 1);
14044
+ var isSCF = () => Boolean(import_node_process11.default.env.SCF_RUNTIME || import_node_process11.default.env.PROD_SCF);
13881
14045
  if (isSCF()) {
13882
14046
  console.log({
13883
14047
  isSCF: isSCF(),
13884
- SCF_RUNTIME: import_node_process10.default.env.SCF_RUNTIME
14048
+ SCF_RUNTIME: import_node_process11.default.env.SCF_RUNTIME
13885
14049
  });
13886
14050
  }
13887
14051