@wix/mcp 1.0.84 → 1.0.86
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/build/bin-standalone.js +61 -8
- package/build/cjs/index.cjs +88 -19
- package/build/cjs/toolkit.cjs +75 -15
- package/build/dts/code-mode/index.d.ts +7 -0
- package/build/dts/code-mode/index.js +14 -10
- package/build/dts/docs/docs.js +5 -3
- package/build/dts/index.d.ts +1 -1
- package/build/dts/infra/tool-bi.d.ts +5 -1
- package/build/dts/infra/tool-bi.js +22 -1
- package/build/dts/toolkit-entry.d.cts +13 -1
- package/build/dts/toolkit-entry.d.ts +13 -1
- package/build/dts/toolkit.d.ts +3 -0
- package/build/dts/toolkit.js +4 -2
- package/build/dts/wix-mcp-server.js +3 -0
- package/build/esm/index.js +88 -19
- package/build/esm/toolkit.js +75 -15
- package/package.json +3 -3
package/build/bin-standalone.js
CHANGED
|
@@ -72663,6 +72663,22 @@ function renderApps(apps, knownApps) {
|
|
|
72663
72663
|
}
|
|
72664
72664
|
return lines.join("\n");
|
|
72665
72665
|
}
|
|
72666
|
+
function sanitizeCustomAppName(raw) {
|
|
72667
|
+
return raw.replace(/[\x00-\x1f\x7f]/g, " ").replace(/[`*_[\]|<>]/g, "").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
72668
|
+
}
|
|
72669
|
+
function renderCustomAppsWithSkillsTools(apps) {
|
|
72670
|
+
const relevant = apps.filter((a2) => a2.appId && (a2.hasSkills || a2.hasTools)).sort(
|
|
72671
|
+
(a2, b) => (a2.appName ?? a2.appId ?? "").localeCompare(b.appName ?? b.appId ?? "")
|
|
72672
|
+
);
|
|
72673
|
+
if (!relevant.length) return "";
|
|
72674
|
+
const lines = [];
|
|
72675
|
+
for (const app of relevant) {
|
|
72676
|
+
const sanitizedName = app.appName ? sanitizeCustomAppName(app.appName) : "";
|
|
72677
|
+
const name = sanitizedName || app.appId;
|
|
72678
|
+
lines.push(`- \`${name}\` (ID: \`${app.appId}\`)`);
|
|
72679
|
+
}
|
|
72680
|
+
return lines.join("\n");
|
|
72681
|
+
}
|
|
72666
72682
|
function renderProperties(props) {
|
|
72667
72683
|
const sections = [];
|
|
72668
72684
|
const regionalFormat = [];
|
|
@@ -72725,6 +72741,15 @@ function renderSite(site, index, knownApps) {
|
|
|
72725
72741
|
lines.push("");
|
|
72726
72742
|
lines.push(appsContent);
|
|
72727
72743
|
}
|
|
72744
|
+
const customAppsWithSkillsToolsContent = renderCustomAppsWithSkillsTools(
|
|
72745
|
+
site.customApps ?? []
|
|
72746
|
+
);
|
|
72747
|
+
if (customAppsWithSkillsToolsContent) {
|
|
72748
|
+
lines.push("");
|
|
72749
|
+
lines.push("### Custom Apps with skills and tools");
|
|
72750
|
+
lines.push("");
|
|
72751
|
+
lines.push(customAppsWithSkillsToolsContent);
|
|
72752
|
+
}
|
|
72728
72753
|
lines.push("");
|
|
72729
72754
|
lines.push("---");
|
|
72730
72755
|
lines.push("");
|
|
@@ -73527,7 +73552,9 @@ function getErrorMessage(error2) {
|
|
|
73527
73552
|
}
|
|
73528
73553
|
function shouldTryMenuFallbackForDocsRead(error2, articleUrl) {
|
|
73529
73554
|
const message = getErrorMessage(error2);
|
|
73530
|
-
|
|
73555
|
+
const { pathname } = new URL(articleUrl);
|
|
73556
|
+
const isMenuFallbackUrl = articleUrl.includes("/api-reference/") || pathname.startsWith("/docs/velo");
|
|
73557
|
+
if (!message.includes("404") || !isMenuFallbackUrl) {
|
|
73531
73558
|
return false;
|
|
73532
73559
|
}
|
|
73533
73560
|
return !["This resource is deprecated", "No schema found"].some(
|
|
@@ -74180,7 +74207,7 @@ var addDocsTools = (server2, allowedTools = [
|
|
|
74180
74207
|
content: [
|
|
74181
74208
|
{
|
|
74182
74209
|
type: "text",
|
|
74183
|
-
text: `Note: "${articleUrl}" is
|
|
74210
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
74184
74211
|
|
|
74185
74212
|
${text}`
|
|
74186
74213
|
}
|
|
@@ -74272,7 +74299,7 @@ ${text}`
|
|
|
74272
74299
|
content: [
|
|
74273
74300
|
{
|
|
74274
74301
|
type: "text",
|
|
74275
|
-
text: `Note: "${articleUrl}" is
|
|
74302
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
74276
74303
|
|
|
74277
74304
|
${text}`
|
|
74278
74305
|
}
|
|
@@ -85350,7 +85377,25 @@ function extractText(result) {
|
|
|
85350
85377
|
return result.content.filter((content) => content.type === "text" && content.text != null).map((content) => content.text).join("\n");
|
|
85351
85378
|
}
|
|
85352
85379
|
var TOOL_RESULT_PREVIEW_MAX_CHARS = 4e3;
|
|
85353
|
-
|
|
85380
|
+
var CODEX_OUTPUT_BUDGET_BYTES = 4e4;
|
|
85381
|
+
function getCodexTruncation(resultText, client) {
|
|
85382
|
+
const isCodex = [client?.name, client?.userAgent].some(
|
|
85383
|
+
(identity3) => identity3?.toLowerCase().includes("codex")
|
|
85384
|
+
);
|
|
85385
|
+
if (!isCodex) {
|
|
85386
|
+
return void 0;
|
|
85387
|
+
}
|
|
85388
|
+
const resultBytes = new TextEncoder().encode(resultText).length;
|
|
85389
|
+
if (resultBytes <= CODEX_OUTPUT_BUDGET_BYTES) {
|
|
85390
|
+
return void 0;
|
|
85391
|
+
}
|
|
85392
|
+
return {
|
|
85393
|
+
resultBytes,
|
|
85394
|
+
budgetBytes: CODEX_OUTPUT_BUDGET_BYTES,
|
|
85395
|
+
truncatedBytes: resultBytes - CODEX_OUTPUT_BUDGET_BYTES
|
|
85396
|
+
};
|
|
85397
|
+
}
|
|
85398
|
+
function formatToolResultAdditionalFields(result, extras, client) {
|
|
85354
85399
|
const resultText = extractText(result);
|
|
85355
85400
|
const contentTypes = [
|
|
85356
85401
|
...new Set(
|
|
@@ -85367,6 +85412,7 @@ function formatToolResultAdditionalFields(result, extras) {
|
|
|
85367
85412
|
resultTextLength: resultText.length,
|
|
85368
85413
|
resultPreviewTruncated: resultText.length > TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
85369
85414
|
resultContentTypes: contentTypes,
|
|
85415
|
+
codexTruncation: getCodexTruncation(resultText, client),
|
|
85370
85416
|
...extras
|
|
85371
85417
|
});
|
|
85372
85418
|
}
|
|
@@ -85545,10 +85591,17 @@ var WixMcpServer = class extends McpServer {
|
|
|
85545
85591
|
if (!toolSucceeded) {
|
|
85546
85592
|
errorBody = extractText(cbResult);
|
|
85547
85593
|
} else {
|
|
85548
|
-
additionalFields = formatToolResultAdditionalFields(
|
|
85549
|
-
|
|
85550
|
-
|
|
85551
|
-
|
|
85594
|
+
additionalFields = formatToolResultAdditionalFields(
|
|
85595
|
+
cbResult,
|
|
85596
|
+
{
|
|
85597
|
+
returnedRows: toolBiParams.returnedRows,
|
|
85598
|
+
originalLength: toolBiParams.originalLength
|
|
85599
|
+
},
|
|
85600
|
+
{
|
|
85601
|
+
name: this.getClientName?.() || this.server.getClientVersion()?.name,
|
|
85602
|
+
userAgent: this.getUserAgent?.()
|
|
85603
|
+
}
|
|
85604
|
+
);
|
|
85552
85605
|
}
|
|
85553
85606
|
if (toolSucceeded && !isDevEnvironment) {
|
|
85554
85607
|
panorama.transaction(toolName).finish({ toolInvocationId });
|
package/build/cjs/index.cjs
CHANGED
|
@@ -36024,7 +36024,25 @@ function extractText(result) {
|
|
|
36024
36024
|
return result.content.filter((content) => content.type === "text" && content.text != null).map((content) => content.text).join("\n");
|
|
36025
36025
|
}
|
|
36026
36026
|
var TOOL_RESULT_PREVIEW_MAX_CHARS = 4e3;
|
|
36027
|
-
|
|
36027
|
+
var CODEX_OUTPUT_BUDGET_BYTES = 4e4;
|
|
36028
|
+
function getCodexTruncation(resultText, client) {
|
|
36029
|
+
const isCodex = [client?.name, client?.userAgent].some(
|
|
36030
|
+
(identity) => identity?.toLowerCase().includes("codex")
|
|
36031
|
+
);
|
|
36032
|
+
if (!isCodex) {
|
|
36033
|
+
return void 0;
|
|
36034
|
+
}
|
|
36035
|
+
const resultBytes = new TextEncoder().encode(resultText).length;
|
|
36036
|
+
if (resultBytes <= CODEX_OUTPUT_BUDGET_BYTES) {
|
|
36037
|
+
return void 0;
|
|
36038
|
+
}
|
|
36039
|
+
return {
|
|
36040
|
+
resultBytes,
|
|
36041
|
+
budgetBytes: CODEX_OUTPUT_BUDGET_BYTES,
|
|
36042
|
+
truncatedBytes: resultBytes - CODEX_OUTPUT_BUDGET_BYTES
|
|
36043
|
+
};
|
|
36044
|
+
}
|
|
36045
|
+
function formatToolResultAdditionalFields(result, extras, client) {
|
|
36028
36046
|
const resultText = extractText(result);
|
|
36029
36047
|
const contentTypes = [
|
|
36030
36048
|
...new Set(
|
|
@@ -36041,6 +36059,7 @@ function formatToolResultAdditionalFields(result, extras) {
|
|
|
36041
36059
|
resultTextLength: resultText.length,
|
|
36042
36060
|
resultPreviewTruncated: resultText.length > TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
36043
36061
|
resultContentTypes: contentTypes,
|
|
36062
|
+
codexTruncation: getCodexTruncation(resultText, client),
|
|
36044
36063
|
...extras
|
|
36045
36064
|
});
|
|
36046
36065
|
}
|
|
@@ -36222,10 +36241,17 @@ var WixMcpServer = class extends McpServer {
|
|
|
36222
36241
|
if (!toolSucceeded) {
|
|
36223
36242
|
errorBody = extractText(cbResult);
|
|
36224
36243
|
} else {
|
|
36225
|
-
additionalFields = formatToolResultAdditionalFields(
|
|
36226
|
-
|
|
36227
|
-
|
|
36228
|
-
|
|
36244
|
+
additionalFields = formatToolResultAdditionalFields(
|
|
36245
|
+
cbResult,
|
|
36246
|
+
{
|
|
36247
|
+
returnedRows: toolBiParams.returnedRows,
|
|
36248
|
+
originalLength: toolBiParams.originalLength
|
|
36249
|
+
},
|
|
36250
|
+
{
|
|
36251
|
+
name: this.getClientName?.() || this.server.getClientVersion()?.name,
|
|
36252
|
+
userAgent: this.getUserAgent?.()
|
|
36253
|
+
}
|
|
36254
|
+
);
|
|
36229
36255
|
}
|
|
36230
36256
|
if (toolSucceeded && !isDevEnvironment) {
|
|
36231
36257
|
panorama.transaction(toolName).finish({ toolInvocationId });
|
|
@@ -38283,6 +38309,22 @@ function renderApps(apps, knownApps) {
|
|
|
38283
38309
|
}
|
|
38284
38310
|
return lines.join("\n");
|
|
38285
38311
|
}
|
|
38312
|
+
function sanitizeCustomAppName(raw) {
|
|
38313
|
+
return raw.replace(/[\x00-\x1f\x7f]/g, " ").replace(/[`*_[\]|<>]/g, "").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
38314
|
+
}
|
|
38315
|
+
function renderCustomAppsWithSkillsTools(apps) {
|
|
38316
|
+
const relevant = apps.filter((a2) => a2.appId && (a2.hasSkills || a2.hasTools)).sort(
|
|
38317
|
+
(a2, b2) => (a2.appName ?? a2.appId ?? "").localeCompare(b2.appName ?? b2.appId ?? "")
|
|
38318
|
+
);
|
|
38319
|
+
if (!relevant.length) return "";
|
|
38320
|
+
const lines = [];
|
|
38321
|
+
for (const app of relevant) {
|
|
38322
|
+
const sanitizedName = app.appName ? sanitizeCustomAppName(app.appName) : "";
|
|
38323
|
+
const name = sanitizedName || app.appId;
|
|
38324
|
+
lines.push(`- \`${name}\` (ID: \`${app.appId}\`)`);
|
|
38325
|
+
}
|
|
38326
|
+
return lines.join("\n");
|
|
38327
|
+
}
|
|
38286
38328
|
function renderProperties(props) {
|
|
38287
38329
|
const sections = [];
|
|
38288
38330
|
const regionalFormat = [];
|
|
@@ -38345,6 +38387,15 @@ function renderSite(site, index, knownApps) {
|
|
|
38345
38387
|
lines.push("");
|
|
38346
38388
|
lines.push(appsContent);
|
|
38347
38389
|
}
|
|
38390
|
+
const customAppsWithSkillsToolsContent = renderCustomAppsWithSkillsTools(
|
|
38391
|
+
site.customApps ?? []
|
|
38392
|
+
);
|
|
38393
|
+
if (customAppsWithSkillsToolsContent) {
|
|
38394
|
+
lines.push("");
|
|
38395
|
+
lines.push("### Custom Apps with skills and tools");
|
|
38396
|
+
lines.push("");
|
|
38397
|
+
lines.push(customAppsWithSkillsToolsContent);
|
|
38398
|
+
}
|
|
38348
38399
|
lines.push("");
|
|
38349
38400
|
lines.push("---");
|
|
38350
38401
|
lines.push("");
|
|
@@ -39147,7 +39198,9 @@ function getErrorMessage(error2) {
|
|
|
39147
39198
|
}
|
|
39148
39199
|
function shouldTryMenuFallbackForDocsRead(error2, articleUrl) {
|
|
39149
39200
|
const message = getErrorMessage(error2);
|
|
39150
|
-
|
|
39201
|
+
const { pathname } = new URL(articleUrl);
|
|
39202
|
+
const isMenuFallbackUrl = articleUrl.includes("/api-reference/") || pathname.startsWith("/docs/velo");
|
|
39203
|
+
if (!message.includes("404") || !isMenuFallbackUrl) {
|
|
39151
39204
|
return false;
|
|
39152
39205
|
}
|
|
39153
39206
|
return !["This resource is deprecated", "No schema found"].some(
|
|
@@ -39800,7 +39853,7 @@ var addDocsTools = (server, allowedTools = [
|
|
|
39800
39853
|
content: [
|
|
39801
39854
|
{
|
|
39802
39855
|
type: "text",
|
|
39803
|
-
text: `Note: "${articleUrl}" is
|
|
39856
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
39804
39857
|
|
|
39805
39858
|
${text}`
|
|
39806
39859
|
}
|
|
@@ -39892,7 +39945,7 @@ ${text}`
|
|
|
39892
39945
|
content: [
|
|
39893
39946
|
{
|
|
39894
39947
|
type: "text",
|
|
39895
|
-
text: `Note: "${articleUrl}" is
|
|
39948
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
39896
39949
|
|
|
39897
39950
|
${text}`
|
|
39898
39951
|
}
|
|
@@ -52838,11 +52891,13 @@ function validateExecuteCode(code) {
|
|
|
52838
52891
|
}
|
|
52839
52892
|
|
|
52840
52893
|
// src/code-mode/index.ts
|
|
52894
|
+
var defaultCodeModeFetch = (url, init) => fetch(url, init);
|
|
52841
52895
|
var SEARCH_TOOL_NAME = "SearchWixAPISpec";
|
|
52842
52896
|
var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
|
|
52843
52897
|
async function addCodeModeTools(server, options) {
|
|
52844
52898
|
const {
|
|
52845
52899
|
codeModeBaseUrl,
|
|
52900
|
+
codeModeFetch,
|
|
52846
52901
|
authStrategy,
|
|
52847
52902
|
disableTools = [],
|
|
52848
52903
|
toolDescriptions,
|
|
@@ -52852,6 +52907,7 @@ async function addCodeModeTools(server, options) {
|
|
|
52852
52907
|
if (!disableTools.includes(EXECUTE_TOOL_NAME) && authStrategy) {
|
|
52853
52908
|
addExecuteCodeModeTool(server, {
|
|
52854
52909
|
codeModeBaseUrl,
|
|
52910
|
+
codeModeFetch,
|
|
52855
52911
|
authStrategy,
|
|
52856
52912
|
disableTools,
|
|
52857
52913
|
toolDescriptions,
|
|
@@ -52862,6 +52918,7 @@ async function addCodeModeTools(server, options) {
|
|
|
52862
52918
|
function addSearchCodeModeTool(server, options) {
|
|
52863
52919
|
const {
|
|
52864
52920
|
codeModeBaseUrl,
|
|
52921
|
+
codeModeFetch,
|
|
52865
52922
|
authStrategy,
|
|
52866
52923
|
disableTools = [],
|
|
52867
52924
|
toolDescriptions,
|
|
@@ -52876,12 +52933,14 @@ function addSearchCodeModeTool(server, options) {
|
|
|
52876
52933
|
codeModeBaseUrl,
|
|
52877
52934
|
description,
|
|
52878
52935
|
maxResponseSize,
|
|
52879
|
-
authStrategy
|
|
52936
|
+
authStrategy,
|
|
52937
|
+
codeModeFetch
|
|
52880
52938
|
);
|
|
52881
52939
|
}
|
|
52882
52940
|
function addExecuteCodeModeTool(server, options) {
|
|
52883
52941
|
const {
|
|
52884
52942
|
codeModeBaseUrl,
|
|
52943
|
+
codeModeFetch,
|
|
52885
52944
|
authStrategy,
|
|
52886
52945
|
visitor,
|
|
52887
52946
|
disableTools = [],
|
|
@@ -52893,6 +52952,7 @@ function addExecuteCodeModeTool(server, options) {
|
|
|
52893
52952
|
}
|
|
52894
52953
|
addExecuteTool(server, {
|
|
52895
52954
|
codeModeBaseUrl,
|
|
52955
|
+
codeModeFetch,
|
|
52896
52956
|
authStrategy,
|
|
52897
52957
|
visitor,
|
|
52898
52958
|
toolDescriptions,
|
|
@@ -52907,7 +52967,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
|
|
|
52907
52967
|
return void 0;
|
|
52908
52968
|
}
|
|
52909
52969
|
}
|
|
52910
|
-
function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
|
|
52970
|
+
function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
|
|
52911
52971
|
const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
|
|
52912
52972
|
server.tool(
|
|
52913
52973
|
SEARCH_TOOL_NAME,
|
|
@@ -52927,7 +52987,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
|
|
|
52927
52987
|
);
|
|
52928
52988
|
try {
|
|
52929
52989
|
const authorization = await resolveLoopbackAuthorization(authStrategy);
|
|
52930
|
-
const resp = await
|
|
52990
|
+
const resp = await codeModeFetch(searchUrl, {
|
|
52931
52991
|
method: "POST",
|
|
52932
52992
|
headers: {
|
|
52933
52993
|
"Content-Type": "application/json",
|
|
@@ -52978,8 +53038,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
|
|
|
52978
53038
|
}
|
|
52979
53039
|
);
|
|
52980
53040
|
}
|
|
52981
|
-
async function postExecute(executeUrl, body, authorization) {
|
|
52982
|
-
const resp = await
|
|
53041
|
+
async function postExecute(executeUrl, body, authorization, codeModeFetch = defaultCodeModeFetch) {
|
|
53042
|
+
const resp = await codeModeFetch(executeUrl, {
|
|
52983
53043
|
method: "POST",
|
|
52984
53044
|
headers: {
|
|
52985
53045
|
"Content-Type": "application/json",
|
|
@@ -53021,6 +53081,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
|
|
|
53021
53081
|
function addExecuteTool(server, options) {
|
|
53022
53082
|
const {
|
|
53023
53083
|
codeModeBaseUrl,
|
|
53084
|
+
codeModeFetch,
|
|
53024
53085
|
authStrategy,
|
|
53025
53086
|
visitor,
|
|
53026
53087
|
toolDescriptions,
|
|
@@ -53109,7 +53170,8 @@ function addExecuteTool(server, options) {
|
|
|
53109
53170
|
accountId: accountHeaders?.["wix-account-id"],
|
|
53110
53171
|
siteAuthContext
|
|
53111
53172
|
},
|
|
53112
|
-
visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
|
|
53173
|
+
visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
|
|
53174
|
+
codeModeFetch
|
|
53113
53175
|
);
|
|
53114
53176
|
if (data.authErrorStatus && visitor) {
|
|
53115
53177
|
return executeErrorResult(
|
|
@@ -53269,7 +53331,8 @@ function createWixToolkit(options) {
|
|
|
53269
53331
|
toolDescriptions,
|
|
53270
53332
|
toolHints,
|
|
53271
53333
|
maxResponseSize,
|
|
53272
|
-
codeModeBaseUrl = "https://mcp.wix.com"
|
|
53334
|
+
codeModeBaseUrl = "https://mcp.wix.com",
|
|
53335
|
+
codeModeFetch
|
|
53273
53336
|
} = api;
|
|
53274
53337
|
const effectiveToolDescriptions = {
|
|
53275
53338
|
...descriptionsWithoutReadme,
|
|
@@ -53293,6 +53356,7 @@ function createWixToolkit(options) {
|
|
|
53293
53356
|
if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
|
|
53294
53357
|
addSearchCodeModeTool(server, {
|
|
53295
53358
|
codeModeBaseUrl,
|
|
53359
|
+
codeModeFetch,
|
|
53296
53360
|
authStrategy,
|
|
53297
53361
|
disableTools,
|
|
53298
53362
|
toolDescriptions: effectiveToolDescriptions,
|
|
@@ -53302,6 +53366,7 @@ function createWixToolkit(options) {
|
|
|
53302
53366
|
if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
|
|
53303
53367
|
addExecuteCodeModeTool(server, {
|
|
53304
53368
|
codeModeBaseUrl,
|
|
53369
|
+
codeModeFetch,
|
|
53305
53370
|
authStrategy,
|
|
53306
53371
|
disableTools,
|
|
53307
53372
|
toolDescriptions: effectiveToolDescriptions,
|
|
@@ -53384,10 +53449,14 @@ function createWixToolkit(options) {
|
|
|
53384
53449
|
if (!toolSucceeded) {
|
|
53385
53450
|
errorBody = extractText(cbResult);
|
|
53386
53451
|
} else {
|
|
53387
|
-
additionalFields = formatToolResultAdditionalFields(
|
|
53388
|
-
|
|
53389
|
-
|
|
53390
|
-
|
|
53452
|
+
additionalFields = formatToolResultAdditionalFields(
|
|
53453
|
+
cbResult,
|
|
53454
|
+
{
|
|
53455
|
+
returnedRows: toolBiParams.returnedRows,
|
|
53456
|
+
originalLength: toolBiParams.originalLength
|
|
53457
|
+
},
|
|
53458
|
+
{ name: clientName }
|
|
53459
|
+
);
|
|
53391
53460
|
}
|
|
53392
53461
|
if (!isDevEnvironment) {
|
|
53393
53462
|
if (toolSucceeded) {
|
package/build/cjs/toolkit.cjs
CHANGED
|
@@ -18804,6 +18804,22 @@ function renderApps(apps, knownApps) {
|
|
|
18804
18804
|
}
|
|
18805
18805
|
return lines.join("\n");
|
|
18806
18806
|
}
|
|
18807
|
+
function sanitizeCustomAppName(raw) {
|
|
18808
|
+
return raw.replace(/[\x00-\x1f\x7f]/g, " ").replace(/[`*_[\]|<>]/g, "").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
18809
|
+
}
|
|
18810
|
+
function renderCustomAppsWithSkillsTools(apps) {
|
|
18811
|
+
const relevant = apps.filter((a) => a.appId && (a.hasSkills || a.hasTools)).sort(
|
|
18812
|
+
(a, b) => (a.appName ?? a.appId ?? "").localeCompare(b.appName ?? b.appId ?? "")
|
|
18813
|
+
);
|
|
18814
|
+
if (!relevant.length) return "";
|
|
18815
|
+
const lines = [];
|
|
18816
|
+
for (const app of relevant) {
|
|
18817
|
+
const sanitizedName = app.appName ? sanitizeCustomAppName(app.appName) : "";
|
|
18818
|
+
const name = sanitizedName || app.appId;
|
|
18819
|
+
lines.push(`- \`${name}\` (ID: \`${app.appId}\`)`);
|
|
18820
|
+
}
|
|
18821
|
+
return lines.join("\n");
|
|
18822
|
+
}
|
|
18807
18823
|
function renderProperties(props) {
|
|
18808
18824
|
const sections = [];
|
|
18809
18825
|
const regionalFormat = [];
|
|
@@ -18866,6 +18882,15 @@ function renderSite(site, index, knownApps) {
|
|
|
18866
18882
|
lines.push("");
|
|
18867
18883
|
lines.push(appsContent);
|
|
18868
18884
|
}
|
|
18885
|
+
const customAppsWithSkillsToolsContent = renderCustomAppsWithSkillsTools(
|
|
18886
|
+
site.customApps ?? []
|
|
18887
|
+
);
|
|
18888
|
+
if (customAppsWithSkillsToolsContent) {
|
|
18889
|
+
lines.push("");
|
|
18890
|
+
lines.push("### Custom Apps with skills and tools");
|
|
18891
|
+
lines.push("");
|
|
18892
|
+
lines.push(customAppsWithSkillsToolsContent);
|
|
18893
|
+
}
|
|
18869
18894
|
lines.push("");
|
|
18870
18895
|
lines.push("---");
|
|
18871
18896
|
lines.push("");
|
|
@@ -19657,7 +19682,9 @@ function getErrorMessage(error) {
|
|
|
19657
19682
|
}
|
|
19658
19683
|
function shouldTryMenuFallbackForDocsRead(error, articleUrl) {
|
|
19659
19684
|
const message = getErrorMessage(error);
|
|
19660
|
-
|
|
19685
|
+
const { pathname } = new URL(articleUrl);
|
|
19686
|
+
const isMenuFallbackUrl = articleUrl.includes("/api-reference/") || pathname.startsWith("/docs/velo");
|
|
19687
|
+
if (!message.includes("404") || !isMenuFallbackUrl) {
|
|
19661
19688
|
return false;
|
|
19662
19689
|
}
|
|
19663
19690
|
return !["This resource is deprecated", "No schema found"].some(
|
|
@@ -20310,7 +20337,7 @@ var addDocsTools = (server, allowedTools = [
|
|
|
20310
20337
|
content: [
|
|
20311
20338
|
{
|
|
20312
20339
|
type: "text",
|
|
20313
|
-
text: `Note: "${articleUrl}" is
|
|
20340
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
20314
20341
|
|
|
20315
20342
|
${text}`
|
|
20316
20343
|
}
|
|
@@ -20402,7 +20429,7 @@ ${text}`
|
|
|
20402
20429
|
content: [
|
|
20403
20430
|
{
|
|
20404
20431
|
type: "text",
|
|
20405
|
-
text: `Note: "${articleUrl}" is
|
|
20432
|
+
text: `Note: "${articleUrl}" is not an article. Showing the closest documentation menu below; read the article you need from its links. For category URLs, use BrowseWixRESTDocsMenu directly next time.
|
|
20406
20433
|
|
|
20407
20434
|
${text}`
|
|
20408
20435
|
}
|
|
@@ -22028,11 +22055,13 @@ function validateExecuteCode(code) {
|
|
|
22028
22055
|
}
|
|
22029
22056
|
|
|
22030
22057
|
// src/code-mode/index.ts
|
|
22058
|
+
var defaultCodeModeFetch = (url, init) => fetch(url, init);
|
|
22031
22059
|
var SEARCH_TOOL_NAME = "SearchWixAPISpec";
|
|
22032
22060
|
var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
|
|
22033
22061
|
function addSearchCodeModeTool(server, options) {
|
|
22034
22062
|
const {
|
|
22035
22063
|
codeModeBaseUrl,
|
|
22064
|
+
codeModeFetch,
|
|
22036
22065
|
authStrategy,
|
|
22037
22066
|
disableTools = [],
|
|
22038
22067
|
toolDescriptions,
|
|
@@ -22047,12 +22076,14 @@ function addSearchCodeModeTool(server, options) {
|
|
|
22047
22076
|
codeModeBaseUrl,
|
|
22048
22077
|
description,
|
|
22049
22078
|
maxResponseSize,
|
|
22050
|
-
authStrategy
|
|
22079
|
+
authStrategy,
|
|
22080
|
+
codeModeFetch
|
|
22051
22081
|
);
|
|
22052
22082
|
}
|
|
22053
22083
|
function addExecuteCodeModeTool(server, options) {
|
|
22054
22084
|
const {
|
|
22055
22085
|
codeModeBaseUrl,
|
|
22086
|
+
codeModeFetch,
|
|
22056
22087
|
authStrategy,
|
|
22057
22088
|
visitor,
|
|
22058
22089
|
disableTools = [],
|
|
@@ -22064,6 +22095,7 @@ function addExecuteCodeModeTool(server, options) {
|
|
|
22064
22095
|
}
|
|
22065
22096
|
addExecuteTool(server, {
|
|
22066
22097
|
codeModeBaseUrl,
|
|
22098
|
+
codeModeFetch,
|
|
22067
22099
|
authStrategy,
|
|
22068
22100
|
visitor,
|
|
22069
22101
|
toolDescriptions,
|
|
@@ -22078,7 +22110,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
|
|
|
22078
22110
|
return void 0;
|
|
22079
22111
|
}
|
|
22080
22112
|
}
|
|
22081
|
-
function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy) {
|
|
22113
|
+
function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
|
|
22082
22114
|
const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
|
|
22083
22115
|
server.tool(
|
|
22084
22116
|
SEARCH_TOOL_NAME,
|
|
@@ -22098,7 +22130,7 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
|
|
|
22098
22130
|
);
|
|
22099
22131
|
try {
|
|
22100
22132
|
const authorization = await resolveLoopbackAuthorization(authStrategy);
|
|
22101
|
-
const resp = await
|
|
22133
|
+
const resp = await codeModeFetch(searchUrl, {
|
|
22102
22134
|
method: "POST",
|
|
22103
22135
|
headers: {
|
|
22104
22136
|
"Content-Type": "application/json",
|
|
@@ -22149,8 +22181,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
|
|
|
22149
22181
|
}
|
|
22150
22182
|
);
|
|
22151
22183
|
}
|
|
22152
|
-
async function postExecute(executeUrl, body, authorization) {
|
|
22153
|
-
const resp = await
|
|
22184
|
+
async function postExecute(executeUrl, body, authorization, codeModeFetch = defaultCodeModeFetch) {
|
|
22185
|
+
const resp = await codeModeFetch(executeUrl, {
|
|
22154
22186
|
method: "POST",
|
|
22155
22187
|
headers: {
|
|
22156
22188
|
"Content-Type": "application/json",
|
|
@@ -22192,6 +22224,7 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
|
|
|
22192
22224
|
function addExecuteTool(server, options) {
|
|
22193
22225
|
const {
|
|
22194
22226
|
codeModeBaseUrl,
|
|
22227
|
+
codeModeFetch,
|
|
22195
22228
|
authStrategy,
|
|
22196
22229
|
visitor,
|
|
22197
22230
|
toolDescriptions,
|
|
@@ -22280,7 +22313,8 @@ function addExecuteTool(server, options) {
|
|
|
22280
22313
|
accountId: accountHeaders?.["wix-account-id"],
|
|
22281
22314
|
siteAuthContext
|
|
22282
22315
|
},
|
|
22283
|
-
visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization
|
|
22316
|
+
visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
|
|
22317
|
+
codeModeFetch
|
|
22284
22318
|
);
|
|
22285
22319
|
if (data.authErrorStatus && visitor) {
|
|
22286
22320
|
return executeErrorResult(
|
|
@@ -22388,7 +22422,25 @@ function extractText(result) {
|
|
|
22388
22422
|
return result.content.filter((content) => content.type === "text" && content.text != null).map((content) => content.text).join("\n");
|
|
22389
22423
|
}
|
|
22390
22424
|
var TOOL_RESULT_PREVIEW_MAX_CHARS = 4e3;
|
|
22391
|
-
|
|
22425
|
+
var CODEX_OUTPUT_BUDGET_BYTES = 4e4;
|
|
22426
|
+
function getCodexTruncation(resultText, client) {
|
|
22427
|
+
const isCodex = [client?.name, client?.userAgent].some(
|
|
22428
|
+
(identity) => identity?.toLowerCase().includes("codex")
|
|
22429
|
+
);
|
|
22430
|
+
if (!isCodex) {
|
|
22431
|
+
return void 0;
|
|
22432
|
+
}
|
|
22433
|
+
const resultBytes = new TextEncoder().encode(resultText).length;
|
|
22434
|
+
if (resultBytes <= CODEX_OUTPUT_BUDGET_BYTES) {
|
|
22435
|
+
return void 0;
|
|
22436
|
+
}
|
|
22437
|
+
return {
|
|
22438
|
+
resultBytes,
|
|
22439
|
+
budgetBytes: CODEX_OUTPUT_BUDGET_BYTES,
|
|
22440
|
+
truncatedBytes: resultBytes - CODEX_OUTPUT_BUDGET_BYTES
|
|
22441
|
+
};
|
|
22442
|
+
}
|
|
22443
|
+
function formatToolResultAdditionalFields(result, extras, client) {
|
|
22392
22444
|
const resultText = extractText(result);
|
|
22393
22445
|
const contentTypes = [
|
|
22394
22446
|
...new Set(
|
|
@@ -22405,6 +22457,7 @@ function formatToolResultAdditionalFields(result, extras) {
|
|
|
22405
22457
|
resultTextLength: resultText.length,
|
|
22406
22458
|
resultPreviewTruncated: resultText.length > TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
22407
22459
|
resultContentTypes: contentTypes,
|
|
22460
|
+
codexTruncation: getCodexTruncation(resultText, client),
|
|
22408
22461
|
...extras
|
|
22409
22462
|
});
|
|
22410
22463
|
}
|
|
@@ -22542,7 +22595,8 @@ function createWixToolkit(options) {
|
|
|
22542
22595
|
toolDescriptions,
|
|
22543
22596
|
toolHints,
|
|
22544
22597
|
maxResponseSize,
|
|
22545
|
-
codeModeBaseUrl = "https://mcp.wix.com"
|
|
22598
|
+
codeModeBaseUrl = "https://mcp.wix.com",
|
|
22599
|
+
codeModeFetch
|
|
22546
22600
|
} = api;
|
|
22547
22601
|
const effectiveToolDescriptions = {
|
|
22548
22602
|
...descriptionsWithoutReadme,
|
|
@@ -22566,6 +22620,7 @@ function createWixToolkit(options) {
|
|
|
22566
22620
|
if (requestedTools.has("SearchWixAPISpec") && !disableTools?.includes("SearchWixAPISpec")) {
|
|
22567
22621
|
addSearchCodeModeTool(server, {
|
|
22568
22622
|
codeModeBaseUrl,
|
|
22623
|
+
codeModeFetch,
|
|
22569
22624
|
authStrategy,
|
|
22570
22625
|
disableTools,
|
|
22571
22626
|
toolDescriptions: effectiveToolDescriptions,
|
|
@@ -22575,6 +22630,7 @@ function createWixToolkit(options) {
|
|
|
22575
22630
|
if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
|
|
22576
22631
|
addExecuteCodeModeTool(server, {
|
|
22577
22632
|
codeModeBaseUrl,
|
|
22633
|
+
codeModeFetch,
|
|
22578
22634
|
authStrategy,
|
|
22579
22635
|
disableTools,
|
|
22580
22636
|
toolDescriptions: effectiveToolDescriptions,
|
|
@@ -22657,10 +22713,14 @@ function createWixToolkit(options) {
|
|
|
22657
22713
|
if (!toolSucceeded) {
|
|
22658
22714
|
errorBody = extractText(cbResult);
|
|
22659
22715
|
} else {
|
|
22660
|
-
additionalFields = formatToolResultAdditionalFields(
|
|
22661
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22716
|
+
additionalFields = formatToolResultAdditionalFields(
|
|
22717
|
+
cbResult,
|
|
22718
|
+
{
|
|
22719
|
+
returnedRows: toolBiParams.returnedRows,
|
|
22720
|
+
originalLength: toolBiParams.originalLength
|
|
22721
|
+
},
|
|
22722
|
+
{ name: clientName }
|
|
22723
|
+
);
|
|
22664
22724
|
}
|
|
22665
22725
|
if (!isDevEnvironment) {
|
|
22666
22726
|
if (toolSucceeded) {
|
|
@@ -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
|