@wix/mcp 1.0.84 → 1.0.85

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.
@@ -52838,11 +52838,13 @@ function validateExecuteCode(code) {
52838
52838
  }
52839
52839
 
52840
52840
  // src/code-mode/index.ts
52841
+ var defaultCodeModeFetch = (url, init) => fetch(url, init);
52841
52842
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
52842
52843
  var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
52843
52844
  async function addCodeModeTools(server, options) {
52844
52845
  const {
52845
52846
  codeModeBaseUrl,
52847
+ codeModeFetch,
52846
52848
  authStrategy,
52847
52849
  disableTools = [],
52848
52850
  toolDescriptions,
@@ -52852,6 +52854,7 @@ async function addCodeModeTools(server, options) {
52852
52854
  if (!disableTools.includes(EXECUTE_TOOL_NAME) && authStrategy) {
52853
52855
  addExecuteCodeModeTool(server, {
52854
52856
  codeModeBaseUrl,
52857
+ codeModeFetch,
52855
52858
  authStrategy,
52856
52859
  disableTools,
52857
52860
  toolDescriptions,
@@ -52862,6 +52865,7 @@ async function addCodeModeTools(server, options) {
52862
52865
  function addSearchCodeModeTool(server, options) {
52863
52866
  const {
52864
52867
  codeModeBaseUrl,
52868
+ codeModeFetch,
52865
52869
  authStrategy,
52866
52870
  disableTools = [],
52867
52871
  toolDescriptions,
@@ -52876,12 +52880,14 @@ function addSearchCodeModeTool(server, options) {
52876
52880
  codeModeBaseUrl,
52877
52881
  description,
52878
52882
  maxResponseSize,
52879
- authStrategy
52883
+ authStrategy,
52884
+ codeModeFetch
52880
52885
  );
52881
52886
  }
52882
52887
  function addExecuteCodeModeTool(server, options) {
52883
52888
  const {
52884
52889
  codeModeBaseUrl,
52890
+ codeModeFetch,
52885
52891
  authStrategy,
52886
52892
  visitor,
52887
52893
  disableTools = [],
@@ -52893,6 +52899,7 @@ function addExecuteCodeModeTool(server, options) {
52893
52899
  }
52894
52900
  addExecuteTool(server, {
52895
52901
  codeModeBaseUrl,
52902
+ codeModeFetch,
52896
52903
  authStrategy,
52897
52904
  visitor,
52898
52905
  toolDescriptions,
@@ -52907,7 +52914,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
52907
52914
  return void 0;
52908
52915
  }
52909
52916
  }
52910
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
52917
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
52911
52918
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
52912
52919
  server.tool(
52913
52920
  SEARCH_TOOL_NAME,
@@ -52927,7 +52934,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
52927
52934
  );
52928
52935
  try {
52929
52936
  const authorization = await resolveLoopbackAuthorization(authStrategy);
52930
- const resp = await fetch(searchUrl, {
52937
+ const resp = await codeModeFetch(searchUrl, {
52931
52938
  method: "POST",
52932
52939
  headers: {
52933
52940
  "Content-Type": "application/json",
@@ -52978,8 +52985,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
52978
52985
  }
52979
52986
  );
52980
52987
  }
52981
- async function postExecute(executeUrl, body, authorization) {
52982
- const resp = await fetch(executeUrl, {
52988
+ async function postExecute(executeUrl, body, authorization, codeModeFetch = defaultCodeModeFetch) {
52989
+ const resp = await codeModeFetch(executeUrl, {
52983
52990
  method: "POST",
52984
52991
  headers: {
52985
52992
  "Content-Type": "application/json",
@@ -53021,6 +53028,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
53021
53028
  function addExecuteTool(server, options) {
53022
53029
  const {
53023
53030
  codeModeBaseUrl,
53031
+ codeModeFetch,
53024
53032
  authStrategy,
53025
53033
  visitor,
53026
53034
  toolDescriptions,
@@ -53109,7 +53117,8 @@ function addExecuteTool(server, options) {
53109
53117
  accountId: accountHeaders?.["wix-account-id"],
53110
53118
  siteAuthContext
53111
53119
  },
53112
- visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
53120
+ visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
53121
+ codeModeFetch
53113
53122
  );
53114
53123
  if (data.authErrorStatus && visitor) {
53115
53124
  return executeErrorResult(
@@ -53269,7 +53278,8 @@ function createWixToolkit(options) {
53269
53278
  toolDescriptions,
53270
53279
  toolHints,
53271
53280
  maxResponseSize,
53272
- codeModeBaseUrl = "https://mcp.wix.com"
53281
+ codeModeBaseUrl = "https://mcp.wix.com",
53282
+ codeModeFetch
53273
53283
  } = api;
53274
53284
  const effectiveToolDescriptions = {
53275
53285
  ...descriptionsWithoutReadme,
@@ -53293,6 +53303,7 @@ function createWixToolkit(options) {
53293
53303
  if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
53294
53304
  addSearchCodeModeTool(server, {
53295
53305
  codeModeBaseUrl,
53306
+ codeModeFetch,
53296
53307
  authStrategy,
53297
53308
  disableTools,
53298
53309
  toolDescriptions: effectiveToolDescriptions,
@@ -53302,6 +53313,7 @@ function createWixToolkit(options) {
53302
53313
  if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
53303
53314
  addExecuteCodeModeTool(server, {
53304
53315
  codeModeBaseUrl,
53316
+ codeModeFetch,
53305
53317
  authStrategy,
53306
53318
  disableTools,
53307
53319
  toolDescriptions: effectiveToolDescriptions,
@@ -22028,11 +22028,13 @@ function validateExecuteCode(code) {
22028
22028
  }
22029
22029
 
22030
22030
  // src/code-mode/index.ts
22031
+ var defaultCodeModeFetch = (url, init) => fetch(url, init);
22031
22032
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
22032
22033
  var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
22033
22034
  function addSearchCodeModeTool(server, options) {
22034
22035
  const {
22035
22036
  codeModeBaseUrl,
22037
+ codeModeFetch,
22036
22038
  authStrategy,
22037
22039
  disableTools = [],
22038
22040
  toolDescriptions,
@@ -22047,12 +22049,14 @@ function addSearchCodeModeTool(server, options) {
22047
22049
  codeModeBaseUrl,
22048
22050
  description,
22049
22051
  maxResponseSize,
22050
- authStrategy
22052
+ authStrategy,
22053
+ codeModeFetch
22051
22054
  );
22052
22055
  }
22053
22056
  function addExecuteCodeModeTool(server, options) {
22054
22057
  const {
22055
22058
  codeModeBaseUrl,
22059
+ codeModeFetch,
22056
22060
  authStrategy,
22057
22061
  visitor,
22058
22062
  disableTools = [],
@@ -22064,6 +22068,7 @@ function addExecuteCodeModeTool(server, options) {
22064
22068
  }
22065
22069
  addExecuteTool(server, {
22066
22070
  codeModeBaseUrl,
22071
+ codeModeFetch,
22067
22072
  authStrategy,
22068
22073
  visitor,
22069
22074
  toolDescriptions,
@@ -22078,7 +22083,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
22078
22083
  return void 0;
22079
22084
  }
22080
22085
  }
22081
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
22086
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
22082
22087
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
22083
22088
  server.tool(
22084
22089
  SEARCH_TOOL_NAME,
@@ -22098,7 +22103,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
22098
22103
  );
22099
22104
  try {
22100
22105
  const authorization = await resolveLoopbackAuthorization(authStrategy);
22101
- const resp = await fetch(searchUrl, {
22106
+ const resp = await codeModeFetch(searchUrl, {
22102
22107
  method: "POST",
22103
22108
  headers: {
22104
22109
  "Content-Type": "application/json",
@@ -22149,8 +22154,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
22149
22154
  }
22150
22155
  );
22151
22156
  }
22152
- async function postExecute(executeUrl, body, authorization) {
22153
- const resp = await fetch(executeUrl, {
22157
+ async function postExecute(executeUrl, body, authorization, codeModeFetch = defaultCodeModeFetch) {
22158
+ const resp = await codeModeFetch(executeUrl, {
22154
22159
  method: "POST",
22155
22160
  headers: {
22156
22161
  "Content-Type": "application/json",
@@ -22192,6 +22197,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
22192
22197
  function addExecuteTool(server, options) {
22193
22198
  const {
22194
22199
  codeModeBaseUrl,
22200
+ codeModeFetch,
22195
22201
  authStrategy,
22196
22202
  visitor,
22197
22203
  toolDescriptions,
@@ -22280,7 +22286,8 @@ function addExecuteTool(server, options) {
22280
22286
  accountId: accountHeaders?.["wix-account-id"],
22281
22287
  siteAuthContext
22282
22288
  },
22283
- visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
22289
+ visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
22290
+ codeModeFetch
22284
22291
  );
22285
22292
  if (data.authErrorStatus && visitor) {
22286
22293
  return executeErrorResult(
@@ -22542,7 +22549,8 @@ function createWixToolkit(options) {
22542
22549
  toolDescriptions,
22543
22550
  toolHints,
22544
22551
  maxResponseSize,
22545
- codeModeBaseUrl = "https://mcp.wix.com"
22552
+ codeModeBaseUrl = "https://mcp.wix.com",
22553
+ codeModeFetch
22546
22554
  } = api;
22547
22555
  const effectiveToolDescriptions = {
22548
22556
  ...descriptionsWithoutReadme,
@@ -22566,6 +22574,7 @@ function createWixToolkit(options) {
22566
22574
  if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
22567
22575
  addSearchCodeModeTool(server, {
22568
22576
  codeModeBaseUrl,
22577
+ codeModeFetch,
22569
22578
  authStrategy,
22570
22579
  disableTools,
22571
22580
  toolDescriptions: effectiveToolDescriptions,
@@ -22575,6 +22584,7 @@ function createWixToolkit(options) {
22575
22584
  if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
22576
22585
  addExecuteCodeModeTool(server, {
22577
22586
  codeModeBaseUrl,
22587
+ codeModeFetch,
22578
22588
  authStrategy,
22579
22589
  disableTools,
22580
22590
  toolDescriptions: effectiveToolDescriptions,
@@ -1,7 +1,14 @@
1
1
  import { WixMcpServer } from '../wix-mcp-server.js';
2
2
  import { type McpAuthenticationStrategy } from '../auth/index.js';
3
+ /**
4
+ * Transport for the code-mode endpoints (`/api/code-mode/search|execute`).
5
+ * Defaults to the global `fetch`; a host that serves those endpoints itself
6
+ * can pass an in-runtime loopback instead.
7
+ */
8
+ export type CodeModeFetch = (url: string, init: RequestInit) => Promise<Response>;
3
9
  export interface CodeModeOptions {
4
10
  codeModeBaseUrl: string;
11
+ codeModeFetch?: CodeModeFetch;
5
12
  authStrategy?: McpAuthenticationStrategy;
6
13
  /**
7
14
  * Visitor mode: pin ExecuteWixAPI to one site and take an agent-supplied
@@ -6,14 +6,17 @@ import { validateExecuteCode } from './validation.js';
6
6
  import { desc } from '../config/param-descriptions.js';
7
7
  import { rethrowIfUnauthorized } from '../auth/index.js';
8
8
  import { WixFetchError } from '../wix-fetch-error.js';
9
+ // Looks `fetch` up per call so a host or test that swaps the global is honored.
10
+ const defaultCodeModeFetch = (url, init) => fetch(url, init);
9
11
  const SEARCH_TOOL_NAME = 'SearchWixAPISpec';
10
12
  export const EXECUTE_TOOL_NAME = 'ExecuteWixAPI';
11
13
  export async function addCodeModeTools(server, options) {
12
- const { codeModeBaseUrl, authStrategy, disableTools = [], toolDescriptions, maxResponseSize } = options;
14
+ const { codeModeBaseUrl, codeModeFetch, authStrategy, disableTools = [], toolDescriptions, maxResponseSize } = options;
13
15
  addSearchCodeModeTool(server, options);
14
16
  if (!disableTools.includes(EXECUTE_TOOL_NAME) && authStrategy) {
15
17
  addExecuteCodeModeTool(server, {
16
18
  codeModeBaseUrl,
19
+ codeModeFetch,
17
20
  authStrategy,
18
21
  disableTools,
19
22
  toolDescriptions,
@@ -29,21 +32,22 @@ export async function addCodeModeTools(server, options) {
29
32
  * lightIndex.
30
33
  */
31
34
  export function addSearchCodeModeTool(server, options) {
32
- const { codeModeBaseUrl, authStrategy, disableTools = [], toolDescriptions, maxResponseSize } = options;
35
+ const { codeModeBaseUrl, codeModeFetch, authStrategy, disableTools = [], toolDescriptions, maxResponseSize } = options;
33
36
  if (disableTools.includes(SEARCH_TOOL_NAME)) {
34
37
  return;
35
38
  }
36
39
  const description = toolDescriptions?.[SEARCH_TOOL_NAME] ??
37
40
  defaultToolDescriptions.SearchWixAPISpec;
38
- registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy);
41
+ registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch);
39
42
  }
40
43
  export function addExecuteCodeModeTool(server, options) {
41
- const { codeModeBaseUrl, authStrategy, visitor, disableTools = [], toolDescriptions, maxResponseSize } = options;
44
+ const { codeModeBaseUrl, codeModeFetch, authStrategy, visitor, disableTools = [], toolDescriptions, maxResponseSize } = options;
42
45
  if ((!authStrategy && !visitor) || disableTools.includes(EXECUTE_TOOL_NAME)) {
43
46
  return;
44
47
  }
45
48
  addExecuteTool(server, {
46
49
  codeModeBaseUrl,
50
+ codeModeFetch,
47
51
  authStrategy,
48
52
  visitor,
49
53
  toolDescriptions,
@@ -64,7 +68,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
64
68
  return undefined;
65
69
  }
66
70
  }
67
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
71
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
68
72
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
69
73
  server.tool(SEARCH_TOOL_NAME, description, {
70
74
  code: z
@@ -77,7 +81,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
77
81
  logger.log(`[SearchWixAPISpec] Executing search (${code.length} chars), reason="${reason}"`);
78
82
  try {
79
83
  const authorization = await resolveLoopbackAuthorization(authStrategy);
80
- const resp = await fetch(searchUrl, {
84
+ const resp = await codeModeFetch(searchUrl, {
81
85
  method: 'POST',
82
86
  headers: {
83
87
  'Content-Type': 'application/json',
@@ -135,8 +139,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
135
139
  * the call looked anonymous to `rateLimiterMiddleware` and shared its IP-keyed
136
140
  * bucket — it comes from the Durable Object, not the client.
137
141
  */
138
- async function postExecute(executeUrl, body, authorization) {
139
- const resp = await fetch(executeUrl, {
142
+ async function postExecute(executeUrl, body, authorization, codeModeFetch = defaultCodeModeFetch) {
143
+ const resp = await codeModeFetch(executeUrl, {
140
144
  method: 'POST',
141
145
  headers: {
142
146
  'Content-Type': 'application/json',
@@ -179,7 +183,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
179
183
  };
180
184
  }
181
185
  function addExecuteTool(server, options) {
182
- const { codeModeBaseUrl, authStrategy, visitor, toolDescriptions, maxResponseSize } = options;
186
+ const { codeModeBaseUrl, codeModeFetch, authStrategy, visitor, toolDescriptions, maxResponseSize } = options;
183
187
  const executeUrl = `${codeModeBaseUrl}/api/code-mode/execute`;
184
188
  const d = desc('ExecuteWixAPI');
185
189
  server.tool(EXECUTE_TOOL_NAME, toolDescriptions?.[EXECUTE_TOOL_NAME] ??
@@ -289,7 +293,7 @@ function addExecuteTool(server, options) {
289
293
  siteAuthContext
290
294
  }, visitor
291
295
  ? visitorToken
292
- : (accountHeaders?.Authorization ?? siteHeaders?.Authorization));
296
+ : (accountHeaders?.Authorization ?? siteHeaders?.Authorization), codeModeFetch);
293
297
  // Visitor mode can't refresh server-side, so steer the agent to regenerate.
294
298
  if (data.authErrorStatus && visitor) {
295
299
  return executeErrorResult(`Visitor token rejected (HTTP ${data.authErrorStatus}). Call GenerateVisitorToken to obtain a fresh token, then retry.`);
@@ -21,7 +21,7 @@ export type { WixToolCallResult, WixToolContentBlock, WixToolAnnotations } from
21
21
  export { createWixToolkit, extractText, type WixTool, type WixToolkit, type WixToolkitOptions, type WixToolkitHooks, type WixToolkitAuth, type WixToolkitDocsConfig, type WixToolkitApiConfig } from './toolkit.js';
22
22
  export { fetchRecipesIndex, fetchArticle, RECIPES_INDEX_URL } from './docs/fetch-article.js';
23
23
  export { generateDocsNavigationTree, fetchMenuContent, MENU_CONTENT_THRESHOLD, normalizeMenuContent, summarizeLargeMenu, parseDirectChildren } from './docs/normalize-menu-content.js';
24
- export { addCodeModeTools, addExecuteCodeModeTool, addSearchCodeModeTool, type CodeModeOptions } from './code-mode/index.js';
24
+ export { addCodeModeTools, addExecuteCodeModeTool, addSearchCodeModeTool, type CodeModeFetch, type CodeModeOptions } from './code-mode/index.js';
25
25
  export { validateExecuteCode, EXECUTE_FUNCTION_EXPRESSION_HINT, type CodeValidationResult } from './code-mode/validation.js';
26
26
  export { addGraphqlTools, resetGraphqlSchemaCache, GRAPHQL_TOOL_NAMES, SEARCH_GRAPHQL_TOOL_NAME, INSPECT_GRAPHQL_TOOL_NAME, EXECUTE_GRAPHQL_TOOL_NAME, WIX_GRAPHQL_ENDPOINT, type GraphqlToolsOptions, type GraphqlToolName } from './graphql/index.js';
27
27
  export { defaultConfig, defaultToolDescriptions, defaultReadmeDocs, widgetSiteCreationConfig, SITE_CREATION_COPY, toWidget, executeCodeModeToolDescriptions, SYSTEM_REMINDER_GUIDELINES, SYSTEM_REMINDER, mergeConfig, type ModeDefaultConfig } from './config/default-config.js';
@@ -163,6 +163,12 @@ export interface ToolHintsConfig {
163
163
  destructiveHint?: boolean;
164
164
  openWorldHint?: boolean;
165
165
  }
166
+ /**
167
+ * Transport for the code-mode endpoints (`/api/code-mode/search|execute`).
168
+ * Defaults to the global `fetch`; a host that serves those endpoints itself
169
+ * can pass an in-runtime loopback instead.
170
+ */
171
+ export type CodeModeFetch = (url: string, init: RequestInit) => Promise<Response>;
166
172
  /**
167
173
  * Safely extract all text content from a WixToolCallResult.
168
174
  * Filters out non-text content blocks (images, audio, resources)
@@ -251,6 +257,8 @@ export interface WixToolkitApiConfig {
251
257
  maxResponseSize?: number;
252
258
  /** Base URL for code-mode tools such as ExecuteWixAPI */
253
259
  codeModeBaseUrl?: string;
260
+ /** Transport for the code-mode endpoints; defaults to the global `fetch`. */
261
+ codeModeFetch?: CodeModeFetch;
254
262
  }
255
263
  /** Options for createWixToolkit. */
256
264
  export interface WixToolkitOptions {
@@ -163,6 +163,12 @@ export interface ToolHintsConfig {
163
163
  destructiveHint?: boolean;
164
164
  openWorldHint?: boolean;
165
165
  }
166
+ /**
167
+ * Transport for the code-mode endpoints (`/api/code-mode/search|execute`).
168
+ * Defaults to the global `fetch`; a host that serves those endpoints itself
169
+ * can pass an in-runtime loopback instead.
170
+ */
171
+ export type CodeModeFetch = (url: string, init: RequestInit) => Promise<Response>;
166
172
  /**
167
173
  * Safely extract all text content from a WixToolCallResult.
168
174
  * Filters out non-text content blocks (images, audio, resources)
@@ -251,6 +257,8 @@ export interface WixToolkitApiConfig {
251
257
  maxResponseSize?: number;
252
258
  /** Base URL for code-mode tools such as ExecuteWixAPI */
253
259
  codeModeBaseUrl?: string;
260
+ /** Transport for the code-mode endpoints; defaults to the global `fetch`. */
261
+ codeModeFetch?: CodeModeFetch;
254
262
  }
255
263
  /** Options for createWixToolkit. */
256
264
  export interface WixToolkitOptions {
@@ -30,6 +30,7 @@ import type { WixToolCallResult, WixToolAnnotations } from './toolkit-types.js';
30
30
  import { z } from 'zod';
31
31
  import { type DocsToolsOptions, type DocsTool } from './docs/docs.js';
32
32
  import { type ToolHintsConfig } from './api-call/index.js';
33
+ import { type CodeModeFetch } from './code-mode/index.js';
33
34
  import type { McpAuthenticationStrategy, McpHeaders } from './auth/index.js';
34
35
  import { extractText, formatToolResultAdditionalFields } from './infra/tool-bi.js';
35
36
  /** A single tool extracted from @wix/mcp, ready to execute. */
@@ -113,6 +114,8 @@ export interface WixToolkitApiConfig {
113
114
  maxResponseSize?: number;
114
115
  /** Base URL for code-mode tools such as ExecuteWixAPI */
115
116
  codeModeBaseUrl?: string;
117
+ /** Transport for the code-mode endpoints; defaults to the global `fetch`. */
118
+ codeModeFetch?: CodeModeFetch;
116
119
  }
117
120
  /** Options for createWixToolkit. */
118
121
  export interface WixToolkitOptions {
@@ -193,7 +193,7 @@ export function createWixToolkit(options) {
193
193
  }
194
194
  // Register API tools
195
195
  if (api) {
196
- const { tools: apiTools, disableTools, enableTools, toolDescriptions, toolHints, maxResponseSize, codeModeBaseUrl = 'https://mcp.wix.com' } = api;
196
+ const { tools: apiTools, disableTools, enableTools, toolDescriptions, toolHints, maxResponseSize, codeModeBaseUrl = 'https://mcp.wix.com', codeModeFetch } = api;
197
197
  // Precedence (low → high): README-free defaults, code-mode variant, consumer overrides.
198
198
  const effectiveToolDescriptions = {
199
199
  ...descriptionsWithoutReadme,
@@ -209,6 +209,7 @@ export function createWixToolkit(options) {
209
209
  !disableTools?.includes('SearchWixAPISpec')) {
210
210
  addSearchCodeModeTool(server, {
211
211
  codeModeBaseUrl,
212
+ codeModeFetch,
212
213
  authStrategy,
213
214
  disableTools,
214
215
  toolDescriptions: effectiveToolDescriptions,
@@ -219,6 +220,7 @@ export function createWixToolkit(options) {
219
220
  !disableTools?.includes('ExecuteWixAPI')) {
220
221
  addExecuteCodeModeTool(server, {
221
222
  codeModeBaseUrl,
223
+ codeModeFetch,
222
224
  authStrategy,
223
225
  disableTools,
224
226
  toolDescriptions: effectiveToolDescriptions,
@@ -46602,11 +46602,13 @@ function validateExecuteCode(code) {
46602
46602
  }
46603
46603
 
46604
46604
  // src/code-mode/index.ts
46605
+ var defaultCodeModeFetch = (url, init) => fetch(url, init);
46605
46606
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
46606
46607
  var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
46607
46608
  async function addCodeModeTools(server, options) {
46608
46609
  const {
46609
46610
  codeModeBaseUrl,
46611
+ codeModeFetch,
46610
46612
  authStrategy,
46611
46613
  disableTools = [],
46612
46614
  toolDescriptions,
@@ -46616,6 +46618,7 @@ async function addCodeModeTools(server, options) {
46616
46618
  if (!disableTools.includes(EXECUTE_TOOL_NAME) && authStrategy) {
46617
46619
  addExecuteCodeModeTool(server, {
46618
46620
  codeModeBaseUrl,
46621
+ codeModeFetch,
46619
46622
  authStrategy,
46620
46623
  disableTools,
46621
46624
  toolDescriptions,
@@ -46626,6 +46629,7 @@ async function addCodeModeTools(server, options) {
46626
46629
  function addSearchCodeModeTool(server, options) {
46627
46630
  const {
46628
46631
  codeModeBaseUrl,
46632
+ codeModeFetch,
46629
46633
  authStrategy,
46630
46634
  disableTools = [],
46631
46635
  toolDescriptions,
@@ -46640,12 +46644,14 @@ function addSearchCodeModeTool(server, options) {
46640
46644
  codeModeBaseUrl,
46641
46645
  description,
46642
46646
  maxResponseSize,
46643
- authStrategy
46647
+ authStrategy,
46648
+ codeModeFetch
46644
46649
  );
46645
46650
  }
46646
46651
  function addExecuteCodeModeTool(server, options) {
46647
46652
  const {
46648
46653
  codeModeBaseUrl,
46654
+ codeModeFetch,
46649
46655
  authStrategy,
46650
46656
  visitor,
46651
46657
  disableTools = [],
@@ -46657,6 +46663,7 @@ function addExecuteCodeModeTool(server, options) {
46657
46663
  }
46658
46664
  addExecuteTool(server, {
46659
46665
  codeModeBaseUrl,
46666
+ codeModeFetch,
46660
46667
  authStrategy,
46661
46668
  visitor,
46662
46669
  toolDescriptions,
@@ -46671,7 +46678,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
46671
46678
  return void 0;
46672
46679
  }
46673
46680
  }
46674
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
46681
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
46675
46682
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
46676
46683
  server.tool(
46677
46684
  SEARCH_TOOL_NAME,
@@ -46691,7 +46698,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
46691
46698
  );
46692
46699
  try {
46693
46700
  const authorization3 = await resolveLoopbackAuthorization(authStrategy);
46694
- const resp = await fetch(searchUrl, {
46701
+ const resp = await codeModeFetch(searchUrl, {
46695
46702
  method: "POST",
46696
46703
  headers: {
46697
46704
  "Content-Type": "application/json",
@@ -46742,8 +46749,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
46742
46749
  }
46743
46750
  );
46744
46751
  }
46745
- async function postExecute(executeUrl, body, authorization3) {
46746
- const resp = await fetch(executeUrl, {
46752
+ async function postExecute(executeUrl, body, authorization3, codeModeFetch = defaultCodeModeFetch) {
46753
+ const resp = await codeModeFetch(executeUrl, {
46747
46754
  method: "POST",
46748
46755
  headers: {
46749
46756
  "Content-Type": "application/json",
@@ -46785,6 +46792,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
46785
46792
  function addExecuteTool(server, options) {
46786
46793
  const {
46787
46794
  codeModeBaseUrl,
46795
+ codeModeFetch,
46788
46796
  authStrategy,
46789
46797
  visitor,
46790
46798
  toolDescriptions,
@@ -46873,7 +46881,8 @@ function addExecuteTool(server, options) {
46873
46881
  accountId: accountHeaders?.["wix-account-id"],
46874
46882
  siteAuthContext
46875
46883
  },
46876
- visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
46884
+ visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
46885
+ codeModeFetch
46877
46886
  );
46878
46887
  if (data.authErrorStatus && visitor) {
46879
46888
  return executeErrorResult(
@@ -47033,7 +47042,8 @@ function createWixToolkit(options) {
47033
47042
  toolDescriptions,
47034
47043
  toolHints,
47035
47044
  maxResponseSize,
47036
- codeModeBaseUrl = "https://mcp.wix.com"
47045
+ codeModeBaseUrl = "https://mcp.wix.com",
47046
+ codeModeFetch
47037
47047
  } = api;
47038
47048
  const effectiveToolDescriptions = {
47039
47049
  ...descriptionsWithoutReadme,
@@ -47057,6 +47067,7 @@ function createWixToolkit(options) {
47057
47067
  if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
47058
47068
  addSearchCodeModeTool(server, {
47059
47069
  codeModeBaseUrl,
47070
+ codeModeFetch,
47060
47071
  authStrategy,
47061
47072
  disableTools,
47062
47073
  toolDescriptions: effectiveToolDescriptions,
@@ -47066,6 +47077,7 @@ function createWixToolkit(options) {
47066
47077
  if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
47067
47078
  addExecuteCodeModeTool(server, {
47068
47079
  codeModeBaseUrl,
47080
+ codeModeFetch,
47069
47081
  authStrategy,
47070
47082
  disableTools,
47071
47083
  toolDescriptions: effectiveToolDescriptions,
@@ -16447,11 +16447,13 @@ function validateExecuteCode(code) {
16447
16447
  }
16448
16448
 
16449
16449
  // src/code-mode/index.ts
16450
+ var defaultCodeModeFetch = (url, init) => fetch(url, init);
16450
16451
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
16451
16452
  var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
16452
16453
  function addSearchCodeModeTool(server, options) {
16453
16454
  const {
16454
16455
  codeModeBaseUrl,
16456
+ codeModeFetch,
16455
16457
  authStrategy,
16456
16458
  disableTools = [],
16457
16459
  toolDescriptions,
@@ -16466,12 +16468,14 @@ function addSearchCodeModeTool(server, options) {
16466
16468
  codeModeBaseUrl,
16467
16469
  description,
16468
16470
  maxResponseSize,
16469
- authStrategy
16471
+ authStrategy,
16472
+ codeModeFetch
16470
16473
  );
16471
16474
  }
16472
16475
  function addExecuteCodeModeTool(server, options) {
16473
16476
  const {
16474
16477
  codeModeBaseUrl,
16478
+ codeModeFetch,
16475
16479
  authStrategy,
16476
16480
  visitor,
16477
16481
  disableTools = [],
@@ -16483,6 +16487,7 @@ function addExecuteCodeModeTool(server, options) {
16483
16487
  }
16484
16488
  addExecuteTool(server, {
16485
16489
  codeModeBaseUrl,
16490
+ codeModeFetch,
16486
16491
  authStrategy,
16487
16492
  visitor,
16488
16493
  toolDescriptions,
@@ -16497,7 +16502,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
16497
16502
  return void 0;
16498
16503
  }
16499
16504
  }
16500
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
16505
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
16501
16506
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
16502
16507
  server.tool(
16503
16508
  SEARCH_TOOL_NAME,
@@ -16517,7 +16522,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
16517
16522
  );
16518
16523
  try {
16519
16524
  const authorization3 = await resolveLoopbackAuthorization(authStrategy);
16520
- const resp = await fetch(searchUrl, {
16525
+ const resp = await codeModeFetch(searchUrl, {
16521
16526
  method: "POST",
16522
16527
  headers: {
16523
16528
  "Content-Type": "application/json",
@@ -16568,8 +16573,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
16568
16573
  }
16569
16574
  );
16570
16575
  }
16571
- async function postExecute(executeUrl, body, authorization3) {
16572
- const resp = await fetch(executeUrl, {
16576
+ async function postExecute(executeUrl, body, authorization3, codeModeFetch = defaultCodeModeFetch) {
16577
+ const resp = await codeModeFetch(executeUrl, {
16573
16578
  method: "POST",
16574
16579
  headers: {
16575
16580
  "Content-Type": "application/json",
@@ -16611,6 +16616,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
16611
16616
  function addExecuteTool(server, options) {
16612
16617
  const {
16613
16618
  codeModeBaseUrl,
16619
+ codeModeFetch,
16614
16620
  authStrategy,
16615
16621
  visitor,
16616
16622
  toolDescriptions,
@@ -16699,7 +16705,8 @@ function addExecuteTool(server, options) {
16699
16705
  accountId: accountHeaders?.["wix-account-id"],
16700
16706
  siteAuthContext
16701
16707
  },
16702
- visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
16708
+ visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
16709
+ codeModeFetch
16703
16710
  );
16704
16711
  if (data.authErrorStatus && visitor) {
16705
16712
  return executeErrorResult(
@@ -18713,7 +18720,8 @@ function createWixToolkit(options) {
18713
18720
  toolDescriptions,
18714
18721
  toolHints,
18715
18722
  maxResponseSize,
18716
- codeModeBaseUrl = "https://mcp.wix.com"
18723
+ codeModeBaseUrl = "https://mcp.wix.com",
18724
+ codeModeFetch
18717
18725
  } = api;
18718
18726
  const effectiveToolDescriptions = {
18719
18727
  ...descriptionsWithoutReadme,
@@ -18737,6 +18745,7 @@ function createWixToolkit(options) {
18737
18745
  if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
18738
18746
  addSearchCodeModeTool(server, {
18739
18747
  codeModeBaseUrl,
18748
+ codeModeFetch,
18740
18749
  authStrategy,
18741
18750
  disableTools,
18742
18751
  toolDescriptions: effectiveToolDescriptions,
@@ -18746,6 +18755,7 @@ function createWixToolkit(options) {
18746
18755
  if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
18747
18756
  addExecuteCodeModeTool(server, {
18748
18757
  codeModeBaseUrl,
18758
+ codeModeFetch,
18749
18759
  authStrategy,
18750
18760
  disableTools,
18751
18761
  toolDescriptions: effectiveToolDescriptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/mcp",
3
- "version": "1.0.84",
3
+ "version": "1.0.85",
4
4
  "description": "A Model Context Protocol server for Wix AI tools",
5
5
  "bin": "./build/bin-standalone.js",
6
6
  "dependencies": {
@@ -133,5 +133,5 @@
133
133
  ]
134
134
  }
135
135
  },
136
- "falconPackageHash": "c391c0fba13ea30921f1c007a71a652bd532ba1f063ebed6c8c35627"
136
+ "falconPackageHash": "fa4f66edf0696bfeabc3430c4fc334d1b036704c758c5d5c65aa2b60"
137
137
  }