@mcpc-tech/cli 0.1.52 → 0.1.54

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.mjs CHANGED
@@ -543,10 +543,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
543
543
  var CursorSchema = z.string();
544
544
  var TaskCreationParamsSchema = z.looseObject({
545
545
  /**
546
- * Time in milliseconds to keep task results available after completion.
547
- * If null, the task has unlimited lifetime until manually cleaned up.
546
+ * Requested duration in milliseconds to retain task from creation.
548
547
  */
549
- ttl: z.union([z.number(), z.null()]).optional(),
548
+ ttl: z.number().optional(),
550
549
  /**
551
550
  * Time in milliseconds to wait between task status requests.
552
551
  */
@@ -846,7 +845,11 @@ var ClientCapabilitiesSchema = z.object({
846
845
  /**
847
846
  * Present if the client supports task creation.
848
847
  */
849
- tasks: ClientTasksCapabilitySchema.optional()
848
+ tasks: ClientTasksCapabilitySchema.optional(),
849
+ /**
850
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
851
+ */
852
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
850
853
  });
851
854
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
852
855
  /**
@@ -907,7 +910,11 @@ var ServerCapabilitiesSchema = z.object({
907
910
  /**
908
911
  * Present if the server supports task creation.
909
912
  */
910
- tasks: ServerTasksCapabilitySchema.optional()
913
+ tasks: ServerTasksCapabilitySchema.optional(),
914
+ /**
915
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
916
+ */
917
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
911
918
  });
912
919
  var InitializeResultSchema = ResultSchema.extend({
913
920
  /**
@@ -1100,6 +1107,12 @@ var ResourceSchema = z.object({
1100
1107
  * The MIME type of this resource, if known.
1101
1108
  */
1102
1109
  mimeType: z.optional(z.string()),
1110
+ /**
1111
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1112
+ *
1113
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1114
+ */
1115
+ size: z.optional(z.number()),
1103
1116
  /**
1104
1117
  * Optional annotations for the client.
1105
1118
  */
@@ -2341,15 +2354,17 @@ var Response2 = class _Response {
2341
2354
  this.#init = init;
2342
2355
  }
2343
2356
  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];
2357
+ ;
2358
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
2346
2359
  }
2347
2360
  }
2348
2361
  get headers() {
2349
2362
  const cache = this[cacheKey];
2350
2363
  if (cache) {
2351
2364
  if (!(cache[2] instanceof Headers)) {
2352
- cache[2] = new Headers(cache[2]);
2365
+ cache[2] = new Headers(
2366
+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
2367
+ );
2353
2368
  }
2354
2369
  return cache[2];
2355
2370
  }
@@ -2383,6 +2398,8 @@ if (typeof global.crypto === "undefined") {
2383
2398
  global.crypto = crypto2;
2384
2399
  }
2385
2400
  var outgoingEnded = Symbol("outgoingEnded");
2401
+ var incomingDraining = Symbol("incomingDraining");
2402
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
2386
2403
 
2387
2404
  // __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
2388
2405
  var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
@@ -5486,7 +5503,7 @@ function getDefaultAgents() {
5486
5503
  }
5487
5504
 
5488
5505
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
5489
- var CLI_VERSION = "0.1.52";
5506
+ var CLI_VERSION = "0.1.54";
5490
5507
  function extractServerName(command, commandArgs) {
5491
5508
  for (const arg of commandArgs) {
5492
5509
  if (!arg.startsWith("-")) {
@@ -5909,7 +5926,7 @@ function applyModeOverride(config, mode) {
5909
5926
  agent.options.mode = mode;
5910
5927
  if (mode === "ai_acp" && !agent.options.acpSettings) {
5911
5928
  agent.options.acpSettings = {
5912
- command: "claude-code-acp",
5929
+ command: "claude-agent-acp",
5913
5930
  args: [],
5914
5931
  session: {}
5915
5932
  };
@@ -6269,6 +6286,10 @@ var Protocol = class {
6269
6286
  this._progressHandlers.clear();
6270
6287
  this._taskProgressTokens.clear();
6271
6288
  this._pendingDebouncedNotifications.clear();
6289
+ for (const info of this._timeoutInfo.values()) {
6290
+ clearTimeout(info.timeoutId);
6291
+ }
6292
+ this._timeoutInfo.clear();
6272
6293
  for (const controller of this._requestHandlerAbortControllers.values()) {
6273
6294
  controller.abort();
6274
6295
  }
@@ -6399,7 +6420,9 @@ var Protocol = class {
6399
6420
  await capturedTransport?.send(errorResponse);
6400
6421
  }
6401
6422
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
6402
- this._requestHandlerAbortControllers.delete(request.id);
6423
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
6424
+ this._requestHandlerAbortControllers.delete(request.id);
6425
+ }
6403
6426
  });
6404
6427
  }
6405
6428
  _onprogress(notification) {
@@ -8493,7 +8516,7 @@ var StdioClientTransport = class {
8493
8516
  },
8494
8517
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
8495
8518
  shell: false,
8496
- windowsHide: process7.platform === "win32" && isElectron(),
8519
+ windowsHide: process7.platform === "win32",
8497
8520
  cwd: this._serverParams.cwd
8498
8521
  });
8499
8522
  this._process.on("error", (error) => {
@@ -8600,9 +8623,6 @@ var StdioClientTransport = class {
8600
8623
  });
8601
8624
  }
8602
8625
  };
8603
- function isElectron() {
8604
- return "type" in process7;
8605
- }
8606
8626
 
8607
8627
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
8608
8628
  var ParseError = class extends Error {
@@ -9347,12 +9367,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
9347
9367
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
9348
9368
  function selectClientAuthMethod(clientInformation, supportedMethods) {
9349
9369
  const hasClientSecret = clientInformation.client_secret !== void 0;
9350
- if (supportedMethods.length === 0) {
9351
- return hasClientSecret ? "client_secret_post" : "none";
9352
- }
9353
- if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && supportedMethods.includes(clientInformation.token_endpoint_auth_method)) {
9370
+ if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
9354
9371
  return clientInformation.token_endpoint_auth_method;
9355
9372
  }
9373
+ if (supportedMethods.length === 0) {
9374
+ return hasClientSecret ? "client_secret_basic" : "none";
9375
+ }
9356
9376
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
9357
9377
  return "client_secret_basic";
9358
9378
  }
@@ -9463,6 +9483,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
9463
9483
  });
