@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.mjs CHANGED
@@ -551,10 +551,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
551
551
  var CursorSchema = z.string();
552
552
  var TaskCreationParamsSchema = z.looseObject({
553
553
  /**
554
- * Time in milliseconds to keep task results available after completion.
555
- * If null, the task has unlimited lifetime until manually cleaned up.
554
+ * Requested duration in milliseconds to retain task from creation.
556
555
  */
557
- ttl: z.union([z.number(), z.null()]).optional(),
556
+ ttl: z.number().optional(),
558
557
  /**
559
558
  * Time in milliseconds to wait between task status requests.
560
559
  */
@@ -854,7 +853,11 @@ var ClientCapabilitiesSchema = z.object({
854
853
  /**
855
854
  * Present if the client supports task creation.
856
855
  */
857
- tasks: ClientTasksCapabilitySchema.optional()
856
+ tasks: ClientTasksCapabilitySchema.optional(),
857
+ /**
858
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
859
+ */
860
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
858
861
  });
859
862
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
860
863
  /**
@@ -916,7 +919,11 @@ var ServerCapabilitiesSchema = z.object({
916
919
  /**
917
920
  * Present if the server supports task creation.
918
921
  */
919
- tasks: ServerTasksCapabilitySchema.optional()
922
+ tasks: ServerTasksCapabilitySchema.optional(),
923
+ /**
924
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
925
+ */
926
+ extensions: z.record(z.string(), AssertObjectSchema).optional()
920
927
  });
921
928
  var InitializeResultSchema = ResultSchema.extend({
922
929
  /**
@@ -1109,6 +1116,12 @@ var ResourceSchema = z.object({
1109
1116
  * The MIME type of this resource, if known.
1110
1117
  */
1111
1118
  mimeType: z.optional(z.string()),
1119
+ /**
1120
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1121
+ *
1122
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1123
+ */
1124
+ size: z.optional(z.number()),
1112
1125
  /**
1113
1126
  * Optional annotations for the client.
1114
1127
  */
@@ -2369,7 +2382,7 @@ var coreHandler = (app) => {
2369
2382
  };
2370
2383
 
2371
2384
  // __mcpc__cli_latest/node_modules/@hono/node-server/dist/index.mjs
2372
- import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
2385
+ import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
2373
2386
  import { Http2ServerRequest } from "http2";
2374
2387
  import { Readable } from "stream";
2375
2388
  import crypto2 from "crypto";
@@ -2692,6 +2705,50 @@ if (typeof global.crypto === "undefined") {
2692
2705
  global.crypto = crypto2;
2693
2706
  }
2694
2707
  var outgoingEnded = Symbol("outgoingEnded");
2708
+ var incomingDraining = Symbol("incomingDraining");
2709
+ var DRAIN_TIMEOUT_MS = 500;
2710
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
2711
+ var drainIncoming = (incoming) => {
2712
+ const incomingWithDrainState = incoming;
2713
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
2714
+ return;
2715
+ }
2716
+ incomingWithDrainState[incomingDraining] = true;
2717
+ if (incoming instanceof Http2ServerRequest2) {
2718
+ try {
2719
+ ;
2720
+ incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
2721
+ } catch {
2722
+ }
2723
+ return;
2724
+ }
2725
+ let bytesRead = 0;
2726
+ const cleanup = () => {
2727
+ clearTimeout(timer);
2728
+ incoming.off("data", onData);
2729
+ incoming.off("end", cleanup);
2730
+ incoming.off("error", cleanup);
2731
+ };
2732
+ const forceClose = () => {
2733
+ cleanup();
2734
+ const socket = incoming.socket;
2735
+ if (socket && !socket.destroyed) {
2736
+ socket.destroySoon();
2737
+ }
2738
+ };
2739
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
2740
+ timer.unref?.();
2741
+ const onData = (chunk) => {
2742
+ bytesRead += chunk.length;
2743
+ if (bytesRead > MAX_DRAIN_BYTES) {
2744
+ forceClose();
2745
+ }
2746
+ };
2747
+ incoming.on("data", onData);
2748
+ incoming.on("end", cleanup);
2749
+ incoming.on("error", cleanup);
2750
+ incoming.resume();
2751
+ };
2695
2752
  var handleRequestError = () => new Response(null, {
2696
2753
  status: 400
2697
2754
  });
@@ -2863,14 +2920,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
2863
2920
  setTimeout(() => {
2864
2921
  if (!incomingEnded) {
2865
2922
  setTimeout(() => {
2866
- incoming.destroy();
2867
- outgoing.destroy();
2923
+ drainIncoming(incoming);
2868
2924
  });
2869
2925
  }
2870
2926
  });
2871
2927
  }
