@mcpc-tech/cli 0.1.53 → 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/index.cjs CHANGED
@@ -555,10 +555,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
555
555
  var CursorSchema = z.string();
556
556
  var TaskCreationParamsSchema = z.looseObject({
557
557
  /**
558
- * Time in milliseconds to keep task results available after completion.
559
- * If null, the task has unlimited lifetime until manually cleaned up.
558
+ * Requested duration in milliseconds to retain task from creation.
560
559
  */
561
- ttl: z.union([z.number(), z.null()]).optional(),
560
+ ttl: z.number().optional(),
562
561
  /**
563
562
  * Time in milliseconds to wait between task status requests.
564
563
  */
@@ -858,7 +857,11 @@ var ClientCapabilitiesSchema = z.object({
858
857
  /**
859
858
  * Present if the client supports task creation.
860
859
  */
861
- tasks: ClientTasksCapabilitySchema.optional()
860
+ tasks: ClientTasksCapabilitySchema.optional(),
861
+ /**
862
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
863
+ */
864
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
862
865
  });
863
866
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
864
867
  /**
@@ -920,7 +923,11 @@ var ServerCapabilitiesSchema = z.object({
920
923
  /**
921
924
  * Present if the server supports task creation.
922
925
  */
923
- tasks: ServerTasksCapabilitySchema.optional()
926
+ tasks: ServerTasksCapabilitySchema.optional(),
927
+ /**
928
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
929
+ */
930
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
924
931
  });
925
932
  var InitializeResultSchema = ResultSchema.extend({
926
933
  /**
@@ -1113,6 +1120,12 @@ var ResourceSchema = z.object({
1113
1120
  * The MIME type of this resource, if known.
1114
1121
  */
1115
1122
  mimeType: z.optional(z.string()),
1123
+ /**
1124
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1125
+ *
1126
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1127
+ */
1128
+ size: z.optional(z.number()),
1116
1129
  /**
1117
1130
  * Optional annotations for the client.
1118
1131
  */
@@ -2696,6 +2709,50 @@ if (typeof global.crypto === "undefined") {
2696
2709
  global.crypto = import_crypto.default;
2697
2710
  }
2698
2711
  var outgoingEnded = Symbol("outgoingEnded");
2712
+ var incomingDraining = Symbol("incomingDraining");
2713
+ var DRAIN_TIMEOUT_MS = 500;
2714
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
2715
+ var drainIncoming = (incoming) => {
2716
+ const incomingWithDrainState = incoming;
2717
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
2718
+ return;
2719
+ }
2720
+ incomingWithDrainState[incomingDraining] = true;
2721
+ if (incoming instanceof import_http2.Http2ServerRequest) {
2722
+ try {
2723
+ ;
2724
+ incoming.stream?.close?.(import_http2.constants.NGHTTP2_NO_ERROR);
2725
+ } catch {
2726
+ }
2727
+ return;
2728
+ }
2729
+ let bytesRead = 0;
2730
+ const cleanup = () => {
2731
+ clearTimeout(timer);
2732
+ incoming.off("data", onData);
2733
+ incoming.off("end", cleanup);
2734
+ incoming.off("error", cleanup);
2735
+ };
2736
+ const forceClose = () => {
2737
+ cleanup();
2738
+ const socket = incoming.socket;
2739
+ if (socket && !socket.destroyed) {
2740
+ socket.destroySoon();
2741
+ }
2742
+ };
2743
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
2744
+ timer.unref?.();
2745
+ const onData = (chunk) => {
2746
+ bytesRead += chunk.length;
2747
+ if (bytesRead > MAX_DRAIN_BYTES) {
2748
+ forceClose();
2749
+ }
2750
+ };
2751
+ incoming.on("data", onData);
2752
+ incoming.on("end", cleanup);
2753
+ incoming.on("error", cleanup);
2754
+ incoming.resume();
2755
+ };
2699
2756
  var handleRequestError = () => new Response(null, {
2700
2757
  status: 400
2701
2758
  });
@@ -2867,14 +2924,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
2867
2924
  setTimeout(() => {
2868
2925
  if (!incomingEnded) {
2869
2926
  setTimeout(() => {
2870
- incoming.destroy();
2871
- outgoing.destroy();
2927
+ drainIncoming(incoming);
2872
2928
  });
2873
2929
  }
2874
2930
  });
2875
2931
  }
