@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/server.cjs 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
  /**
@@ -908,7 +911,11 @@ var ServerCapabilitiesSchema = z.object({
908
911
  /**
909
912
  * Present if the server supports task creation.
910
913
  */
911
- tasks: ServerTasksCapabilitySchema.optional()
914
+ tasks: ServerTasksCapabilitySchema.optional(),
915
+ /**
916
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
917
+ */
918
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
912
919
  });
913
920
  var InitializeResultSchema = ResultSchema.extend({
914
921
  /**
@@ -1101,6 +1108,12 @@ var ResourceSchema = z.object({
1101
1108
  * The MIME type of this resource, if known.
1102
1109
  */
1103
1110
  mimeType: z.optional(z.string()),
1111
+ /**
1112
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1113
+ *
1114
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1115
+ */
1116
+ size: z.optional(z.number()),
1104
1117
  /**
1105
1118
  * Optional annotations for the client.
1106
1119
  */
@@ -2684,6 +2697,50 @@ if (typeof global.crypto === "undefined") {
2684
2697
  global.crypto = import_crypto.default;
2685
2698
  }
2686
2699
  var outgoingEnded = Symbol("outgoingEnded");
2700
+ var incomingDraining = Symbol("incomingDraining");
2701
+ var DRAIN_TIMEOUT_MS = 500;
2702
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
2703
+ var drainIncoming = (incoming) => {
2704
+ const incomingWithDrainState = incoming;
2705
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
2706
+ return;
2707
+ }
2708
+ incomingWithDrainState[incomingDraining] = true;
2709
+ if (incoming instanceof import_http2.Http2ServerRequest) {
2710
+ try {
2711
+ ;
2712
+ incoming.stream?.close?.(import_http2.constants.NGHTTP2_NO_ERROR);
2713
+ } catch {
2714
+ }
2715
+ return;
2716
+ }
2717
+ let bytesRead = 0;
2718
+ const cleanup = () => {
2719
+ clearTimeout(timer);
2720
+ incoming.off("data", onData);
2721
+ incoming.off("end", cleanup);
2722
+ incoming.off("error", cleanup);
2723
+ };
2724
+ const forceClose = () => {
2725
+ cleanup();
2726
+ const socket = incoming.socket;
2727
+ if (socket && !socket.destroyed) {
2728
+ socket.destroySoon();
2729
+ }
2730
+ };
2731
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
2732
+ timer.unref?.();
2733
+ const onData = (chunk) => {
2734
+ bytesRead += chunk.length;
2735
+ if (bytesRead > MAX_DRAIN_BYTES) {
2736
+ forceClose();
2737
+ }
2738
+ };
2739
+ incoming.on("data", onData);
2740
+ incoming.on("end", cleanup);
2741
+ incoming.on("error", cleanup);
2742
+ incoming.resume();
2743
+ };
2687
2744
  var handleRequestError = () => new Response(null, {
2688
2745
  status: 400
2689
2746
  });
@@ -2855,14 +2912,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
2855
2912
  setTimeout(() => {
2856
2913
  if (!incomingEnded) {
2857
2914
  setTimeout(() => {
2858
- incoming.destroy();
2859
- outgoing.destroy();
2915
+ drainIncoming(incoming);
2860
2916
  });
2861
2917
  }
2862
2918
  });
2863
2919
  }
2864
2920
  };
2865
2921
  }
2922
+ outgoing.on("finish", () => {
2923
+ if (!incomingEnded) {
2924
+ drainIncoming(incoming);
2925
+ }
2926
+ });
2866
2927
  }