2872
2928
  };
2873
2929
  }
2930
+ outgoing.on("finish", () => {
2931
+ if (!incomingEnded) {
2932
+ drainIncoming(incoming);
2933
+ }
2934
+ });
2874
2935
  }
2875
2936
  outgoing.on("close", () => {
2876
2937
  const abortController = req[abortControllerKey];
@@ -2885,7 +2946,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
2885
2946
  setTimeout(() => {
2886
2947
  if (!incomingEnded) {
2887
2948
  setTimeout(() => {
2888
- incoming.destroy();
2949
+ drainIncoming(incoming);
2889
2950
  });
2890
2951
  }
2891
2952
  });
@@ -6725,7 +6786,7 @@ function getDefaultAgents() {
6725
6786
  }
6726
6787
 
6727
6788
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6728
- var CLI_VERSION = "0.1.53";
6789
+ var CLI_VERSION = "0.1.54";
6729
6790
  function extractServerName(command, commandArgs) {
6730
6791
  for (const arg of commandArgs) {
6731
6792
  if (!arg.startsWith("-")) {
@@ -7569,6 +7630,10 @@ var Protocol = class {
7569
7630
  this._progressHandlers.clear();
7570
7631
  this._taskProgressTokens.clear();
7571
7632
  this._pendingDebouncedNotifications.clear();
7633
+ for (const info of this._timeoutInfo.values()) {
7634
+ clearTimeout(info.timeoutId);
7635
+ }
7636
+ this._timeoutInfo.clear();
7572
7637
  for (const controller of this._requestHandlerAbortControllers.values()) {
7573
7638
  controller.abort();
7574
7639
  }
@@ -7699,7 +7764,9 @@ var Protocol = class {
7699
7764
  await capturedTransport?.send(errorResponse);
7700
7765
  }
7701
7766
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
7702
- this._requestHandlerAbortControllers.delete(request.id);
7767
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
7768
+ this._requestHandlerAbortControllers.delete(request.id);
7769
+ }
7703
7770
  });
7704
7771
  }
7705
7772
  _onprogress(notification) {
@@ -9823,7 +9890,7 @@ var StdioClientTransport = class {
9823
9890
  },
9824
9891
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
9825
9892
  shell: false,
9826
- windowsHide: process6.platform === "win32" && isElectron(),
9893
+ windowsHide: process6.platform === "win32",
9827
9894
  cwd: this._serverParams.cwd
9828
9895
  });
9829
9896
  this._process.on("error", (error) => {
@@ -9930,9 +9997,6 @@ var StdioClientTransport = class {
9930
9997
  });
9931
9998
  }
9932
9999
  };
9933
- function isElectron() {
9934
- return "type" in process6;
9935
- }
9936
10000
 
9937
10001
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
9938
10002
  var ParseError = class extends Error {
@@ -10677,12 +10741,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
10677
10741
  var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
10678
10742
  function selectClientAuthMethod(clientInformation, supportedMethods) {
10679
10743
  const hasClientSecret = clientInformation.client_secret !== void 0;
10680
- if (supportedMethods.length === 0) {
10681
- return hasClientSecret ? "client_secret_post" : "none";
10682
- }
10683
- 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)) {
10744
+ 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))) {
10684
10745
  return clientInformation.token_endpoint_auth_method;
10685
10746
  }
10747
+ if (supportedMethods.length === 0) {
10748
+ return hasClientSecret ? "client_secret_basic" : "none";
10749
+ }
10686
10750
  if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
10687
10751
  return "client_secret_basic";
10688
10752
  }
@@ -10793,6 +10857,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10793
10857
  });
10794
10858
  }
10795
10859
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
10860
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
10796
10861
  let clientInformation = await Promise.resolve(provider.clientInformation());
10797
10862
  if (!clientInformation) {
10798
10863
  if (authorizationCode !== void 0) {
@@ -10816,6 +10881,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10816
10881
  const fullInformation = await registerClient(authorizationServerUrl, {
10817
10882
  metadata,
10818
10883
  clientMetadata: provider.clientMetadata,
10884
+ scope: resolvedScope,
10819
10885
  fetchFn
10820
10886
  });
10821
10887
  await provider.saveClientInformation(fullInformation);
@@ -10859,7 +10925,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
10859
10925
  clientInformation,
10860
10926
  state,
10861
10927
  redirectUrl: provider.redirectUrl,
10862
- scope: scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
10928
+ scope: resolvedScope,
10863
10929
  resource
10864
10930
  });