2876
2932
  };
2877
2933
  }
2934
+ outgoing.on("finish", () => {
2935
+ if (!incomingEnded) {
2936
+ drainIncoming(incoming);
2937
+ }
2938
+ });
2878
2939
  }
2879
2940
  outgoing.on("close", () => {
2880
2941
  const abortController = req[abortControllerKey];
@@ -2889,7 +2950,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
2889
2950
  setTimeout(() => {
2890
2951
  if (!incomingEnded) {
2891
2952
  setTimeout(() => {
2892
- incoming.destroy();
2953
+ drainIncoming(incoming);
2893
2954
  });
2894
2955
  }
2895
2956
  });
@@ -6729,7 +6790,7 @@ function getDefaultAgents() {
6729
6790
  }
6730
6791
 
6731
6792
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6732
- var CLI_VERSION = "0.1.53";
6793
+ var CLI_VERSION = "0.1.54";
6733
6794
  function extractServerName(command, commandArgs) {
6734
6795
  for (const arg of commandArgs) {
6735
6796
  if (!arg.startsWith("-")) {
@@ -7584,6 +7645,10 @@ var Protocol = class {
7584
7645
  this._progressHandlers.clear();
7585
7646
  this._taskProgressTokens.clear();
7586
7647
  this._pendingDebouncedNotifications.clear();
7648
+ for (const info of this._timeoutInfo.values()) {
7649
+ clearTimeout(info.timeoutId);
7650
+ }
7651
+ this._timeoutInfo.clear();
7587
7652
  for (const controller of this._requestHandlerAbortControllers.values()) {
7588
7653
  controller.abort();
7589
7654
  }
@@ -7714,7 +7779,9 @@ var Protocol = class {
7714
7779
  await capturedTransport?.send(errorResponse);
7715
7780
  }
7716
7781
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
7717
- this._requestHandlerAbortControllers.delete(request.id);
7782
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
7783
+ this._requestHandlerAbortControllers.delete(request.id);
7784
+ }
7718
7785
  });
7719
7786
  }
7720
7787
  _onprogress(notification) {
@@ -9838,7 +9905,7 @@ var StdioClientTransport = class {
9838
9905
  },
9839
9906
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
9840
9907
  shell: false,
9841
- windowsHide: import_node_process5.default.platform === "win32" && isElectron(),
9908
+ windowsHide: import_node_process5.default.platform === "win32",
9842
9909
  cwd: this._serverParams.cwd
9843
9910
  });
9844
9911
  this._process.on("error", (error) => {
@@ -9945,9 +10012,6 @@ var StdioClientTransport = class {
9945
10012
  });
9946
10013
  }
9947
10014
  };
9948
- function isElectron() {
9949
- return "type" in import_node_process5.default;
9950
- }
9951
10015
 
9952
10016
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
9953
10017
  var ParseError = class extends Error {
@@ -10692,12 +10756,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
10692
10756
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
10693
10757
  function selectClientAuthMethod(clientInformation, supportedMethods) {
10694
10758
  const hasClientSecret = clientInformation.client_secret !== void 0;
10695
- if (supportedMethods.length === 0) {
10696
- return hasClientSecret ? "client_secret_post" : "none";
10697
- }
10698
- 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)) {
10759
+ 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))) {
10699
10760
  return clientInformation.token_endpoint_auth_method;
10700
10761
  }
10762
+ if (supportedMethods.length === 0) {
10763
+ return hasClientSecret ? "client_secret_basic" : "none";
10764
+ }
10701
10765
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
10702
10766
  return "client_secret_basic";
10703
10767
  }
@@ -10808,6 +10872,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10808
10872
  });
10809
10873
  }
10810
10874
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
10875
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
10811
10876
  let clientInformation = await Promise.resolve(provider.clientInformation());
10812
10877
  if (!clientInformation) {
10813
10878
  if (authorizationCode !== void 0) {
@@ -10831,6 +10896,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10831
10896
  const fullInformation = await registerClient(authorizationServerUrl, {
10832
10897
  metadata,
10833
10898
  clientMetadata: provider.clientMetadata,
10899
+ scope: resolvedScope,
10834
10900
  fetchFn
10835
10901
  });
10836
10902
  await provider.saveClientInformation(fullInformation);
@@ -10874,7 +10940,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10874
10940
  clientInformation,
10875
10941
  state,
10876
10942
  redirectUrl: provider.redirectUrl,
10877
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
10943
+ scope: resolvedScope,
10878
10944
  resource
10879
10945
  });