9464
9484
  }
9465
9485
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
9486
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
9466
9487
  let clientInformation = await Promise.resolve(provider.clientInformation());
9467
9488
  if (!clientInformation) {
9468
9489
  if (authorizationCode !== void 0) {
@@ -9486,6 +9507,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
9486
9507
  const fullInformation = await registerClient(authorizationServerUrl, {
9487
9508
  metadata,
9488
9509
  clientMetadata: provider.clientMetadata,
9510
+ scope: resolvedScope,
9489
9511
  fetchFn
9490
9512
  });
9491
9513
  await provider.saveClientInformation(fullInformation);
@@ -9529,7 +9551,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
9529
9551
  clientInformation,
9530
9552
  state,
9531
9553
  redirectUrl: provider.redirectUrl,
9532
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
9554
+ scope: resolvedScope,
9533
9555
  resource
9534
9556
  });
9535
9557
  await provider.saveCodeVerifier(codeVerifier);
@@ -9847,7 +9869,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
9847
9869
  fetchFn
9848
9870
  });
9849
9871
  }
9850
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
9872
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
9851
9873
  let registrationUrl;
9852
9874
  if (metadata) {
9853
9875
  if (!metadata.registration_endpoint) {
@@ -9862,7 +9884,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
9862
9884
  headers: {
9863
9885
  "Content-Type": "application/json"
9864
9886
  },
9865
- body: JSON.stringify(clientMetadata)
9887
+ body: JSON.stringify({
9888
+ ...clientMetadata,
9889
+ ...scope !== void 0 ? { scope } : {}
9890
+ })
9866
9891
  });