2867
2928
  outgoing.on("close", () => {
2868
2929
  const abortController = req[abortControllerKey];
@@ -2877,7 +2938,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
2877
2938
  setTimeout(() => {
2878
2939
  if (!incomingEnded) {
2879
2940
  setTimeout(() => {
2880
- incoming.destroy();
2941
+ drainIncoming(incoming);
2881
2942
  });
2882
2943
  }
2883
2944
  });
@@ -6717,7 +6778,7 @@ function getDefaultAgents() {
6717
6778
  }
6718
6779
 
6719
6780
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6720
- var CLI_VERSION = "0.1.53";
6781
+ var CLI_VERSION = "0.1.54";
6721
6782
  function extractServerName(command, commandArgs) {
6722
6783
  for (const arg of commandArgs) {
6723
6784
  if (!arg.startsWith("-")) {
@@ -7561,6 +7622,10 @@ var Protocol = class {
7561
7622
  this._progressHandlers.clear();
7562
7623
  this._taskProgressTokens.clear();
7563
7624
  this._pendingDebouncedNotifications.clear();
7625
+ for (const info of this._timeoutInfo.values()) {
7626
+ clearTimeout(info.timeoutId);
7627
+ }
7628
+ this._timeoutInfo.clear();
7564
7629
  for (const controller of this._requestHandlerAbortControllers.values()) {
7565
7630
  controller.abort();
7566
7631
  }
@@ -7691,7 +7756,9 @@ var Protocol = class {
7691
7756
  await capturedTransport?.send(errorResponse);
7692
7757
  }
7693
7758
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
7694
- this._requestHandlerAbortControllers.delete(request.id);
7759
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
7760
+ this._requestHandlerAbortControllers.delete(request.id);
7761
+ }
7695
7762
  });
7696
7763
  }
7697
7764
  _onprogress(notification) {
@@ -9815,7 +9882,7 @@ var StdioClientTransport = class {
9815
9882
  },
9816
9883
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
9817
9884
  shell: false,
9818
- windowsHide: import_node_process5.default.platform === "win32" && isElectron(),
9885
+ windowsHide: import_node_process5.default.platform === "win32",
9819
9886
  cwd: this._serverParams.cwd
9820
9887
  });
9821
9888
  this._process.on("error", (error) => {
@@ -9922,9 +9989,6 @@ var StdioClientTransport = class {
9922
9989
  });
9923
9990
  }
9924
9991
  };
9925
- function isElectron() {
9926
- return "type" in import_node_process5.default;
9927
- }
9928
9992
 
9929
9993
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
9930
9994
  var ParseError = class extends Error {
@@ -10669,12 +10733,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
10669
10733
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
10670
10734
  function selectClientAuthMethod(clientInformation, supportedMethods) {
10671
10735
  const hasClientSecret = clientInformation.client_secret !== void 0;
10672
- if (supportedMethods.length === 0) {
10673
- return hasClientSecret ? "client_secret_post" : "none";
10674
- }
10675
- 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)) {
10736
+ 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))) {
10676
10737
  return clientInformation.token_endpoint_auth_method;
10677
10738
  }
10739
+ if (supportedMethods.length === 0) {
10740
+ return hasClientSecret ? "client_secret_basic" : "none";
10741
+ }
10678
10742
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
10679
10743
  return "client_secret_basic";
10680
10744
  }
@@ -10785,6 +10849,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10785
10849
  });
10786
10850
  }
10787
10851
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
10852
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
10788
10853
  let clientInformation = await Promise.resolve(provider.clientInformation());
10789
10854
  if (!clientInformation) {
10790
10855
  if (authorizationCode !== void 0) {
@@ -10808,6 +10873,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10808
10873
  const fullInformation = await registerClient(authorizationServerUrl, {
10809
10874
  metadata,
10810
10875
  clientMetadata: provider.clientMetadata,
10876
+ scope: resolvedScope,
10811
10877
  fetchFn
10812
10878
  });
10813
10879
  await provider.saveClientInformation(fullInformation);
@@ -10851,7 +10917,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10851
10917
  clientInformation,
10852
10918
  state,
10853
10919
  redirectUrl: provider.redirectUrl,
10854
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
10920
+ scope: resolvedScope,
10855
10921
  resource
10856
10922
  });
10857
10923
  await provider.saveCodeVerifier(codeVerifier);
@@ -11169,7 +11235,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
11169
11235
  fetchFn
11170
11236
  });
11171
11237
  }
11172
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
11238
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
11173
11239
  let registrationUrl;