10880
10946
  await provider.saveCodeVerifier(codeVerifier);
@@ -11192,7 +11258,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
11192
11258
  fetchFn
11193
11259
  });
11194
11260
  }
11195
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
11261
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
11196
11262
  let registrationUrl;
11197
11263
  if (metadata) {
11198
11264
  if (!metadata.registration_endpoint) {
@@ -11207,7 +11273,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
11207
11273
  headers: {
11208
11274
  "Content-Type": "application/json"
11209
11275
  },
11210
- body: JSON.stringify(clientMetadata)
11276
+ body: JSON.stringify({
11277
+ ...clientMetadata,
11278
+ ...scope !== void 0 ? { scope } : {}
11279
+ })
11211
11280
  });
11212
11281
  if (!response.ok) {
11213
11282
  throw await parseErrorResponse(response);
@@ -12302,7 +12371,7 @@ var SystemPrompts = {
12302
12371
  </rules>
12303
12372
 
12304
12373
  <format>
12305
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12374
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12306
12375
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
12307
12376
  </format>`,
12308
12377
  /**
@@ -12427,7 +12496,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
12427
12496
  *
12428
12497
  * Only two fields:
12429
12498
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
12430
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
12499
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
12431
12500
  */
12432
12501
  forAgentic: function(allToolNames) {
12433
12502
  const toolEnum = [
@@ -14379,11 +14448,12 @@ var ToolManager = class {
14379
14448
  /**
14380
14449
  * Register a tool in the registry
14381
14450
  */
14382
- registerTool(name, description, schema, callback, options = {}) {
14451
+ registerTool(name, description, inputSchema, callback, options = {}) {
14383
14452
  this.toolRegistry.set(name, {
14384
14453
  callback,
14385
14454
  description,
14386
- schema
14455
+ inputSchema,
14456
+ outputSchema: options.outputSchema
14387
14457
  });
14388
14458
  if (options.hidden) {
14389
14459
  this.toolConfigs.set(name, {
@@ -14396,13 +14466,16 @@ var ToolManager = class {
14396
14466
  /**
14397
14467
  * Explicitly mark a tool as public (exposed to MCP clients)
14398
14468
  */
14399
- addPublicTool(name, description, schema) {
14469
+ addPublicTool(name, description, inputSchema, outputSchema) {
14400
14470
  const existingTool = this.publicTools.find((t) => t.name === name);
14401
14471
  if (!existingTool) {
14402
14472
  this.publicTools.push({
14403
14473
  name,
14404
14474
  description,
14405
- inputSchema: schema
14475
+ inputSchema,
14476
+ ...outputSchema ? {
14477
+ outputSchema
14478
+ } : {}
14406
14479
  });
14407
14480
  }
14408
14481
  this.toolConfigs.set(name, {
@@ -14528,10 +14601,13 @@ var ToolManager = class {
14528
14601
  getHiddenToolSchema(name) {
14529
14602
  const tool2 = this.toolRegistry.get(name);
14530
14603
  const config = this.toolConfigs.get(name);
14531
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
14604
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
14532
14605
  return {
14533
14606
  description: tool2.description,
14534
- schema: tool2.schema
14607
+ inputSchema: tool2.inputSchema,
14608
+ ...tool2.outputSchema ? {
14609
+ outputSchema: tool2.outputSchema
14610
+ } : {}
14535
14611
  };
14536
14612
  }
14537
14613
  return void 0;
@@ -14567,10 +14643,13 @@ var ToolManager = class {
14567
14643
  composedTools[name] = {
14568
14644
  name,
14569
14645
  description: tool2.description,
14570
- inputSchema: jsonSchema(tool2.schema || {
14646
+ inputSchema: jsonSchema(tool2.inputSchema || {
14571
14647
  type: "object",
14572
14648
  properties: {}
14573
14649
  }),
14650
+ ...tool2.outputSchema ? {
14651
+ outputSchema: jsonSchema(tool2.outputSchema)
14652
+ } : {},
14574
14653
  execute: tool2.callback
14575
14654
  };
14576
14655
  }
@@ -14587,10 +14666,13 @@ var ToolManager = class {
14587
14666
  return {
14588
14667
  name,
14589
14668
  description: tool2.description,
14590
- inputSchema: tool2.schema ?? {
14669
+ inputSchema: tool2.inputSchema ?? {
14591
14670
  type: "object",
14592
14671
  properties: {}
14593
14672
  },
14673
+ ...tool2.outputSchema ? {
14674
+ outputSchema: tool2.outputSchema
14675
+ } : {},
14594
14676
  execute: tool2.callback
14595
14677
  };
14596
14678
  }
@@ -14604,10 +14686,13 @@ var ToolManager = class {
14604
14686
  composedTools.push({
14605
14687
  name,
14606
14688
  description: tool2.description,
14607
- inputSchema: tool2.schema ?? {
14689
+ inputSchema: tool2.inputSchema ?? {
14608
14690
  type: "object",
14609
14691
  properties: {}
14610
14692
  },
14693
+ ...tool2.outputSchema ? {
14694
+ outputSchema: tool2.outputSchema
14695
+ } : {},
14611
14696
  execute: tool2.callback
14612
14697
  });
14613
14698
  }
@@ -14660,7 +14745,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14660
14745
  const tempTool = {
14661
14746
  name: toolId,
14662
14747
  description: toolData.description,
14663
- inputSchema: toolData.schema || defaultSchema,
14748
+ inputSchema: toolData.inputSchema || defaultSchema,
14749
+ ...toolData.outputSchema ? {
14750
+ outputSchema: toolData.outputSchema
14751
+ } : {},
14664
14752
  execute: toolData.callback
14665
14753
  };
14666
14754
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -14672,7 +14760,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14672
14760
  },
14673
14761
  transformationIndex: 0
14674
14762
  });
14675
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
14763
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
14764
+ outputSchema: processedTool.outputSchema
14765
+ });
14676
14766
  }
14677
14767
  }
14678
14768
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -14847,9 +14937,13 @@ var ComposableMCPServer = class extends Server {
14847
14937
  }
14848
14938
  tool(name, description, paramsSchema, cb, options = {}) {
14849
14939
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
14850
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
14940
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
14941
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
14942
+ ...options,
14943
+ outputSchema: outputSchemaObj
14944
+ });
14851
14945
  if (!options.internal) {
14852
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
14946
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
14853
14947
  }
14854
14948
  if (options.plugins) {
14855
14949
  for (const plugin of options.plugins) {
@@ -15106,9 +15200,12 @@ var ComposableMCPServer = class extends Server {
15106
15200
  return {
15107
15201
  name,
15108
15202
  description: tool2?.description || "",
15109
- inputSchema: tool2?.schema || {
15203
+ inputSchema: tool2?.inputSchema || {
15110
15204
  type: "object"
15111
- }
15205
+ },
15206
+ ...tool2?.outputSchema ? {
15207
+ outputSchema: tool2.outputSchema
15208
+ } : {}
15112
15209
  };
15113
15210
  });
15114
15211
  }
@@ -15133,9 +15230,12 @@ var ComposableMCPServer = class extends Server {
15133
15230
  return Array.from(registry.entries()).map(([name, tool2]) => ({
15134
15231
  name,
15135
15232
  description: tool2?.description || "",
15136
- inputSchema: tool2?.schema || {
15233
+ inputSchema: tool2?.inputSchema || {
15137
15234
  type: "object"
15138
- }
15235
+ },
15236
+ ...tool2?.outputSchema ? {
15237
+ outputSchema: tool2.outputSchema
15238
+ } : {}
15139
15239
  }));
15140
15240
  }
15141
15241
  /**
@@ -15277,7 +15377,9 @@ var ComposableMCPServer = class extends Server {
15277
15377
  });
15278
15378
  });
15279
15379
  Object.entries(tools).forEach(([toolId, tool2]) => {
15280
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
15380
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
15381
+ outputSchema: tool2.outputSchema
15382
+ });
15281
15383
  });
15282
15384
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
15283
15385
  const allTools = {
@@ -15338,7 +15440,8 @@ var ComposableMCPServer = class extends Server {
15338
15440
  return;
15339
15441
  }
15340
15442
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
15341
- internal: false
15443
+ internal: false,
15444
+ outputSchema: tool2.outputSchema
15342
15445
  });
15343
15446
  });
15344
15447
  await this.pluginManager.triggerComposeEnd({