9867
9892
  if (!response.ok) {
9868
9893
  throw await parseErrorResponse(response);
@@ -10957,7 +10982,7 @@ var SystemPrompts = {
10957
10982
  </rules>
10958
10983
 
10959
10984
  <format>
10960
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
10985
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
10961
10986
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
10962
10987
  </format>`,
10963
10988
  /**
@@ -11082,7 +11107,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
11082
11107
  *
11083
11108
  * Only two fields:
11084
11109
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
11085
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
11110
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
11086
11111
  */
11087
11112
  forAgentic: function(allToolNames) {
11088
11113
  const toolEnum = [
@@ -13033,11 +13058,12 @@ var ToolManager = class {
13033
13058
  /**
13034
13059
  * Register a tool in the registry
13035
13060
  */
13036
- registerTool(name, description, schema, callback, options = {}) {
13061
+ registerTool(name, description, inputSchema, callback, options = {}) {
13037
13062
  this.toolRegistry.set(name, {
13038
13063
  callback,
13039
13064
  description,
13040
- schema
13065
+ inputSchema,
13066
+ outputSchema: options.outputSchema
13041
13067
  });
13042
13068
  if (options.hidden) {
13043
13069
  this.toolConfigs.set(name, {
@@ -13050,13 +13076,16 @@ var ToolManager = class {
13050
13076
  /**
13051
13077
  * Explicitly mark a tool as public (exposed to MCP clients)
13052
13078
  */
13053
- addPublicTool(name, description, schema) {
13079
+ addPublicTool(name, description, inputSchema, outputSchema) {
13054
13080
  const existingTool = this.publicTools.find((t) => t.name === name);
13055
13081
  if (!existingTool) {
13056
13082
  this.publicTools.push({
13057
13083
  name,
13058
13084
  description,
13059
- inputSchema: schema
13085
+ inputSchema,
13086
+ ...outputSchema ? {
13087
+ outputSchema
13088
+ } : {}
13060
13089
  });
13061
13090
  }
13062
13091
  this.toolConfigs.set(name, {
@@ -13182,10 +13211,13 @@ var ToolManager = class {
13182
13211
  getHiddenToolSchema(name) {
13183
13212
  const tool2 = this.toolRegistry.get(name);
13184
13213
  const config = this.toolConfigs.get(name);
13185
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
13214
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
13186
13215
  return {
13187
13216
  description: tool2.description,
13188
- schema: tool2.schema
13217
+ inputSchema: tool2.inputSchema,
13218
+ ...tool2.outputSchema ? {
13219
+ outputSchema: tool2.outputSchema
13220
+ } : {}
13189
13221
  };
13190
13222
  }
13191
13223
  return void 0;
@@ -13221,10 +13253,13 @@ var ToolManager = class {
13221
13253
  composedTools[name] = {
13222
13254
  name,
13223
13255
  description: tool2.description,
13224
- inputSchema: jsonSchema(tool2.schema || {
13256
+ inputSchema: jsonSchema(tool2.inputSchema || {
13225
13257
  type: "object",
13226
13258
  properties: {}
13227
13259
  }),
13260
+ ...tool2.outputSchema ? {
13261
+ outputSchema: jsonSchema(tool2.outputSchema)
13262
+ } : {},
13228
13263
  execute: tool2.callback
13229
13264
  };
13230
13265
  }
@@ -13241,10 +13276,13 @@ var ToolManager = class {
13241
13276
  return {
13242
13277
  name,
13243
13278
  description: tool2.description,
13244
- inputSchema: tool2.schema ?? {
13279
+ inputSchema: tool2.inputSchema ?? {
13245
13280
  type: "object",
13246
13281
  properties: {}
13247
13282
  },
13283
+ ...tool2.outputSchema ? {
13284
+ outputSchema: tool2.outputSchema
13285
+ } : {},
13248
13286
  execute: tool2.callback
13249
13287
  };
13250
13288
  }
@@ -13258,10 +13296,13 @@ var ToolManager = class {
13258
13296
  composedTools.push({
13259
13297
  name,
13260
13298
  description: tool2.description,
13261
- inputSchema: tool2.schema ?? {
13299
+ inputSchema: tool2.inputSchema ?? {
13262
13300
  type: "object",
13263
13301
  properties: {}
13264
13302
  },
13303
+ ...tool2.outputSchema ? {
13304
+ outputSchema: tool2.outputSchema
13305
+ } : {},
13265
13306
  execute: tool2.callback
13266
13307
  });
13267
13308
  }
@@ -13314,7 +13355,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
13314
13355
  const tempTool = {
13315
13356
  name: toolId,
13316
13357
  description: toolData.description,
13317
- inputSchema: toolData.schema || defaultSchema,
13358
+ inputSchema: toolData.inputSchema || defaultSchema,
13359
+ ...toolData.outputSchema ? {
13360
+ outputSchema: toolData.outputSchema
13361
+ } : {},
13318
13362
  execute: toolData.callback
13319
13363
  };
13320
13364
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -13326,7 +13370,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
13326
13370
  },
13327
13371
  transformationIndex: 0
13328
13372
  });
13329
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
13373
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
13374
+ outputSchema: processedTool.outputSchema
13375
+ });
13330
13376
  }
13331
13377
  }
13332
13378
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -13372,6 +13418,7 @@ var ComposableMCPServer = class extends Server {
13372
13418
  toolManager;
13373
13419
  logger = createLogger("mcpc.compose");
13374
13420
  fileLoaders = /* @__PURE__ */ new Map();
13421
+ pluginsDisposed = false;
13375
13422
  // Legacy property for backward compatibility
13376
13423
  get toolNameMapping() {
13377
13424
  return this.toolManager.getToolNameMapping();
@@ -13500,9 +13547,13 @@ var ComposableMCPServer = class extends Server {
13500
13547
  }
13501
13548
  tool(name, description, paramsSchema, cb, options = {}) {
13502
13549
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
13503
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
13550
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
13551
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
13552
+ ...options,
13553
+ outputSchema: outputSchemaObj
13554
+ });
13504
13555
  if (!options.internal) {
13505
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
13556
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
13506
13557
  }
13507
13558
  if (options.plugins) {
13508
13559
  for (const plugin of options.plugins) {
@@ -13759,9 +13810,12 @@ var ComposableMCPServer = class extends Server {
13759
13810
  return {
13760
13811
  name,
13761
13812
  description: tool2?.description || "",
13762
- inputSchema: tool2?.schema || {
13813
+ inputSchema: tool2?.inputSchema || {
13763
13814
  type: "object"
13764
- }
13815
+ },
13816
+ ...tool2?.outputSchema ? {
13817
+ outputSchema: tool2.outputSchema
13818
+ } : {}
13765
13819
  };
13766
13820
  });
13767
13821
  }
@@ -13786,9 +13840,12 @@ var ComposableMCPServer = class extends Server {
13786
13840
  return Array.from(registry.entries()).map(([name, tool2]) => ({
13787
13841
  name,
13788
13842
  description: tool2?.description || "",
13789
- inputSchema: tool2?.schema || {
13843
+ inputSchema: tool2?.inputSchema || {
13790
13844
  type: "object"
13791
- }
13845
+ },
13846
+ ...tool2?.outputSchema ? {
13847
+ outputSchema: tool2.outputSchema
13848
+ } : {}
13792
13849
  }));
13793
13850
  }
13794
13851
  /**
@@ -13847,11 +13904,21 @@ var ComposableMCPServer = class extends Server {
13847
13904
  async disposePlugins() {
13848
13905
  await this.pluginManager.dispose();
13849
13906
  }
13907
+ /**
13908
+ * Dispose plugins only once to avoid duplicated cleanup in chained handlers.
13909
+ */
13910
+ async disposePluginsOnce() {
13911
+ if (this.pluginsDisposed) {
13912
+ return;
13913
+ }
13914
+ this.pluginsDisposed = true;
13915
+ await this.disposePlugins();
13916
+ }
13850
13917
  /**
13851
13918
  * Close the server and ensure all plugins are disposed
13852
13919
  */
13853
13920
  async close() {
13854
- await this.disposePlugins();
13921
+ await this.disposePluginsOnce();
13855
13922
  await super.close();
13856
13923
  }
13857
13924
  async compose(name, description, depsConfig = {
@@ -13920,7 +13987,9 @@ var ComposableMCPServer = class extends Server {
13920
13987
  });
13921
13988
  });
13922
13989
  Object.entries(tools).forEach(([toolId, tool2]) => {
13923
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
13990
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
13991
+ outputSchema: tool2.outputSchema
13992
+ });
13924
13993
  });
13925
13994
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
13926
13995
  const allTools = {
@@ -13956,16 +14025,20 @@ var ComposableMCPServer = class extends Server {
13956
14025
  server: this,
13957
14026
  toolNames: Object.keys(allTools)
13958
14027
  });
14028
+ const previousOnClose = this.onclose;
13959
14029
  this.onclose = async () => {
13960
14030
  await cleanupClients();
13961
- await this.disposePlugins();
14031
+ await this.disposePluginsOnce();
13962
14032
  await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
14033
+ previousOnClose?.();
13963
14034
  };
14035
+ const previousOnError = this.onerror;
13964
14036
  this.onerror = async (error) => {
13965
14037
  await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
13966
14038
  await cleanupClients();
13967
- await this.disposePlugins();
14039
+ await this.disposePluginsOnce();
13968
14040
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
14041
+ previousOnError?.(error);
13969
14042
  };
13970
14043
  const toolNameToDetailList = Object.entries(allTools);
13971
14044
  const publicToolNames = this.getPublicToolNames();
@@ -13977,7 +14050,8 @@ var ComposableMCPServer = class extends Server {
13977
14050
  return;
13978
14051
  }
13979
14052
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
13980
- internal: false
14053
+ internal: false,
14054
+ outputSchema: tool2.outputSchema
13981
14055
  });
13982
14056
  });
13983
14057
  await this.pluginManager.triggerComposeEnd({