@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/app.mjs CHANGED
@@ -548,10 +548,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
548
548
  var CursorSchema = z.string();
549
549
  var TaskCreationParamsSchema = z.looseObject({
550
550
  /**
551
- * Time in milliseconds to keep task results available after completion.
552
- * If null, the task has unlimited lifetime until manually cleaned up.
551
+ * Requested duration in milliseconds to retain task from creation.
553
552
  */
554
- ttl: z.union([z.number(), z.null()]).optional(),
553
+ ttl: z.number().optional(),
555
554
  /**
556
555
  * Time in milliseconds to wait between task status requests.
557
556
  */
@@ -851,7 +850,11 @@ var ClientCapabilitiesSchema = z.object({
851
850
  /**
852
851
  * Present if the client supports task creation.
853
852
  */
854
- tasks: ClientTasksCapabilitySchema.optional()
853
+ tasks: ClientTasksCapabilitySchema.optional(),
854
+ /**
855
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
856
+ */
857
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
855
858
  });
856
859
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
857
860
  /**
@@ -913,7 +916,11 @@ var ServerCapabilitiesSchema = z.object({
913
916
  /**
914
917
  * Present if the server supports task creation.
915
918
  */
916
- tasks: ServerTasksCapabilitySchema.optional()
919
+ tasks: ServerTasksCapabilitySchema.optional(),
920
+ /**
921
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
922
+ */
923
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
917
924
  });
918
925
  var InitializeResultSchema = ResultSchema.extend({
919
926
  /**
@@ -1106,6 +1113,12 @@ var ResourceSchema = z.object({
1106
1113
  * The MIME type of this resource, if known.
1107
1114
  */
1108
1115
  mimeType: z.optional(z.string()),
1116
+ /**
1117
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1118
+ *
1119
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1120
+ */
1121
+ size: z.optional(z.number()),
1109
1122
  /**
1110
1123
  * Optional annotations for the client.
1111
1124
  */
@@ -2670,6 +2683,10 @@ var Protocol = class {
2670
2683
  this._progressHandlers.clear();
2671
2684
  this._taskProgressTokens.clear();
2672
2685
  this._pendingDebouncedNotifications.clear();
2686
+ for (const info of this._timeoutInfo.values()) {
2687
+ clearTimeout(info.timeoutId);
2688
+ }
2689
+ this._timeoutInfo.clear();
2673
2690
  for (const controller of this._requestHandlerAbortControllers.values()) {
2674
2691
  controller.abort();
2675
2692
  }
@@ -2800,7 +2817,9 @@ var Protocol = class {
2800
2817
  await capturedTransport?.send(errorResponse);
2801
2818
  }
2802
2819
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
2803
- this._requestHandlerAbortControllers.delete(request.id);
2820
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
2821
+ this._requestHandlerAbortControllers.delete(request.id);
2822
+ }
2804
2823
  });
2805
2824
  }
2806
2825
  _onprogress(notification) {
@@ -4924,7 +4943,7 @@ var StdioClientTransport = class {
4924
4943
  },
4925
4944
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
4926
4945
  shell: false,
4927
- windowsHide: process2.platform === "win32" && isElectron(),
4946
+ windowsHide: process2.platform === "win32",
4928
4947
  cwd: this._serverParams.cwd
4929
4948
  });
4930
4949
  this._process.on("error", (error) => {
@@ -5031,9 +5050,6 @@ var StdioClientTransport = class {
5031
5050
  });
5032
5051
  }
5033
5052
  };
5034
- function isElectron() {
5035
- return "type" in process2;
5036
- }
5037
5053
 
5038
5054
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
5039
5055
  var ParseError = class extends Error {
@@ -5778,12 +5794,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
5778
5794
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
5779
5795
  function selectClientAuthMethod(clientInformation, supportedMethods) {
5780
5796
  const hasClientSecret = clientInformation.client_secret !== void 0;
5781
- if (supportedMethods.length === 0) {
5782
- return hasClientSecret ? "client_secret_post" : "none";
5783
- }
5784
- 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)) {
5797
+ 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))) {
5785
5798
  return clientInformation.token_endpoint_auth_method;
5786
5799
  }
5800
+ if (supportedMethods.length === 0) {
5801
+ return hasClientSecret ? "client_secret_basic" : "none";
5802
+ }
5787
5803
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
5788
5804
  return "client_secret_basic";
5789
5805
  }
@@ -5894,6 +5910,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5894
5910
  });