10865
10931
  await provider.saveCodeVerifier(codeVerifier);
@@ -11177,7 +11243,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
11177
11243
  fetchFn
11178
11244
  });
11179
11245
  }
11180
- async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
11246
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
11181
11247
  let registrationUrl;
11182
11248
  if (metadata) {
11183
11249
  if (!metadata.registration_endpoint) {
@@ -11192,7 +11258,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
11192
11258
  headers: {
11193
11259
  "Content-Type": "application/json"
11194
11260
  },
11195
- body: JSON.stringify(clientMetadata)
11261
+ body: JSON.stringify({
11262
+ ...clientMetadata,
11263
+ ...scope !== void 0 ? { scope } : {}
11264
+ })
11196
11265
  });
11197
11266
  if (!response.ok) {
11198
11267
  throw await parseErrorResponse(response);
@@ -12287,7 +12356,7 @@ var SystemPrompts = {
12287
12356
  </rules>
12288
12357
 
12289
12358
  <format>
12290
- Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12359
+ Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
12291
12360
  Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
12292
12361
  </format>`,
12293
12362
  /**
@@ -12412,7 +12481,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
12412
12481
  *
12413
12482
  * Only two fields:
12414
12483
  * - `tool`: which tool to execute (enum includes "man" + all tool names)
12415
- * - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
12484
+ * - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
12416
12485
  */
12417
12486
  forAgentic: function(allToolNames) {
12418
12487
  const toolEnum = [
@@ -14363,11 +14432,12 @@ var ToolManager = class {
14363
14432
  /**
14364
14433
  * Register a tool in the registry
14365
14434
  */
14366
- registerTool(name, description, schema, callback, options = {}) {
14435
+ registerTool(name, description, inputSchema, callback, options = {}) {
14367
14436
  this.toolRegistry.set(name, {
14368
14437
  callback,
14369
14438
  description,
14370
- schema
14439
+ inputSchema,
14440
+ outputSchema: options.outputSchema
14371
14441
  });
14372
14442
  if (options.hidden) {
14373
14443
  this.toolConfigs.set(name, {
@@ -14380,13 +14450,16 @@ var ToolManager = class {
14380
14450
  /**
14381
14451
  * Explicitly mark a tool as public (exposed to MCP clients)
14382
14452
  */
14383
- addPublicTool(name, description, schema) {
14453
+ addPublicTool(name, description, inputSchema, outputSchema) {
14384
14454
  const existingTool = this.publicTools.find((t) => t.name === name);
14385
14455
  if (!existingTool) {
14386
14456
  this.publicTools.push({
14387
14457
  name,
14388
14458
  description,
14389
- inputSchema: schema
14459
+ inputSchema,
14460
+ ...outputSchema ? {
14461
+ outputSchema
14462
+ } : {}
14390
14463
  });
14391
14464
  }
14392
14465
  this.toolConfigs.set(name, {
@@ -14512,10 +14585,13 @@ var ToolManager = class {
14512
14585
  getHiddenToolSchema(name) {
14513
14586
  const tool2 = this.toolRegistry.get(name);
14514
14587
  const config = this.toolConfigs.get(name);
14515
- if (tool2 && config?.visibility?.hidden && tool2.schema) {
14588
+ if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
14516
14589
  return {
14517
14590
  description: tool2.description,
14518
- schema: tool2.schema
14591
+ inputSchema: tool2.inputSchema,
14592
+ ...tool2.outputSchema ? {
14593
+ outputSchema: tool2.outputSchema
14594
+ } : {}
14519
14595
  };
14520
14596
  }
14521
14597
  return void 0;
@@ -14551,10 +14627,13 @@ var ToolManager = class {
14551
14627
  composedTools[name] = {
14552
14628
  name,
14553
14629
  description: tool2.description,
14554
- inputSchema: jsonSchema(tool2.schema || {
14630
+ inputSchema: jsonSchema(tool2.inputSchema || {
14555
14631
  type: "object",
14556
14632
  properties: {}
14557
14633
  }),
14634
+ ...tool2.outputSchema ? {
14635
+ outputSchema: jsonSchema(tool2.outputSchema)
14636
+ } : {},
14558
14637
  execute: tool2.callback
14559
14638
  };
14560
14639
  }
@@ -14571,10 +14650,13 @@ var ToolManager = class {
14571
14650
  return {
14572
14651
  name,
14573
14652
  description: tool2.description,
14574
- inputSchema: tool2.schema ?? {
14653
+ inputSchema: tool2.inputSchema ?? {
14575
14654
  type: "object",
14576
14655
  properties: {}
14577
14656
  },
14657
+ ...tool2.outputSchema ? {
14658
+ outputSchema: tool2.outputSchema
14659
+ } : {},
14578
14660
  execute: tool2.callback
14579
14661
  };
14580
14662
  }
@@ -14588,10 +14670,13 @@ var ToolManager = class {
14588
14670
  composedTools.push({
14589
14671
  name,
14590
14672
  description: tool2.description,
14591
- inputSchema: tool2.schema ?? {
14673
+ inputSchema: tool2.inputSchema ?? {
14592
14674
  type: "object",
14593
14675
  properties: {}
14594
14676
  },
14677
+ ...tool2.outputSchema ? {
14678
+ outputSchema: tool2.outputSchema
14679
+ } : {},
14595
14680
  execute: tool2.callback
14596
14681
  });
14597
14682
  }
@@ -14644,7 +14729,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14644
14729
  const tempTool = {
14645
14730
  name: toolId,
14646
14731
  description: toolData.description,
14647
- inputSchema: toolData.schema || defaultSchema,
14732
+ inputSchema: toolData.inputSchema || defaultSchema,
14733
+ ...toolData.outputSchema ? {
14734
+ outputSchema: toolData.outputSchema
14735
+ } : {},
14648
14736
  execute: toolData.callback
14649
14737
  };
14650
14738
  const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
@@ -14656,7 +14744,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
14656
14744
  },
14657
14745
  transformationIndex: 0
14658
14746
  });
14659
- toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
14747
+ toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
14748
+ outputSchema: processedTool.outputSchema
14749
+ });
14660
14750
  }
14661
14751
  }
14662
14752
  function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
@@ -14831,9 +14921,13 @@ var ComposableMCPServer = class extends Server {
14831
14921
  }
14832
14922
  tool(name, description, paramsSchema, cb, options = {}) {
14833
14923
  const jsonSchemaObj = extractJsonSchema(paramsSchema);
14834
- this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
14924
+ const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
14925
+ this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
14926
+ ...options,
14927
+ outputSchema: outputSchemaObj
14928
+ });
14835
14929
  if (!options.internal) {
14836
- this.toolManager.addPublicTool(name, description, jsonSchemaObj);
14930
+ this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
14837
14931
  }
14838
14932
  if (options.plugins) {
14839
14933
  for (const plugin of options.plugins) {
@@ -15090,9 +15184,12 @@ var ComposableMCPServer = class extends Server {
15090
15184
  return {
15091
15185
  name,
15092
15186
  description: tool2?.description || "",
15093
- inputSchema: tool2?.schema || {
15187
+ inputSchema: tool2?.inputSchema || {
15094
15188
  type: "object"
15095
- }
15189
+ },
15190
+ ...tool2?.outputSchema ? {
15191
+ outputSchema: tool2.outputSchema
15192
+ } : {}
15096
15193
  };
15097
15194
  });
15098
15195
  }
@@ -15117,9 +15214,12 @@ var ComposableMCPServer = class extends Server {
15117
15214
  return Array.from(registry.entries()).map(([name, tool2]) => ({
15118
15215
  name,
15119
15216
  description: tool2?.description || "",
15120
- inputSchema: tool2?.schema || {
15217
+ inputSchema: tool2?.inputSchema || {
15121
15218
  type: "object"
15122
- }
15219
+ },
15220
+ ...tool2?.outputSchema ? {
15221
+ outputSchema: tool2.outputSchema
15222
+ } : {}
15123
15223
  }));
15124
15224
  }
15125
15225
  /**
@@ -15261,7 +15361,9 @@ var ComposableMCPServer = class extends Server {
15261
15361
  });
15262
15362
  });
15263
15363
  Object.entries(tools).forEach(([toolId, tool2]) => {
15264
- this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute);
15364
+ this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
15365
+ outputSchema: tool2.outputSchema
15366
+ });
15265
15367
  });
15266
15368
  const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
15267
15369
  const allTools = {
@@ -15322,7 +15424,8 @@ var ComposableMCPServer = class extends Server {
15322
15424
  return;
15323
15425
  }
15324
15426
  this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
15325
- internal: false
15427
+ internal: false,
15428
+ outputSchema: tool2.outputSchema
15326
15429
  });
15327
15430
  });
15328
15431
  await this.pluginManager.triggerComposeEnd({