@wix/mcp 1.0.10 → 1.0.11

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.
@@ -8268,13 +8268,14 @@ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_
8268
8268
  var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
8269
8269
  var dateRegex = new RegExp(`^${dateRegexSource}$`);
8270
8270
  function timeRegexSource(args) {
8271
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
8271
+ let secondsRegexSource = `[0-5]\\d`;
8272
8272
  if (args.precision) {
8273
- regex = `${regex}\\.\\d{${args.precision}}`;
8273
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
8274
8274
  } else if (args.precision == null) {
8275
- regex = `${regex}(\\.\\d+)?`;
8275
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
8276
8276
  }
8277
- return regex;
8277
+ const secondsQuantifier = args.precision ? "+" : "?";
8278
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
8278
8279
  }
8279
8280
  function timeRegex(args) {
8280
8281
  return new RegExp(`^${timeRegexSource(args)}$`);
@@ -11485,21 +11486,23 @@ var z = /* @__PURE__ */ Object.freeze({
11485
11486
  });
11486
11487
 
11487
11488
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
11488
- var LATEST_PROTOCOL_VERSION = "2024-11-05";
11489
+ var LATEST_PROTOCOL_VERSION = "2025-03-26";
11489
11490
  var SUPPORTED_PROTOCOL_VERSIONS = [
11490
11491
  LATEST_PROTOCOL_VERSION,
11492
+ "2024-11-05",
11491
11493
  "2024-10-07"
11492
11494
  ];
11493
11495
  var JSONRPC_VERSION = "2.0";
11494
11496
  var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
11495
11497
  var CursorSchema = z.string();
11498
+ var RequestMetaSchema = z.object({
11499
+ /**
11500
+ * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
11501
+ */
11502
+ progressToken: z.optional(ProgressTokenSchema)
11503
+ }).passthrough();
11496
11504
  var BaseRequestParamsSchema = z.object({
11497
- _meta: z.optional(z.object({
11498
- /**
11499
- * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
11500
- */
11501
- progressToken: z.optional(ProgressTokenSchema)
11502
- }).passthrough())
11505
+ _meta: z.optional(RequestMetaSchema)
11503
11506
  }).passthrough();
11504
11507
  var RequestSchema = z.object({
11505
11508
  method: z.string(),
@@ -11526,14 +11529,17 @@ var JSONRPCRequestSchema = z.object({
11526
11529
  jsonrpc: z.literal(JSONRPC_VERSION),
11527
11530
  id: RequestIdSchema
11528
11531
  }).merge(RequestSchema).strict();
11532
+ var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
11529
11533
  var JSONRPCNotificationSchema = z.object({
11530
11534
  jsonrpc: z.literal(JSONRPC_VERSION)
11531
11535
  }).merge(NotificationSchema).strict();
11536
+ var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
11532
11537
  var JSONRPCResponseSchema = z.object({
11533
11538
  jsonrpc: z.literal(JSONRPC_VERSION),
11534
11539
  id: RequestIdSchema,
11535
11540
  result: ResultSchema
11536
11541
  }).strict();
11542
+ var isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
11537
11543
  var ErrorCode;
11538
11544
  (function(ErrorCode2) {
11539
11545
  ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
@@ -11562,6 +11568,7 @@ var JSONRPCErrorSchema = z.object({
11562
11568
  data: z.optional(z.unknown())
11563
11569
  })
11564
11570
  }).strict();
11571
+ var isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
11565
11572
  var JSONRPCMessageSchema = z.union([
11566
11573
  JSONRPCRequestSchema,
11567
11574
  JSONRPCNotificationSchema,
@@ -11937,6 +11944,45 @@ var GetPromptResultSchema = ResultSchema.extend({
11937
11944
  var PromptListChangedNotificationSchema = NotificationSchema.extend({
11938
11945
  method: z.literal("notifications/prompts/list_changed")
11939
11946
  });
11947
+ var ToolAnnotationsSchema = z.object({
11948
+ /**
11949
+ * A human-readable title for the tool.
11950
+ */
11951
+ title: z.optional(z.string()),
11952
+ /**
11953
+ * If true, the tool does not modify its environment.
11954
+ *
11955
+ * Default: false
11956
+ */
11957
+ readOnlyHint: z.optional(z.boolean()),
11958
+ /**
11959
+ * If true, the tool may perform destructive updates to its environment.
11960
+ * If false, the tool performs only additive updates.
11961
+ *
11962
+ * (This property is meaningful only when `readOnlyHint == false`)
11963
+ *
11964
+ * Default: true
11965
+ */
11966
+ destructiveHint: z.optional(z.boolean()),
11967
+ /**
11968
+ * If true, calling the tool repeatedly with the same arguments
11969
+ * will have no additional effect on the its environment.
11970
+ *
11971
+ * (This property is meaningful only when `readOnlyHint == false`)
11972
+ *
11973
+ * Default: false
11974
+ */
11975
+ idempotentHint: z.optional(z.boolean()),
11976
+ /**
11977
+ * If true, this tool may interact with an "open world" of external
11978
+ * entities. If false, the tool's domain of interaction is closed.
11979
+ * For example, the world of a web search tool is open, whereas that
11980
+ * of a memory tool is not.
11981
+ *
11982
+ * Default: true
11983
+ */
11984
+ openWorldHint: z.optional(z.boolean())
11985
+ }).passthrough();
11940
11986
  var ToolSchema = z.object({
11941
11987
  /**
11942
11988
  * The name of the tool.
@@ -11952,7 +11998,11 @@ var ToolSchema = z.object({
11952
11998
  inputSchema: z.object({
11953
11999
  type: z.literal("object"),
11954
12000
  properties: z.optional(z.object({}).passthrough())
11955
- }).passthrough()
12001
+ }).passthrough(),
12002
+ /**
12003
+ * Optional additional tool information.
12004
+ */
12005
+ annotations: z.optional(ToolAnnotationsSchema)
11956
12006
  }).passthrough();
11957
12007
  var ListToolsRequestSchema = PaginatedRequestSchema.extend({
11958
12008
  method: z.literal("tools/list")
@@ -12282,13 +12332,15 @@ var Protocol = class {
12282
12332
  this._transport.onerror = (error) => {
12283
12333
  this._onerror(error);
12284
12334
  };
12285
- this._transport.onmessage = (message) => {
12286
- if (!("method" in message)) {
12335
+ this._transport.onmessage = (message, extra) => {
12336
+ if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
12287
12337
  this._onresponse(message);
12288
- } else if ("id" in message) {
12289
- this._onrequest(message);
12290
- } else {
12338
+ } else if (isJSONRPCRequest(message)) {
12339
+ this._onrequest(message, extra);
12340
+ } else if (isJSONRPCNotification(message)) {
12291
12341
  this._onnotification(message);
12342
+ } else {
12343
+ this._onerror(new Error(`Unknown message type: ${JSON.stringify(message)}`));
12292
12344
  }
12293
12345
  };
12294
12346
  await this._transport.start();
@@ -12317,8 +12369,8 @@ var Protocol = class {
12317
12369
  }
12318
12370
  Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
12319
12371
  }
12320
- _onrequest(request) {
12321
- var _a, _b, _c;
12372
+ _onrequest(request, extra) {
12373
+ var _a, _b, _c, _d;
12322
12374
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
12323
12375
  if (handler === void 0) {
12324
12376
  (_b = this._transport) === null || _b === void 0 ? void 0 : _b.send({
@@ -12333,11 +12385,16 @@ var Protocol = class {
12333
12385
  }
12334
12386
  const abortController = new AbortController();
12335
12387
  this._requestHandlerAbortControllers.set(request.id, abortController);
12336
- const extra = {
12388
+ const fullExtra = {
12337
12389
  signal: abortController.signal,
12338
- sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId
12390
+ sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId,
12391
+ _meta: (_d = request.params) === null || _d === void 0 ? void 0 : _d._meta,
12392
+ sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
12393
+ sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
12394
+ authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
12395
+ requestId: request.id
12339
12396
  };
12340
- Promise.resolve().then(() => handler(request, extra)).then((result) => {
12397
+ Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
12341
12398
  var _a2;
12342
12399
  if (abortController.signal.aborted) {
12343
12400
  return;
@@ -12394,7 +12451,7 @@ var Protocol = class {
12394
12451
  this._responseHandlers.delete(messageId);
12395
12452
  this._progressHandlers.delete(messageId);
12396
12453
  this._cleanupTimeout(messageId);
12397
- if ("result" in response) {
12454
+ if (isJSONRPCResponse(response)) {
12398
12455
  handler(response);
12399
12456
  } else {
12400
12457
  const error = new McpError(response.error.code, response.error.message, response.error.data);
@@ -12417,6 +12474,7 @@ var Protocol = class {
12417
12474
  * Do not use this method to emit notifications! Use notification() instead.
12418
12475
  */
12419
12476
  request(request, resultSchema, options) {
12477
+ const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
12420
12478
  return new Promise((resolve, reject) => {
12421
12479
  var _a, _b, _c, _d, _e;
12422
12480
  if (!this._transport) {
@@ -12452,7 +12510,7 @@ var Protocol = class {
12452
12510
  requestId: messageId,
12453
12511
  reason: String(reason)
12454
12512
  }
12455
- }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
12513
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
12456
12514
  reject(reason);
12457
12515
  };
12458
12516
  this._responseHandlers.set(messageId, (response) => {
@@ -12477,7 +12535,7 @@ var Protocol = class {
12477
12535
  const timeout = (_d = options === null || options === void 0 ? void 0 : options.timeout) !== null && _d !== void 0 ? _d : DEFAULT_REQUEST_TIMEOUT_MSEC;
12478
12536
  const timeoutHandler = () => cancel(new McpError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
12479
12537
  this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_e = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _e !== void 0 ? _e : false);
12480
- this._transport.send(jsonrpcRequest).catch((error) => {
12538
+ this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => {
12481
12539
  this._cleanupTimeout(messageId);
12482
12540
  reject(error);
12483
12541
  });
@@ -12486,7 +12544,7 @@ var Protocol = class {
12486
12544
  /**
12487
12545
  * Emits a notification, which is a one-way message that does not expect a response.
12488
12546
  */
12489
- async notification(notification) {
12547
+ async notification(notification, options) {
12490
12548
  if (!this._transport) {
12491
12549
  throw new Error("Not connected");
12492
12550
  }
@@ -12495,7 +12553,7 @@ var Protocol = class {
12495
12553
  ...notification,
12496
12554
  jsonrpc: "2.0"
12497
12555
  };
12498
- await this._transport.send(jsonrpcNotification);
12556
+ await this._transport.send(jsonrpcNotification, options);
12499
12557
  }
12500
12558
  /**
12501
12559
  * Registers a handler to invoke when this protocol object receives a request with the given method.
@@ -12505,7 +12563,9 @@ var Protocol = class {
12505
12563
  setRequestHandler(requestSchema, handler) {
12506
12564
  const method = requestSchema.shape.method.value;
12507
12565
  this.assertRequestHandlerCapability(method);
12508
- this._requestHandlers.set(method, (request, extra) => Promise.resolve(handler(requestSchema.parse(request), extra)));
12566
+ this._requestHandlers.set(method, (request, extra) => {
12567
+ return Promise.resolve(handler(requestSchema.parse(request), extra));
12568
+ });
12509
12569
  }
12510
12570
  /**
12511
12571
  * Removes the request handler for the given method.
@@ -14048,16 +14108,19 @@ var McpServer = class {
14048
14108
  this.server.assertCanSetRequestHandler(ListToolsRequestSchema.shape.method.value);
14049
14109
  this.server.assertCanSetRequestHandler(CallToolRequestSchema.shape.method.value);
14050
14110
  this.server.registerCapabilities({
14051
- tools: {}
14111
+ tools: {
14112
+ listChanged: true
14113
+ }
14052
14114
  });
14053
14115
  this.server.setRequestHandler(ListToolsRequestSchema, () => ({
14054
- tools: Object.entries(this._registeredTools).map(([name, tool]) => {
14116
+ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
14055
14117
  return {
14056
14118
  name,
14057
14119
  description: tool.description,
14058
14120
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
14059
14121
  strictUnions: true
14060
- }) : EMPTY_OBJECT_JSON_SCHEMA
14122
+ }) : EMPTY_OBJECT_JSON_SCHEMA,
14123
+ annotations: tool.annotations
14061
14124
  };
14062
14125
  })
14063
14126
  }));
@@ -14066,6 +14129,9 @@ var McpServer = class {
14066
14129
  if (!tool) {
14067
14130
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
14068
14131
  }
14132
+ if (!tool.enabled) {
14133
+ throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
14134
+ }
14069
14135
  if (tool.inputSchema) {
14070
14136
  const parseResult = await tool.inputSchema.safeParseAsync(request.params.arguments);
14071
14137
  if (!parseResult.success) {
@@ -14125,7 +14191,10 @@ var McpServer = class {
14125
14191
  async handlePromptCompletion(request, ref) {
14126
14192
  const prompt = this._registeredPrompts[ref.name];
14127
14193
  if (!prompt) {
14128
- throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.ref.name} not found`);
14194
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
14195
+ }
14196
+ if (!prompt.enabled) {
14197
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
14129
14198
  }
14130
14199
  if (!prompt.argsSchema) {
14131
14200
  return EMPTY_COMPLETION_RESULT;
@@ -14161,10 +14230,12 @@ var McpServer = class {
14161
14230
  this.server.assertCanSetRequestHandler(ListResourceTemplatesRequestSchema.shape.method.value);
14162
14231
  this.server.assertCanSetRequestHandler(ReadResourceRequestSchema.shape.method.value);
14163
14232
  this.server.registerCapabilities({
14164
- resources: {}
14233
+ resources: {
14234
+ listChanged: true
14235
+ }
14165
14236
  });
14166
14237
  this.server.setRequestHandler(ListResourcesRequestSchema, async (request, extra) => {
14167
- const resources = Object.entries(this._registeredResources).map(([uri, resource]) => ({
14238
+ const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
14168
14239
  uri,
14169
14240
  name: resource.name,
14170
14241
  ...resource.metadata
@@ -14196,6 +14267,9 @@ var McpServer = class {
14196
14267
  const uri = new URL(request.params.uri);
14197
14268
  const resource = this._registeredResources[uri.toString()];
14198
14269
  if (resource) {
14270
+ if (!resource.enabled) {
14271
+ throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} disabled`);
14272
+ }
14199
14273
  return resource.readCallback(uri, extra);
14200
14274
  }
14201
14275
  for (const template of Object.values(this._registeredResourceTemplates)) {
@@ -14216,10 +14290,12 @@ var McpServer = class {
14216
14290
  this.server.assertCanSetRequestHandler(ListPromptsRequestSchema.shape.method.value);
14217
14291
  this.server.assertCanSetRequestHandler(GetPromptRequestSchema.shape.method.value);
14218
14292
  this.server.registerCapabilities({
14219
- prompts: {}
14293
+ prompts: {
14294
+ listChanged: true
14295
+ }
14220
14296
  });
14221
14297
  this.server.setRequestHandler(ListPromptsRequestSchema, () => ({
14222
- prompts: Object.entries(this._registeredPrompts).map(([name, prompt]) => {
14298
+ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
14223
14299
  return {
14224
14300
  name,
14225
14301
  description: prompt.description,
@@ -14232,6 +14308,9 @@ var McpServer = class {
14232
14308
  if (!prompt) {
14233
14309
  throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
14234
14310
  }
14311
+ if (!prompt.enabled) {
14312
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
14313
+ }
14235
14314
  if (prompt.argsSchema) {
14236
14315
  const parseResult = await prompt.argsSchema.safeParseAsync(request.params.arguments);
14237
14316
  if (!parseResult.success) {
@@ -14258,22 +14337,69 @@ var McpServer = class {
14258
14337
  if (this._registeredResources[uriOrTemplate]) {
14259
14338
  throw new Error(`Resource ${uriOrTemplate} is already registered`);
14260
14339
  }
14261
- this._registeredResources[uriOrTemplate] = {
14340
+ const registeredResource = {
14262
14341
  name,
14263
14342
  metadata,
14264
- readCallback
14343
+ readCallback,
14344
+ enabled: true,
14345
+ disable: () => registeredResource.update({ enabled: false }),
14346
+ enable: () => registeredResource.update({ enabled: true }),
14347
+ remove: () => registeredResource.update({ uri: null }),
14348
+ update: (updates) => {
14349
+ if (typeof updates.uri !== "undefined" && updates.uri !== uriOrTemplate) {
14350
+ delete this._registeredResources[uriOrTemplate];
14351
+ if (updates.uri)
14352
+ this._registeredResources[updates.uri] = registeredResource;
14353
+ }
14354
+ if (typeof updates.name !== "undefined")
14355
+ registeredResource.name = updates.name;
14356
+ if (typeof updates.metadata !== "undefined")
14357
+ registeredResource.metadata = updates.metadata;
14358
+ if (typeof updates.callback !== "undefined")
14359
+ registeredResource.readCallback = updates.callback;
14360
+ if (typeof updates.enabled !== "undefined")
14361
+ registeredResource.enabled = updates.enabled;
14362
+ this.sendResourceListChanged();
14363
+ }
14265
14364
  };
14365
+ this._registeredResources[uriOrTemplate] = registeredResource;
14366
+ this.setResourceRequestHandlers();
14367
+ this.sendResourceListChanged();
14368
+ return registeredResource;
14266
14369
  } else {
14267
14370
  if (this._registeredResourceTemplates[name]) {
14268
14371
  throw new Error(`Resource template ${name} is already registered`);
14269
14372
  }
14270
- this._registeredResourceTemplates[name] = {
14373
+ const registeredResourceTemplate = {
14271
14374
  resourceTemplate: uriOrTemplate,
14272
14375
  metadata,
14273
- readCallback
14376
+ readCallback,
14377
+ enabled: true,
14378
+ disable: () => registeredResourceTemplate.update({ enabled: false }),
14379
+ enable: () => registeredResourceTemplate.update({ enabled: true }),
14380
+ remove: () => registeredResourceTemplate.update({ name: null }),
14381
+ update: (updates) => {
14382
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
14383
+ delete this._registeredResourceTemplates[name];
14384
+ if (updates.name)
14385
+ this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
14386
+ }
14387
+ if (typeof updates.template !== "undefined")
14388
+ registeredResourceTemplate.resourceTemplate = updates.template;
14389
+ if (typeof updates.metadata !== "undefined")
14390
+ registeredResourceTemplate.metadata = updates.metadata;
14391
+ if (typeof updates.callback !== "undefined")
14392
+ registeredResourceTemplate.readCallback = updates.callback;
14393
+ if (typeof updates.enabled !== "undefined")
14394
+ registeredResourceTemplate.enabled = updates.enabled;
14395
+ this.sendResourceListChanged();
14396
+ }
14274
14397
  };
14398
+ this._registeredResourceTemplates[name] = registeredResourceTemplate;
14399
+ this.setResourceRequestHandlers();
14400
+ this.sendResourceListChanged();
14401
+ return registeredResourceTemplate;
14275
14402
  }
14276
- this.setResourceRequestHandlers();
14277
14403
  }
14278
14404
  tool(name, ...rest) {
14279
14405
  if (this._registeredTools[name]) {
@@ -14284,16 +14410,51 @@ var McpServer = class {
14284
14410
  description = rest.shift();
14285
14411
  }
14286
14412
  let paramsSchema;
14413
+ let annotations;
14287
14414
  if (rest.length > 1) {
14288
- paramsSchema = rest.shift();
14415
+ const firstArg = rest[0];
14416
+ if (isZodRawShape(firstArg)) {
14417
+ paramsSchema = rest.shift();
14418
+ if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
14419
+ annotations = rest.shift();
14420
+ }
14421
+ } else if (typeof firstArg === "object" && firstArg !== null) {
14422
+ annotations = rest.shift();
14423
+ }
14289
14424
  }
14290
14425
  const cb = rest[0];
14291
- this._registeredTools[name] = {
14426
+ const registeredTool = {
14292
14427
  description,
14293
14428
  inputSchema: paramsSchema === void 0 ? void 0 : z.object(paramsSchema),
14294
- callback: cb
14429
+ annotations,
14430
+ callback: cb,
14431
+ enabled: true,
14432
+ disable: () => registeredTool.update({ enabled: false }),
14433
+ enable: () => registeredTool.update({ enabled: true }),
14434
+ remove: () => registeredTool.update({ name: null }),
14435
+ update: (updates) => {
14436
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
14437
+ delete this._registeredTools[name];
14438
+ if (updates.name)
14439
+ this._registeredTools[updates.name] = registeredTool;
14440
+ }
14441
+ if (typeof updates.description !== "undefined")
14442
+ registeredTool.description = updates.description;
14443
+ if (typeof updates.paramsSchema !== "undefined")
14444
+ registeredTool.inputSchema = z.object(updates.paramsSchema);
14445
+ if (typeof updates.callback !== "undefined")
14446
+ registeredTool.callback = updates.callback;
14447
+ if (typeof updates.annotations !== "undefined")
14448
+ registeredTool.annotations = updates.annotations;
14449
+ if (typeof updates.enabled !== "undefined")
14450
+ registeredTool.enabled = updates.enabled;
14451
+ this.sendToolListChanged();
14452
+ }
14295
14453
  };
14454
+ this._registeredTools[name] = registeredTool;
14296
14455
  this.setToolRequestHandlers();
14456
+ this.sendToolListChanged();
14457
+ return registeredTool;
14297
14458
  }
14298
14459
  prompt(name, ...rest) {
14299
14460
  if (this._registeredPrompts[name]) {
@@ -14308,17 +14469,80 @@ var McpServer = class {
14308
14469
  argsSchema = rest.shift();
14309
14470
  }
14310
14471
  const cb = rest[0];
14311
- this._registeredPrompts[name] = {
14472
+ const registeredPrompt = {
14312
14473
  description,
14313
14474
  argsSchema: argsSchema === void 0 ? void 0 : z.object(argsSchema),
14314
- callback: cb
14475
+ callback: cb,
14476
+ enabled: true,
14477
+ disable: () => registeredPrompt.update({ enabled: false }),
14478
+ enable: () => registeredPrompt.update({ enabled: true }),
14479
+ remove: () => registeredPrompt.update({ name: null }),
14480
+ update: (updates) => {
14481
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
14482
+ delete this._registeredPrompts[name];
14483
+ if (updates.name)
14484
+ this._registeredPrompts[updates.name] = registeredPrompt;
14485
+ }
14486
+ if (typeof updates.description !== "undefined")
14487
+ registeredPrompt.description = updates.description;
14488
+ if (typeof updates.argsSchema !== "undefined")
14489
+ registeredPrompt.argsSchema = z.object(updates.argsSchema);
14490
+ if (typeof updates.callback !== "undefined")
14491
+ registeredPrompt.callback = updates.callback;
14492
+ if (typeof updates.enabled !== "undefined")
14493
+ registeredPrompt.enabled = updates.enabled;
14494
+ this.sendPromptListChanged();
14495
+ }
14315
14496
  };
14497
+ this._registeredPrompts[name] = registeredPrompt;
14316
14498
  this.setPromptRequestHandlers();
14499
+ this.sendPromptListChanged();
14500
+ return registeredPrompt;
14501
+ }
14502
+ /**
14503
+ * Checks if the server is connected to a transport.
14504
+ * @returns True if the server is connected
14505
+ */
14506
+ isConnected() {
14507
+ return this.server.transport !== void 0;
14508
+ }
14509
+ /**
14510
+ * Sends a resource list changed event to the client, if connected.
14511
+ */
14512
+ sendResourceListChanged() {
14513
+ if (this.isConnected()) {
14514
+ this.server.sendResourceListChanged();
14515
+ }
14516
+ }
14517
+ /**
14518
+ * Sends a tool list changed event to the client, if connected.
14519
+ */
14520
+ sendToolListChanged() {
14521
+ if (this.isConnected()) {
14522
+ this.server.sendToolListChanged();
14523
+ }
14524
+ }
14525
+ /**
14526
+ * Sends a prompt list changed event to the client, if connected.
14527
+ */
14528
+ sendPromptListChanged() {
14529
+ if (this.isConnected()) {
14530
+ this.server.sendPromptListChanged();
14531
+ }
14317
14532
  }
14318
14533
  };
14319
14534
  var EMPTY_OBJECT_JSON_SCHEMA = {
14320
14535
  type: "object"
14321
14536
  };
14537
+ function isZodRawShape(obj) {
14538
+ if (typeof obj !== "object" || obj === null)
14539
+ return false;
14540
+ const isEmptyObject = Object.keys(obj).length === 0;
14541
+ return isEmptyObject || Object.values(obj).some(isZodTypeLike);
14542
+ }
14543
+ function isZodTypeLike(value) {
14544
+ return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
14545
+ }
14322
14546
  function promptArgumentsFromSchema(schema) {
14323
14547
  return Object.entries(schema.shape).map(([name, field]) => ({
14324
14548
  name,
@@ -14833,11 +15057,13 @@ var extractWixHttpErrorDetails = (error) => defaults(extractWixHttpErrorDetailsR
14833
15057
 
14834
15058
  // ../../node_modules/@wix/panorama-client/dist/esm/constants.js
14835
15059
  var MAX_STACK_TRACE_SIZE_BYTES = 32 * 1024;
15060
+ var MAX_SESSION_TIME_MS = 24 * 60 * 60 * 1e3;
14836
15061
 
14837
15062
  // ../../node_modules/@wix/panorama-client/dist/esm/lib/payload-sanitizer.js
14838
15063
  var sanitizePayload = (payload) => {
14839
15064
  const {
14840
- errorStack
15065
+ errorStack,
15066
+ sessionTime
14841
15067
  } = payload;
14842
15068
  if (errorStack && errorStack.length > MAX_STACK_TRACE_SIZE_BYTES) {
14843
15069
  const truncationMessage = `...[truncated by Panorama client to ${MAX_STACK_TRACE_SIZE_BYTES / 1024}kb]`;
@@ -14847,6 +15073,12 @@ var sanitizePayload = (payload) => {
14847
15073
  errorStack: `${truncatedErrorStack}${truncationMessage}`
14848
15074
  };
14849
15075
  }
15076
+ if (sessionTime && sessionTime > MAX_SESSION_TIME_MS) {
15077
+ payload = {
15078
+ ...payload,
15079
+ sessionTime: MAX_SESSION_TIME_MS
15080
+ };
15081
+ }
14850
15082
  return payload;
14851
15083
  };
14852
15084
 
@@ -15214,6 +15446,7 @@ var panoramaClient = function(options) {
15214
15446
  var StacktraceScriptType = /* @__PURE__ */ function(StacktraceScriptType2) {
15215
15447
  StacktraceScriptType2["WIX_SERVICE"] = "WIX_SERVICE";
15216
15448
  StacktraceScriptType2["WIX_APP"] = "WIX_APP";
15449
+ StacktraceScriptType2["WIX_CLI_APP"] = "WIX_CLI_APP";
15217
15450
  StacktraceScriptType2["WIX_CHAT"] = "WIX_CHAT_WIDGET";
15218
15451
  StacktraceScriptType2["BROWSER_EXTENSION"] = "BROWSER_EXTENSION";
15219
15452
  return StacktraceScriptType2;
@@ -17257,7 +17490,7 @@ function isNode5() {
17257
17490
 
17258
17491
  // ../../node_modules/@wix/headers/dist/esm/headers/artifact-id.js
17259
17492
  function artifactId3(override) {
17260
- const artifactIdToUse = process.env.ARTIFACT_ID ?? process.env.APP_NAME ?? "";
17493
+ const artifactIdToUse = isNode5() ? process.env.ARTIFACT_ID ?? process.env.APP_NAME ?? "" : "";
17261
17494
  return {
17262
17495
  "X-Wix-Client-Artifact-Id": override ?? (!isCI3() ? artifactIdToUse : "")
17263
17496
  };
@@ -17859,6 +18092,20 @@ function checkSanitizerPocEnabled3() {
17859
18092
  }
17860
18093
  }
17861
18094
 
18095
+ // src/infra/logger.ts
18096
+ import fs from "fs/promises";
18097
+ import path from "path";
18098
+ import { homedir } from "os";
18099
+ var createNullLogger = () => {
18100
+ return {
18101
+ log: () => {
18102
+ },
18103
+ error: () => {
18104
+ }
18105
+ };
18106
+ };
18107
+ var logger2 = createNullLogger();
18108
+
17862
18109
  // src/wix-mcp-server.ts
17863
18110
  var WixMcpServer = class extends McpServer {
17864
18111
  biLogger;
@@ -17872,6 +18119,7 @@ var WixMcpServer = class extends McpServer {
17872
18119
  this.biLogger = createBiLogger({
17873
18120
  _client_id: this.sessionId
17874
18121
  });
18122
+ logger2.log(`WixMcpServer created with sessionId: ${this.sessionId}`);
17875
18123
  }
17876
18124
  setUserIdGetter(getUserId) {
17877
18125
  this.getUserId = getUserId;
@@ -17967,20 +18215,6 @@ var WixMcpServer = class extends McpServer {
17967
18215
  }
17968
18216
  };
17969
18217
 
17970
- // src/infra/logger.ts
17971
- import fs from "fs/promises";
17972
- import path from "path";
17973
- import { homedir } from "os";
17974
- var createNullLogger = () => {
17975
- return {
17976
- log: () => {
17977
- },
17978
- error: () => {
17979
- }
17980
- };
17981
- };
17982
- var logger2 = createNullLogger();
17983
-
17984
18218
  // src/docs/semanticSearch.ts
17985
18219
  var MAX_CONTENT_LENGTH = 1e4;
17986
18220
  var DEFAULT_MAX_RESULTS = 10;
@@ -18577,17 +18811,13 @@ var addDocsTools = (server, allowedTools = [
18577
18811
 
18578
18812
  // src/docs/get-to-know.ts
18579
18813
  var defaultDocUrl = "https://dev.wix.com/docs/picasso/wix-ai-docs/rules/get-to-know-wix-llm-instructions";
18580
- var DESCRIPTION = `\u{1F534} **REQUIRED FIRST STEP for all Wix tasks.** This tool is the primary guide for the Wix ecosystem, offering global setup instructions and current best practices.
18814
+ var DESCRIPTION = `**Tool Name:** WixREADME
18815
+ **Description for LLM:**
18816
+ "**Mandatory First Action for Wix Tasks.** This tool, 'WixREADME', MUST be executed at the very beginning of any process involving Wix functionalities. It provides the indispensable foundational Wix ecosystem context, global setup details, and current best practices.
18581
18817
 
18582
- **Rule: ALWAYS run this tool successfully BEFORE any other Wix-specific action (e.g., doc searches, API calls, coding). NO EXCEPTIONS.** Failing to do so will likely cause errors.
18818
+ **Operational Rule:** Your processing protocol for any Wix-related task dictates that 'WixREADME' is successfully invoked and its output comprehensively analyzed BEFORE any other Wix-specific tool (such as 'ReadFullDocsArticle' or 'SearchX..') is considered or used. This is a non-negotiable prerequisite.
18583
18819
 
18584
- The information from this tool is foundational and MUST inform all subsequent Wix actions.
18585
-
18586
- **Instructions for user requests:**
18587
-
18588
- 1. **Identify Wix concepts** relevant to the query (refer to ReadMe).
18589
- 2. **Read best practices:** For each concept, if a \`<best-practices>{url}</best-practices>\` document exists in ReadMe, use 'ReadFullDocsArticle' to access it.
18590
- 3. **Search:** If more information is needed, use 'SearchX' tools.`;
18820
+ **Function:** Acts as the sole authoritative source for Wix global operational standards and session initialization. Its output is essential for the correct and safe execution of all subsequent Wix-related actions. All other Wix tools are designed to rely on the information it provides."`;
18591
18821
  async function addGetToKnowTools(server, docUrl) {
18592
18822
  server.tool("WixREADME", DESCRIPTION, async ({ httpClient }) => {
18593
18823
  try {
@@ -18622,20 +18852,33 @@ var safeParseJSON = (text) => {
18622
18852
  return text;
18623
18853
  }
18624
18854
  };
18855
+ var buildErrorMessage = ({
18856
+ status,
18857
+ statusText,
18858
+ requestId,
18859
+ responseData
18860
+ }) => {
18861
+ const responseDataObject = typeof responseData === "string" ? safeParseJSON(responseData) : responseData;
18862
+ const errorDetails = typeof responseDataObject === "object" ? JSON.stringify(responseDataObject) : responseDataObject;
18863
+ return [
18864
+ `Failed to call Wix API:${status ? ` ${status}` : ""}${statusText ? ` ${statusText}` : ""}.`,
18865
+ requestId ? `request id: ${requestId}` : "",
18866
+ // Wix 404 for API does not exist is huge (generic 404 page) and loaded to the context
18867
+ status === 404 && errorDetails.includes("<html") ? "Not found" : errorDetails
18868
+ ].filter((str) => !!str).join("\n");
18869
+ };
18625
18870
  var handleWixAPIResponse = async (response) => {
18626
- const responseData = typeof response.data === "string" ? safeParseJSON(response.data) : response.data;
18871
+ const requestId = response.headers.get("x-wix-request-id");
18627
18872
  if (!response.status.toString().startsWith("2")) {
18628
- const requestId = response.headers.get("x-wix-request-id");
18629
- const errorDetails = typeof responseData === "object" ? JSON.stringify(responseData) : responseData;
18630
- throw new Error(
18631
- [
18632
- `Failed to call Wix API: ${response.status} ${response.statusText}.`,
18633
- requestId ? `request id: ${requestId}` : "",
18634
- // Wix 404 for API does not exist is huge (generic 404 page) and loaded to the context
18635
- response.status === 404 && errorDetails.includes("<html") ? "Not found" : errorDetails
18636
- ].filter((str) => !!str).join("\n")
18637
- );
18873
+ const errorMessage = buildErrorMessage({
18874
+ status: response.status,
18875
+ statusText: response.statusText,
18876
+ requestId,
18877
+ responseData: response.data
18878
+ });
18879
+ throw new Error(errorMessage);
18638
18880
  }
18881
+ const responseData = typeof response.data === "string" ? safeParseJSON(response.data) : response.data;
18639
18882
  return responseData;
18640
18883
  };
18641
18884