5895
5911
  }
5896
5912
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
5913
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
5897
5914
  let clientInformation = await Promise.resolve(provider.clientInformation());
5898
5915
  if (!clientInformation) {
5899
5916
  if (authorizationCode !== void 0) {
@@ -5917,6 +5934,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5917
5934
  const fullInformation = await registerClient(authorizationServerUrl, {
5918
5935
  metadata,
5919
5936
  clientMetadata: provider.clientMetadata,
5937
+ scope: resolvedScope,
5920
5938
  fetchFn
5921
5939
  });
5922
5940
  await provider.saveClientInformation(fullInformation);
@@ -5960,7 +5978,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
5960
5978
  clientInformation,
5961
5979
  state,
5962
5980
  redirectUrl: provider.redirectUrl,
5963
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
5981
+ scope: resolvedScope,
5964
5982
  resource
5965
5983
  });
5966
5984
  await provider.saveCodeVerifier(codeVerifier);
@@ -6278,7 +6296,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
6278
6296
  fetchFn
6279
6297
  });
6280
6298
  }
6281
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
6299
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
6282
6300
  let registrationUrl;
6283
6301
  if (metadata) {
6284
6302
  if (!metadata.registration_endpoint) {
@@ -6293,7 +6311,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
6293
6311
  headers: {
6294
6312
  "Content-Type": "application/json"
6295
6313
  },
6296
- body: JSON.stringify(clientMetadata)
6314
+ body: JSON.stringify({
6315
+ ...clientMetadata,
6316
+ ...scope !== void 0 ? { scope } : {}
6317
+ })
6297
6318
  });