11174
11240
  if (metadata) {
11175
11241
  if (!metadata.registration_endpoint) {
@@ -11184,7 +11250,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
11184
11250
  headers: {
11185
11251
  "Content-Type": "application/json"
11186
11252
  },
11187
- body: JSON.stringify(clientMetadata)
11253
+ body: JSON.stringify({
11254
+ ...clientMetadata,
11255
+ ...scope !== void 0 ? { scope } : {}
11256
+ })
11188
11257
  });
11189
11258
  if (!response.ok) {
11190
11259
  throw await parseErrorResponse(response);
@@ -12279,7 +12348,7 @@ var SystemPrompts = {
12279
12348
  </rules>
12280
12349
 
12281
12350
  <format>
12282
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12351
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12283
12352
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
12284
12353
  </format>`,
12285
12354
  /**
@@ -12404,7 +12473,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
12404
12473
  *
12405
12474
  * Only two fields:
12406
12475
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
12407
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
12476
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
12408
12477
  */
12409
12478
  forAgentic: function(allToolNames) {
12410
12479
  const toolEnum = [
@@ -14356,11 +14425,12 @@ var ToolManager = class {
14356
14425
  /**
14357
14426
  * Register a tool in the registry
14358
14427
  */
14359
- registerTool(name, description, schema, callback, options = {}) {
14428
+ registerTool(name, description, inputSchema, callback, options = {}) {
14360
14429
  this.toolRegistry.set(name, {
14361
14430
  callback,
14362
14431
  description,
14363
- schema
14432
+ inputSchema,
14433
+ outputSchema: options.outputSchema
14364
14434
  });
14365
14435
  if (options.hidden) {
14366
14436
  this.toolConfigs.set(name, {
@@ -14373,13 +14443,16 @@ var ToolManager = class {
14373
14443
  /**
14374
14444
  * Explicitly mark a tool as public (exposed to MCP clients)
14375
14445
  */
14376
- addPublicTool(name, description, schema) {
14446
+ addPublicTool(name, description, inputSchema, outputSchema) {
14377
14447
  const existingTool = this.publicTools.find((t) => t.name === name);
14378
14448
  if (!existingTool) {
14379
14449
  this.publicTools.push({
14380
14450
  name,
14381
14451
  description,
14382
- inputSchema: schema
14452
+ inputSchema,
14453
+ ...outputSchema ? {
14454
+ outputSchema
14455
+ } : {}
14383
14456
  });
14384
14457
  }
14385
14458
  this.toolConfigs.set(name, {
@@ -14505,10 +14578,13 @@ var ToolManager = class {
14505
14578
  getHiddenToolSchema(name) {
14506
14579
  const tool2 = this.toolRegistry.get(name);
14507
14580
  const config = this.toolConfigs.get(name);
14508
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
14581
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
14509
14582
  return {
14510
14583
  description: tool2.description,
14511
- schema: tool2.schema
14584
+ inputSchema: tool2.inputSchema,
14585
+ ...tool2.outputSchema ? {
14586
+ outputSchema: tool2.outputSchema
14587
+ } : {}
14512
14588
  };
14513
14589
  }
14514
14590
  return void 0;
@@ -14544,10 +14620,13 @@ var ToolManager = class {
14544
14620
  composedTools[name] = {
14545
14621
  name,
14546
14622
  description: tool2.description,
14547
- inputSchema: jsonSchema(tool2.schema || {
14623
+ inputSchema: jsonSchema(tool2.inputSchema || {
14548
14624
  type: "object",
14549
14625
  properties: {}
14550
14626
  }),
14627
+ ...tool2.outputSchema ? {
14628
+ outputSchema: jsonSchema(tool2.outputSchema)
14629
+ } : {},
14551
14630
  execute: tool2.callback
14552
14631
  };
14553
14632
  }
@@ -14564,10 +14643,13 @@ var ToolManager = class {
14564
14643
  return {
14565
14644
  name,
14566
14645
  description: tool2.description,
14567
- inputSchema: tool2.schema ?? {
14646
+ inputSchema: tool2.inputSchema ?? {
14568
14647
  type: "object",
14569
14648
  properties: {}
14570
14649
  },
14650
+ ...tool2.outputSchema ? {
14651
+ outputSchema: tool2.outputSchema
14652
+ } : {},
14571
14653
  execute: tool2.callback
14572
14654
  };
14573
14655
  }
@@ -14581,10 +14663,13 @@ var ToolManager = class {
14581
14663
  composedTools.push({
14582
14664
  name,
14583
14665
  description: tool2.description,
14584
- inputSchema: tool2.schema ?? {
14666
+ inputSchema: tool2.inputSchema ?? {
14585
14667
  type: "object",
14586
14668
  properties: {}
14587
14669
  },
14670
+ ...tool2.outputSchema ? {
14671
+ outputSchema: tool2.outputSchema
14672
+ } : {},
14588
14673
  execute: tool2.callback
14589
14674
  });
14590
14675
  }
@@ -14637,7 +14722,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14637
14722
  const tempTool = {
14638
14723
  name: toolId,
14639
14724
  description: toolData.description,
14640
- inputSchema: toolData.schema || defaultSchema,
14725
+ inputSchema: toolData.inputSchema || defaultSchema,
14726
+ ...toolData.outputSchema ? {
14727
+ outputSchema: toolData.outputSchema
14728
+ } : {},
14641
14729
  execute: toolData.callback
14642
14730
  };
14643
14731
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -14649,7 +14737,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14649
14737
  },
14650
14738
  transformationIndex: 0
14651
14739
  });
14652
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
14740
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
14741
+ outputSchema: processedTool.outputSchema
14742
+ });
14653
14743
  }
14654
14744
  }
14655
14745
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -14824,9 +14914,13 @@ var ComposableMCPServer = class extends Server {
14824
14914
  }
14825
14915
  tool(name, description, paramsSchema, cb, options = {}) {
14826
14916
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
14827
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
14917
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
14918
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
14919
+ ...options,
14920
+ outputSchema: outputSchemaObj
14921
+ });
14828
14922
  if (!options.internal) {
14829
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
14923
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
14830
14924
  }
14831
14925
  if (options.plugins) {
14832
14926
  for (const plugin of options.plugins) {
@@ -15083,9 +15177,12 @@ var ComposableMCPServer = class extends Server {
15083
15177
  return {
15084
15178
  name,
15085
15179
  description: tool2?.description || "",
15086
- inputSchema: tool2?.schema || {
15180
+ inputSchema: tool2?.inputSchema || {
15087
15181
  type: "object"
15088
- }
15182
+ },
15183
+ ...tool2?.outputSchema ? {
15184
+ outputSchema: tool2.outputSchema
15185
+ } : {}
15089
15186
  };
15090
15187
  });
15091
15188
  }
@@ -15110,9 +15207,12 @@ var ComposableMCPServer = class extends Server {
15110
15207
  return Array.from(registry.entries()).map(([name, tool2]) => ({
15111
15208
  name,
15112
15209
  description: tool2?.description || "",
15113
- inputSchema: tool2?.schema || {
15210
+ inputSchema: tool2?.inputSchema || {
15114
15211
  type: "object"
15115
- }
15212
+ },
15213
+ ...tool2?.outputSchema ? {
15214
+ outputSchema: tool2.outputSchema
15215
+ } : {}
15116
15216
  }));
15117
15217
  }
15118
15218
  /**
@@ -15254,7 +15354,9 @@ var ComposableMCPServer = class extends Server {
15254
15354
  });
15255
15355
  });
15256
15356
  Object.entries(tools).forEach(([toolId, tool2]) => {
15257
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
15357
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
15358
+ outputSchema: tool2.outputSchema
15359
+ });
15258
15360
  });
15259
15361
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
15260
15362
  const allTools = {
@@ -15315,7 +15417,8 @@ var ComposableMCPServer = class extends Server {
15315
15417
  return;
15316
15418
  }
15317
15419
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
15318
- internal: false
15420
+ internal: false,
15421
+ outputSchema: tool2.outputSchema
15319
15422
  });
15320
15423
  });
15321
15424
  await this.pluginManager.triggerComposeEnd({