6298
6319
  if (!response.ok) {
6299
6320
  throw await parseErrorResponse(response);
@@ -7388,7 +7409,7 @@ var SystemPrompts = {
7388
7409
  </rules>
7389
7410
 
7390
7411
  <format>
7391
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
7412
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
7392
7413
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
7393
7414
  </format>`,
7394
7415
  /**
@@ -7513,7 +7534,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
7513
7534
  *
7514
7535
  * Only two fields:
7515
7536
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
7516
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
7537
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
7517
7538
  */
7518
7539
  forAgentic: function(allToolNames) {
7519
7540
  const toolEnum = [
@@ -9464,11 +9485,12 @@ var ToolManager = class {
9464
9485
  /**
9465
9486
  * Register a tool in the registry
9466
9487
  */
9467
- registerTool(name, description, schema, callback, options = {}) {
9488
+ registerTool(name, description, inputSchema, callback, options = {}) {
9468
9489
  this.toolRegistry.set(name, {
9469
9490
  callback,
9470
9491
  description,
9471
- schema
9492
+ inputSchema,
9493
+ outputSchema: options.outputSchema
9472
9494
  });
9473
9495
  if (options.hidden) {
9474
9496
  this.toolConfigs.set(name, {
@@ -9481,13 +9503,16 @@ var ToolManager = class {
9481
9503
  /**
9482
9504
  * Explicitly mark a tool as public (exposed to MCP clients)
9483
9505
  */
9484
- addPublicTool(name, description, schema) {
9506
+ addPublicTool(name, description, inputSchema, outputSchema) {
9485
9507
  const existingTool = this.publicTools.find((t) => t.name === name);
9486
9508
  if (!existingTool) {
9487
9509
  this.publicTools.push({
9488
9510
  name,
9489
9511
  description,
9490
- inputSchema: schema
9512
+ inputSchema,
9513
+ ...outputSchema ? {
9514
+ outputSchema
9515
+ } : {}
9491
9516
  });
9492
9517
  }
9493
9518
  this.toolConfigs.set(name, {
@@ -9613,10 +9638,13 @@ var ToolManager = class {
9613
9638
  getHiddenToolSchema(name) {
9614
9639
  const tool2 = this.toolRegistry.get(name);
9615
9640
  const config = this.toolConfigs.get(name);
9616
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
9641
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
9617
9642
  return {
9618
9643
  description: tool2.description,
9619
- schema: tool2.schema
9644
+ inputSchema: tool2.inputSchema,
9645
+ ...tool2.outputSchema ? {
9646
+ outputSchema: tool2.outputSchema
9647
+ } : {}
9620
9648
  };
9621
9649
  }
9622
9650
  return void 0;
@@ -9652,10 +9680,13 @@ var ToolManager = class {
9652
9680
  composedTools[name] = {
9653
9681
  name,
9654
9682
  description: tool2.description,
9655
- inputSchema: jsonSchema(tool2.schema || {
9683
+ inputSchema: jsonSchema(tool2.inputSchema || {
9656
9684
  type: "object",
9657
9685
  properties: {}
9658
9686
  }),
9687
+ ...tool2.outputSchema ? {
9688
+ outputSchema: jsonSchema(tool2.outputSchema)
9689
+ } : {},
9659
9690
  execute: tool2.callback
9660
9691
  };
9661
9692
  }
@@ -9672,10 +9703,13 @@ var ToolManager = class {
9672
9703
  return {
9673
9704
  name,
9674
9705
  description: tool2.description,
9675
- inputSchema: tool2.schema ?? {
9706
+ inputSchema: tool2.inputSchema ?? {
9676
9707
  type: "object",
9677
9708
  properties: {}
9678
9709
  },
9710
+ ...tool2.outputSchema ? {
9711
+ outputSchema: tool2.outputSchema
9712
+ } : {},
9679
9713
  execute: tool2.callback
9680
9714
  };
9681
9715
  }
@@ -9689,10 +9723,13 @@ var ToolManager = class {
9689
9723
  composedTools.push({
9690
9724
  name,
9691
9725
  description: tool2.description,
9692
- inputSchema: tool2.schema ?? {
9726
+ inputSchema: tool2.inputSchema ?? {
9693
9727
  type: "object",
9694
9728
  properties: {}
9695
9729
  },
9730
+ ...tool2.outputSchema ? {
9731
+ outputSchema: tool2.outputSchema
9732
+ } : {},
9696
9733
  execute: tool2.callback
9697
9734
  });
9698
9735
  }
@@ -9745,7 +9782,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
9745
9782
  const tempTool = {
9746
9783
  name: toolId,
9747
9784
  description: toolData.description,
9748
- inputSchema: toolData.schema || defaultSchema,
9785
+ inputSchema: toolData.inputSchema || defaultSchema,
9786
+ ...toolData.outputSchema ? {
9787
+ outputSchema: toolData.outputSchema
9788
+ } : {},
9749
9789
  execute: toolData.callback
9750
9790
  };
9751
9791
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -9757,7 +9797,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
9757
9797
  },
9758
9798
  transformationIndex: 0
9759
9799
  });
9760
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
9800
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
9801
+ outputSchema: processedTool.outputSchema
9802
+ });
9761
9803
  }
9762
9804
  }
9763
9805
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -9932,9 +9974,13 @@ var ComposableMCPServer = class extends Server {
9932
9974
  }
9933
9975
  tool(name, description, paramsSchema, cb, options = {}) {
9934
9976
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
9935
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
9977
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
9978
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
9979
+ ...options,
9980
+ outputSchema: outputSchemaObj
9981
+ });
9936
9982
  if (!options.internal) {
9937
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
9983
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
9938
9984
  }
9939
9985
  if (options.plugins) {
9940
9986
  for (const plugin of options.plugins) {
@@ -10191,9 +10237,12 @@ var ComposableMCPServer = class extends Server {
10191
10237
  return {
10192
10238
  name,
10193
10239
  description: tool2?.description || "",
10194
- inputSchema: tool2?.schema || {
10240
+ inputSchema: tool2?.inputSchema || {
10195
10241
  type: "object"
10196
- }
10242
+ },
10243
+ ...tool2?.outputSchema ? {
10244
+ outputSchema: tool2.outputSchema
10245
+ } : {}
10197
10246
  };
10198
10247
  });
10199
10248
  }
@@ -10218,9 +10267,12 @@ var ComposableMCPServer = class extends Server {
10218
10267
  return Array.from(registry.entries()).map(([name, tool2]) => ({
10219
10268
  name,
10220
10269
  description: tool2?.description || "",
10221
- inputSchema: tool2?.schema || {
10270
+ inputSchema: tool2?.inputSchema || {
10222
10271
  type: "object"
10223
- }
10272
+ },
10273
+ ...tool2?.outputSchema ? {
10274
+ outputSchema: tool2.outputSchema
10275
+ } : {}
10224
10276
  }));
10225
10277
  }
10226
10278
  /**
@@ -10362,7 +10414,9 @@ var ComposableMCPServer = class extends Server {
10362
10414
  });
10363
10415
  });
10364
10416
  Object.entries(tools).forEach(([toolId, tool2]) => {
10365
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
10417
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
10418
+ outputSchema: tool2.outputSchema
10419
+ });
10366
10420
  });
10367
10421
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
10368
10422
  const allTools = {
@@ -10423,7 +10477,8 @@ var ComposableMCPServer = class extends Server {
10423
10477
  return;
10424
10478
  }
10425
10479
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
10426
- internal: false
10480
+ internal: false,
10481
+ outputSchema: tool2.outputSchema
10427
10482
  });
10428
10483
  });
10429
10484
  await this.pluginManager.triggerComposeEnd({
@@ -13393,7 +13448,7 @@ var coreHandler = (app) => {
13393
13448
  };
13394
13449
 
13395
13450
  // __mcpc__cli_latest/node_modules/@hono/node-server/dist/index.mjs
13396
- import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
13451
+ import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
13397
13452
  import { Http2ServerRequest } from "http2";
13398
13453
  import { Readable } from "stream";
13399
13454
  import crypto3 from "crypto";
@@ -13716,6 +13771,50 @@ if (typeof global.crypto === "undefined") {
13716
13771
  global.crypto = crypto3;
13717
13772
  }
13718
13773
  var outgoingEnded = Symbol("outgoingEnded");
13774
+ var incomingDraining = Symbol("incomingDraining");
13775
+ var DRAIN_TIMEOUT_MS = 500;
13776
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
13777
+ var drainIncoming = (incoming) => {
13778
+ const incomingWithDrainState = incoming;
13779
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
13780
+ return;
13781
+ }
13782
+ incomingWithDrainState[incomingDraining] = true;
13783
+ if (incoming instanceof Http2ServerRequest2) {
13784
+ try {
13785
+ ;
13786
+ incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
13787
+ } catch {
13788
+ }
13789
+ return;
13790
+ }
13791
+ let bytesRead = 0;
13792
+ const cleanup = () => {
13793
+ clearTimeout(timer);
13794
+ incoming.off("data", onData);
13795
+ incoming.off("end", cleanup);
13796
+ incoming.off("error", cleanup);
13797
+ };
13798
+ const forceClose = () => {
13799
+ cleanup();
13800
+ const socket = incoming.socket;
13801
+ if (socket && !socket.destroyed) {
13802
+ socket.destroySoon();
13803
+ }
13804
+ };
13805
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
13806
+ timer.unref?.();
13807
+ const onData = (chunk) => {
13808
+ bytesRead += chunk.length;
13809
+ if (bytesRead > MAX_DRAIN_BYTES) {
13810
+ forceClose();
13811
+ }
13812
+ };
13813
+ incoming.on("data", onData);
13814
+ incoming.on("end", cleanup);
13815
+ incoming.on("error", cleanup);
13816
+ incoming.resume();
13817
+ };
13719
13818
  var handleRequestError = () => new Response(null, {
13720
13819
  status: 400
13721
13820
  });
@@ -13887,14 +13986,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
13887
13986
  setTimeout(() => {
13888
13987
  if (!incomingEnded) {
13889
13988
  setTimeout(() => {
13890
- incoming.destroy();
13891
- outgoing.destroy();
13989
+ drainIncoming(incoming);
13892
13990
  });
13893
13991
  }
13894
13992
  });
13895
13993
  }
13896
13994
  };
13897
13995
  }
13996
+ outgoing.on("finish", () => {
13997
+ if (!incomingEnded) {
13998
+ drainIncoming(incoming);
13999
+ }
14000
+ });
13898
14001
  }
13899
14002
  outgoing.on("close", () => {
13900
14003
  const abortController = req[abortControllerKey];
@@ -13909,7 +14012,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
13909
14012
  setTimeout(() => {
13910
14013
  if (!incomingEnded) {
13911
14014
  setTimeout(() => {
13912
- incoming.destroy();
14015
+ drainIncoming(incoming);
13913
14016
  });
13914
14017
  }
13915
14018
  });
@@ -14921,7 +15024,7 @@ import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/p
14921
15024
  import { homedir } from "node:os";
14922
15025
  import { dirname, join as join3, resolve as resolve4 } from "node:path";
14923
15026
  import process10 from "node:process";
14924
- var CLI_VERSION = "0.1.53";
15027
+ var CLI_VERSION = "0.1.54";
14925
15028
  function extractServerName(command, commandArgs) {
14926
15029
  for (const arg of commandArgs) {
14927
15030
  if (!arg.startsWith("-")) {