@wix/mcp 1.0.29 → 1.0.30
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/README.md +1 -0
- package/build/bin-standalone.js +209 -2
- package/build/bin-standalone.js.map +2 -2
- package/build/cjs/index.cjs +383 -13
- package/build/cjs/index.cjs.map +4 -4
- package/build/dts/bin.d.ts +1 -1
- package/build/dts/bin.d.ts.map +1 -1
- package/build/dts/code-mode/index.d.ts +10 -0
- package/build/dts/code-mode/index.d.ts.map +1 -0
- package/build/dts/code-mode/index.js +150 -0
- package/build/dts/code-mode/index.js.map +1 -0
- package/build/dts/config/default-config.d.ts +1 -0
- package/build/dts/config/default-config.d.ts.map +1 -1
- package/build/dts/config/default-config.js +144 -1
- package/build/dts/config/default-config.js.map +1 -1
- package/build/dts/config/param-descriptions.d.ts +5 -0
- package/build/dts/config/param-descriptions.d.ts.map +1 -1
- package/build/dts/config/param-descriptions.js +5 -0
- package/build/dts/config/param-descriptions.js.map +1 -1
- package/build/dts/docs/docs.d.ts +1 -1
- package/build/dts/docs/docs.d.ts.map +1 -1
- package/build/dts/docs/docs.js +56 -2
- package/build/dts/docs/docs.js.map +1 -1
- package/build/dts/docs/semanticSearch.d.ts.map +1 -1
- package/build/dts/docs/semanticSearch.js +3 -0
- package/build/dts/docs/semanticSearch.js.map +1 -1
- package/build/dts/docs/semanticSearch.test.js +33 -0
- package/build/dts/docs/semanticSearch.test.js.map +1 -1
- package/build/dts/index.d.ts +1 -0
- package/build/dts/index.d.ts.map +1 -1
- package/build/dts/index.js +2 -0
- package/build/dts/index.js.map +1 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.d.ts +0 -7
- package/build/dts/site-widget-tools/site-builder-tool/index.d.ts.map +1 -1
- package/build/dts/site-widget-tools/site-builder-tool/index.js +6 -10
- package/build/dts/site-widget-tools/site-builder-tool/index.js.map +1 -1
- package/build/esm/index.js +382 -13
- package/build/esm/index.js.map +4 -4
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -28720,6 +28720,8 @@ var runSemanticSearch = async (toolName, toolParams, maxResults = 20, rerank = f
|
|
|
28720
28720
|
kbNames.push("HEADLESS_KB_ID");
|
|
28721
28721
|
} else if (toolName === "VELO") {
|
|
28722
28722
|
kbNames.push("VELO_DOCS_KB_ID", "VELO_METHODS_KB_ID");
|
|
28723
|
+
} else if (toolName === "CLI") {
|
|
28724
|
+
kbNames.push("CLI_KB_ID");
|
|
28723
28725
|
}
|
|
28724
28726
|
logger2.log(
|
|
28725
28727
|
`[SemanticSearch] Tool: ${toolName}, KBs: [${kbNames.join(", ")}], Query: "${toolParams.searchTerm}"`
|
|
@@ -29313,6 +29315,148 @@ var defaultToolDescriptions = {
|
|
|
29313
29315
|
`,
|
|
29314
29316
|
VeloREADME: dedent_default`
|
|
29315
29317
|
This tool is set for providing Velo context in order to be used by the agent for executing Velo-related tasks.
|
|
29318
|
+
`,
|
|
29319
|
+
SearchWixCLIDocumentation: dedent_default`
|
|
29320
|
+
Searches the Wix CLI documentation for website development and CLI commands.
|
|
29321
|
+
Use this tool when you need information about Wix CLI commands, local development workflows, or CLI-based website development.
|
|
29322
|
+
Specify what you need information about (e.g., 'wix dev command', 'local development setup', 'CLI authentication', 'wix deploy').
|
|
29323
|
+
If you can't find what you need, try to rephrase your search term or use bigger maxResults value.
|
|
29324
|
+
${SYSTEM_REMINDER}
|
|
29325
|
+
`,
|
|
29326
|
+
SearchWixAPISpec: dedent_default`
|
|
29327
|
+
Search the Wix REST API documentation by writing JavaScript code that runs in a sandboxed environment.
|
|
29328
|
+
Your code has access to two globals:
|
|
29329
|
+
|
|
29330
|
+
**lightIndex** — Array of all Wix REST API resources (~330):
|
|
29331
|
+
\`\`\`typescript
|
|
29332
|
+
interface LightResource {
|
|
29333
|
+
name: string; // e.g. "Products V3", "Contact V4"
|
|
29334
|
+
resourceId: string;
|
|
29335
|
+
menuPath: string[]; // e.g. ["business-solutions", "stores", "catalog-v3", "products-v3"]
|
|
29336
|
+
methods: Array<{
|
|
29337
|
+
operationId: string; // e.g. "wix.stores.catalog.v3.CatalogApi.CreateProduct"
|
|
29338
|
+
summary: string; // e.g. "Create Product"
|
|
29339
|
+
httpMethod: string; // "get" | "post" | "patch" | "delete"
|
|
29340
|
+
path: string; // e.g. "/v3/products"
|
|
29341
|
+
description: string; // truncated to 200 chars
|
|
29342
|
+
}>;
|
|
29343
|
+
}
|
|
29344
|
+
\`\`\`
|
|
29345
|
+
|
|
29346
|
+
**getResourceSchema(resourceId)** — Async function returning the full schema for a resource:
|
|
29347
|
+
\`\`\`typescript
|
|
29348
|
+
interface FullSchema {
|
|
29349
|
+
title: string;
|
|
29350
|
+
description: string;
|
|
29351
|
+
fqdn: string;
|
|
29352
|
+
methods: Array<{
|
|
29353
|
+
summary: string;
|
|
29354
|
+
description: string;
|
|
29355
|
+
operationId: string;
|
|
29356
|
+
httpMethod: string;
|
|
29357
|
+
path: string;
|
|
29358
|
+
servers: Array<{ url: string }>; // Base URLs (e.g. "https://www.wixapis.com/...")
|
|
29359
|
+
requestBody: object | null;
|
|
29360
|
+
responses: object;
|
|
29361
|
+
parameters: Array<object>;
|
|
29362
|
+
permissions: string[];
|
|
29363
|
+
legacyExamples: Array<{ // Curl examples
|
|
29364
|
+
content: { title: string; request: string; response: string };
|
|
29365
|
+
}>;
|
|
29366
|
+
sdkData: { // JS SDK examples
|
|
29367
|
+
packageName: string;
|
|
29368
|
+
namespace: string;
|
|
29369
|
+
methodExamples: Array<{ title: string; content: string }>;
|
|
29370
|
+
};
|
|
29371
|
+
}>;
|
|
29372
|
+
components: { schemas: object };
|
|
29373
|
+
}
|
|
29374
|
+
\`\`\`
|
|
29375
|
+
|
|
29376
|
+
Your code MUST be an \`async function()\` expression that returns a value.
|
|
29377
|
+
|
|
29378
|
+
Top-level verticals: business-solutions (stores, e-commerce, bookings, events, restaurants, pricing-plans, coupons), crm (contacts, members, loyalty-program, forms, community), business-management (payments, invoices, automations), assets (media, files), app-management (oauth, billing), account-level, site.
|
|
29379
|
+
|
|
29380
|
+
Examples:
|
|
29381
|
+
|
|
29382
|
+
Find APIs by keyword:
|
|
29383
|
+
\`\`\`javascript
|
|
29384
|
+
async function() {
|
|
29385
|
+
return lightIndex.filter(r => r.methods.some(m => m.summary.toLowerCase().includes("query products")))
|
|
29386
|
+
.map(r => ({ name: r.name, methods: r.methods.map(m => m.summary + " (" + m.httpMethod.toUpperCase() + " " + m.path + ")") }));
|
|
29387
|
+
}
|
|
29388
|
+
\`\`\`
|
|
29389
|
+
|
|
29390
|
+
Get full schema with base URL, curl examples, and permissions:
|
|
29391
|
+
\`\`\`javascript
|
|
29392
|
+
async function() {
|
|
29393
|
+
const resource = lightIndex.find(r => r.name === "Contact V4");
|
|
29394
|
+
const schema = await getResourceSchema(resource.resourceId);
|
|
29395
|
+
const method = schema.methods.find(m => m.summary === "Query Contacts");
|
|
29396
|
+
return {
|
|
29397
|
+
baseUrl: method.servers?.find(s => s.url.includes("wixapis.com"))?.url,
|
|
29398
|
+
path: method.path,
|
|
29399
|
+
httpMethod: method.httpMethod,
|
|
29400
|
+
permissions: method.permissions,
|
|
29401
|
+
requestBody: method.requestBody,
|
|
29402
|
+
curlExample: method.legacyExamples?.[0]?.content,
|
|
29403
|
+
sdkExample: method.sdkData?.methodExamples?.[0]?.content
|
|
29404
|
+
};
|
|
29405
|
+
}
|
|
29406
|
+
\`\`\`
|
|
29407
|
+
|
|
29408
|
+
Browse a vertical:
|
|
29409
|
+
\`\`\`javascript
|
|
29410
|
+
async function() {
|
|
29411
|
+
return lightIndex.filter(r => r.menuPath[0] === "crm")
|
|
29412
|
+
.map(r => ({ name: r.name, path: r.menuPath.join(" > "), methods: r.methods.length }));
|
|
29413
|
+
}
|
|
29414
|
+
\`\`\`
|
|
29415
|
+
`,
|
|
29416
|
+
ExecuteWixAPI: dedent_default`
|
|
29417
|
+
Execute JavaScript code against the Wix REST API. First use the 'SearchWixAPISpec' tool to find the right endpoints, base URLs, and request/response schemas. Then write code using the wix.request() function. Auth is handled automatically — do not set Authorization headers.
|
|
29418
|
+
|
|
29419
|
+
Available in your code:
|
|
29420
|
+
\`\`\`typescript
|
|
29421
|
+
interface WixRequestOptions {
|
|
29422
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
29423
|
+
url: string; // Full URL from schema servers field, e.g. "https://www.wixapis.com/contacts/v4/contacts"
|
|
29424
|
+
body?: unknown;
|
|
29425
|
+
headers?: Record<string, string>; // Do NOT set Authorization — it is injected automatically
|
|
29426
|
+
}
|
|
29427
|
+
|
|
29428
|
+
interface WixResponse<T = unknown> {
|
|
29429
|
+
status: number;
|
|
29430
|
+
data: T;
|
|
29431
|
+
}
|
|
29432
|
+
|
|
29433
|
+
declare const wix: {
|
|
29434
|
+
request<T = unknown>(options: WixRequestOptions): Promise<WixResponse<T>>;
|
|
29435
|
+
};
|
|
29436
|
+
|
|
29437
|
+
declare const siteId: string | undefined;
|
|
29438
|
+
\`\`\`
|
|
29439
|
+
|
|
29440
|
+
Your code MUST be an \`async function()\` expression that returns the result.
|
|
29441
|
+
|
|
29442
|
+
Example — query products then update one:
|
|
29443
|
+
\`\`\`javascript
|
|
29444
|
+
async function() {
|
|
29445
|
+
const list = await wix.request({
|
|
29446
|
+
method: "POST",
|
|
29447
|
+
url: "https://www.wixapis.com/stores/v1/products/query",
|
|
29448
|
+
body: { query: { paging: { limit: 5 } } }
|
|
29449
|
+
});
|
|
29450
|
+
const product = list.data.products[0];
|
|
29451
|
+
if (!product) return { error: "No products found" };
|
|
29452
|
+
const updated = await wix.request({
|
|
29453
|
+
method: "PATCH",
|
|
29454
|
+
url: \`https://www.wixapis.com/stores/v1/products/\${product.id}\`,
|
|
29455
|
+
body: { product: { name: "Updated Name" } }
|
|
29456
|
+
});
|
|
29457
|
+
return updated.data;
|
|
29458
|
+
}
|
|
29459
|
+
\`\`\`
|
|
29316
29460
|
`
|
|
29317
29461
|
};
|
|
29318
29462
|
var defaultReadmeDocs = [
|
|
@@ -29396,7 +29540,8 @@ function mergeConfig(base, overrides) {
|
|
|
29396
29540
|
toolHints: { ...base.toolHints, ...overrides.toolHints },
|
|
29397
29541
|
docsTools: overrides.docsTools ?? base.docsTools,
|
|
29398
29542
|
getToKnowWixEnabled: overrides.getToKnowWixEnabled ?? base.getToKnowWixEnabled,
|
|
29399
|
-
createWixBusinessGuideEnabled: overrides.createWixBusinessGuideEnabled ?? base.createWixBusinessGuideEnabled
|
|
29543
|
+
createWixBusinessGuideEnabled: overrides.createWixBusinessGuideEnabled ?? base.createWixBusinessGuideEnabled,
|
|
29544
|
+
codeModeEnabled: overrides.codeModeEnabled ?? base.codeModeEnabled
|
|
29400
29545
|
};
|
|
29401
29546
|
}
|
|
29402
29547
|
var defaultConfig = {
|
|
@@ -29679,6 +29824,11 @@ var paramDescriptions = {
|
|
|
29679
29824
|
searchTerm: "The search term to search for in the Velo Documentation",
|
|
29680
29825
|
maxResults: "The maximum number of results to return, default is 5, max is 15"
|
|
29681
29826
|
},
|
|
29827
|
+
SearchWixCLIDocumentation: {
|
|
29828
|
+
searchTerm: "The search term to search for in the Wix CLI Documentation",
|
|
29829
|
+
maxResults: "The maximum number of results to return, default is 5, max is 15",
|
|
29830
|
+
reason: "One sentence describing the original user request and the task you are trying to accomplish with this search."
|
|
29831
|
+
},
|
|
29682
29832
|
ReadFullDocsArticle: {
|
|
29683
29833
|
articleUrl: "The URL of the docs article or method article to fetch. Should be something like https://dev.wix.com/docs/.../.../..."
|
|
29684
29834
|
},
|
|
@@ -29717,7 +29867,8 @@ var VALID_DOCS_TOOLS = [
|
|
|
29717
29867
|
"BUILD_APPS",
|
|
29718
29868
|
"WIX_HEADLESS",
|
|
29719
29869
|
"VELO",
|
|
29720
|
-
"BUSINESS_SOLUTIONS"
|
|
29870
|
+
"BUSINESS_SOLUTIONS",
|
|
29871
|
+
"CLI"
|
|
29721
29872
|
];
|
|
29722
29873
|
var addDocsTools = (server, allowedTools = [
|
|
29723
29874
|
"WDS",
|
|
@@ -29725,7 +29876,8 @@ var addDocsTools = (server, allowedTools = [
|
|
|
29725
29876
|
"SDK",
|
|
29726
29877
|
"BUILD_APPS",
|
|
29727
29878
|
"WIX_HEADLESS",
|
|
29728
|
-
"BUSINESS_SOLUTIONS"
|
|
29879
|
+
"BUSINESS_SOLUTIONS",
|
|
29880
|
+
"CLI"
|
|
29729
29881
|
], options = {}) => {
|
|
29730
29882
|
const {
|
|
29731
29883
|
getToKnowWixEnabled = false,
|
|
@@ -30134,6 +30286,62 @@ var addDocsTools = (server, allowedTools = [
|
|
|
30134
30286
|
}
|
|
30135
30287
|
);
|
|
30136
30288
|
}
|
|
30289
|
+
if (allowedTools.includes("CLI") && !disableTools?.includes("SearchWixCLIDocumentation")) {
|
|
30290
|
+
server.tool(
|
|
30291
|
+
"SearchWixCLIDocumentation",
|
|
30292
|
+
getDescription(
|
|
30293
|
+
"SearchWixCLIDocumentation",
|
|
30294
|
+
defaultToolDescriptions.SearchWixCLIDocumentation ?? ""
|
|
30295
|
+
),
|
|
30296
|
+
(() => {
|
|
30297
|
+
const d = desc("SearchWixCLIDocumentation");
|
|
30298
|
+
return {
|
|
30299
|
+
searchTerm: external_exports.string().describe(d.searchTerm),
|
|
30300
|
+
maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(10),
|
|
30301
|
+
reason: external_exports.string().describe(d.reason)
|
|
30302
|
+
};
|
|
30303
|
+
})(),
|
|
30304
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
30305
|
+
async ({ searchTerm, maxResults, reason }, { panorama }) => {
|
|
30306
|
+
try {
|
|
30307
|
+
logger2.log(
|
|
30308
|
+
`[SearchWixCLIDocumentation] searchTerm="${searchTerm}", reason="${reason}"`
|
|
30309
|
+
);
|
|
30310
|
+
const result = await runSemanticSearchAndFormat({
|
|
30311
|
+
toolName: "CLI",
|
|
30312
|
+
toolParams: {
|
|
30313
|
+
searchTerm
|
|
30314
|
+
},
|
|
30315
|
+
maxResults: Math.max(1, Math.min(maxResults ?? 5, 15)),
|
|
30316
|
+
linesInEachResult: 15
|
|
30317
|
+
});
|
|
30318
|
+
return {
|
|
30319
|
+
content: [
|
|
30320
|
+
{
|
|
30321
|
+
type: "text",
|
|
30322
|
+
text: result
|
|
30323
|
+
}
|
|
30324
|
+
]
|
|
30325
|
+
};
|
|
30326
|
+
} catch (error2) {
|
|
30327
|
+
panorama.errorMonitor().reportError(error2);
|
|
30328
|
+
captureException(error2, {
|
|
30329
|
+
tags: {
|
|
30330
|
+
componentId: "SearchWixCLIDocumentation",
|
|
30331
|
+
toolName: "SearchWixCLIDocumentation"
|
|
30332
|
+
}
|
|
30333
|
+
});
|
|
30334
|
+
logger2.error(
|
|
30335
|
+
`Error searching for ${searchTerm} in Wix CLI: ${error2}`
|
|
30336
|
+
);
|
|
30337
|
+
return {
|
|
30338
|
+
isError: true,
|
|
30339
|
+
content: [{ type: "text", text: "Error: " + error2.message }]
|
|
30340
|
+
};
|
|
30341
|
+
}
|
|
30342
|
+
}
|
|
30343
|
+
);
|
|
30344
|
+
}
|
|
30137
30345
|
if (!disableTools?.includes("ReadFullDocsArticle")) {
|
|
30138
30346
|
server.tool(
|
|
30139
30347
|
"ReadFullDocsArticle",
|
|
@@ -30981,20 +31189,18 @@ function addCreateSiteWidgetTool(server, authStrategy, options) {
|
|
|
30981
31189
|
};
|
|
30982
31190
|
}
|
|
30983
31191
|
);
|
|
30984
|
-
const isCompactPrompt = options?.compactSitePrompt ?? true;
|
|
30985
|
-
const compactSuffix = " Keep the prompt short and concise, single page site if possible, do not add pages that are not explicitly requested.";
|
|
30986
|
-
const toolDescription = `A tool that builds a site using Wix. Use this ONLY when the user explicitly asks to build/create/generate a site/website/application. The widget resource is available at ${CREATE_SITE_WIDGET_URI}.${isCompactPrompt ? compactSuffix : ""}`;
|
|
30987
|
-
const sitePromptDescription = `The prompt to build the site.${isCompactPrompt ? compactSuffix : ""} If not provided, the user will be asked to provide a prompt.`;
|
|
30988
31192
|
server.registerTool(
|
|
30989
31193
|
SITE_BUILDER_TOOL_NAME,
|
|
30990
31194
|
{
|
|
30991
31195
|
title: "Wix Site Builder",
|
|
30992
|
-
description:
|
|
31196
|
+
description: `**PRIMARY tool for creating/building/generating a Wix site or website.** This is the preferred and recommended way to create a new Wix site. Use this tool whenever the user asks to build, create, or generate a site/website/application. Do NOT use CreateWixBusinessGuide for site creation \u2014 use this tool instead.`,
|
|
30993
31197
|
inputSchema: {
|
|
30994
31198
|
jobId: external_exports.string().optional().describe(
|
|
30995
31199
|
"The job ID of the site build. If not provided, a new job will be created."
|
|
30996
31200
|
),
|
|
30997
|
-
sitePrompt: external_exports.string().describe(
|
|
31201
|
+
sitePrompt: external_exports.string().describe(
|
|
31202
|
+
`The prompt to build the site. If not provided, the user will be asked to provide a prompt.`
|
|
31203
|
+
)
|
|
30998
31204
|
},
|
|
30999
31205
|
_meta: toolMeta(),
|
|
31000
31206
|
annotations: {
|
|
@@ -31006,7 +31212,7 @@ function addCreateSiteWidgetTool(server, authStrategy, options) {
|
|
|
31006
31212
|
async (args, { setToolBiParams }) => {
|
|
31007
31213
|
console.log(
|
|
31008
31214
|
`[${SITE_BUILDER_TOOL_NAME}] \u{1F680} Start Building Your Site tool invoked!`,
|
|
31009
|
-
{ prompt: args.sitePrompt, jobId: args.jobId
|
|
31215
|
+
{ prompt: args.sitePrompt, jobId: args.jobId }
|
|
31010
31216
|
);
|
|
31011
31217
|
const accountHeaders = await getAccountAuthHeaders();
|
|
31012
31218
|
let jobId;
|
|
@@ -31089,9 +31295,7 @@ async function buildHarmonySite({
|
|
|
31089
31295
|
withScreenshots: true,
|
|
31090
31296
|
actionContext: "wix-mcp"
|
|
31091
31297
|
};
|
|
31092
|
-
console.log("[buildHarmonySite] request", {
|
|
31093
|
-
buildSiteRequest
|
|
31094
|
-
});
|
|
31298
|
+
console.log("[buildHarmonySite] request", { buildSiteRequest });
|
|
31095
31299
|
try {
|
|
31096
31300
|
const response = await httpClient.post(
|
|
31097
31301
|
"https://manage.wix.com/_api/harmony-site-builder/generate-harmony-site",
|
|
@@ -33624,6 +33828,170 @@ function createWixToolkit(options) {
|
|
|
33624
33828
|
}
|
|
33625
33829
|
};
|
|
33626
33830
|
}
|
|
33831
|
+
|
|
33832
|
+
// src/code-mode/index.ts
|
|
33833
|
+
var SEARCH_TOOL_NAME = "SearchWixAPISpec";
|
|
33834
|
+
var EXECUTE_TOOL_NAME = "ExecuteWixAPI";
|
|
33835
|
+
function addCodeModeTools(server, options) {
|
|
33836
|
+
const {
|
|
33837
|
+
codeModeBaseUrl,
|
|
33838
|
+
authStrategy,
|
|
33839
|
+
disableTools = [],
|
|
33840
|
+
toolDescriptions
|
|
33841
|
+
} = options;
|
|
33842
|
+
if (!disableTools.includes(SEARCH_TOOL_NAME)) {
|
|
33843
|
+
addSearchTool(server, codeModeBaseUrl, disableTools, toolDescriptions);
|
|
33844
|
+
}
|
|
33845
|
+
if (!disableTools.includes(EXECUTE_TOOL_NAME) && authStrategy) {
|
|
33846
|
+
addExecuteTool(
|
|
33847
|
+
server,
|
|
33848
|
+
codeModeBaseUrl,
|
|
33849
|
+
authStrategy,
|
|
33850
|
+
disableTools,
|
|
33851
|
+
toolDescriptions
|
|
33852
|
+
);
|
|
33853
|
+
}
|
|
33854
|
+
}
|
|
33855
|
+
function addSearchTool(server, codeModeBaseUrl, disableTools, toolDescriptions) {
|
|
33856
|
+
const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
|
|
33857
|
+
server.tool(
|
|
33858
|
+
SEARCH_TOOL_NAME,
|
|
33859
|
+
toolDescriptions?.[SEARCH_TOOL_NAME] ?? defaultToolDescriptions.SearchWixAPISpec,
|
|
33860
|
+
{
|
|
33861
|
+
code: external_exports.string().describe(
|
|
33862
|
+
"JavaScript async function() expression to search the Wix API index. Has access to `lightIndex` (array of resources) and `getResourceSchema(resourceId)` (returns full schema)."
|
|
33863
|
+
)
|
|
33864
|
+
},
|
|
33865
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
33866
|
+
async ({ code }) => {
|
|
33867
|
+
logger2.log(`[SearchWixAPISpec] Executing search (${code.length} chars)`);
|
|
33868
|
+
try {
|
|
33869
|
+
const resp = await fetch(searchUrl, {
|
|
33870
|
+
method: "POST",
|
|
33871
|
+
headers: { "Content-Type": "application/json" },
|
|
33872
|
+
body: JSON.stringify({ code })
|
|
33873
|
+
});
|
|
33874
|
+
if (!resp.ok) {
|
|
33875
|
+
const errorBody = await resp.text();
|
|
33876
|
+
logger2.log(`[SearchWixAPISpec] HTTP ${resp.status}: ${errorBody}`);
|
|
33877
|
+
return {
|
|
33878
|
+
content: [
|
|
33879
|
+
{
|
|
33880
|
+
type: "text",
|
|
33881
|
+
text: `Search error (${resp.status}): ${errorBody}`,
|
|
33882
|
+
isError: true
|
|
33883
|
+
}
|
|
33884
|
+
]
|
|
33885
|
+
};
|
|
33886
|
+
}
|
|
33887
|
+
const data = await resp.json();
|
|
33888
|
+
if (data.error) {
|
|
33889
|
+
return {
|
|
33890
|
+
content: [
|
|
33891
|
+
{
|
|
33892
|
+
type: "text",
|
|
33893
|
+
text: `Search error: ${data.error}`,
|
|
33894
|
+
isError: true
|
|
33895
|
+
}
|
|
33896
|
+
]
|
|
33897
|
+
};
|
|
33898
|
+
}
|
|
33899
|
+
const text = typeof data.result === "string" ? data.result : JSON.stringify(data.result, null, 2);
|
|
33900
|
+
return {
|
|
33901
|
+
content: [{ type: "text", text }]
|
|
33902
|
+
};
|
|
33903
|
+
} catch (err) {
|
|
33904
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
33905
|
+
logger2.log(`[SearchWixAPISpec] Error: ${message}`);
|
|
33906
|
+
return {
|
|
33907
|
+
content: [
|
|
33908
|
+
{ type: "text", text: `Search error: ${message}`, isError: true }
|
|
33909
|
+
]
|
|
33910
|
+
};
|
|
33911
|
+
}
|
|
33912
|
+
}
|
|
33913
|
+
);
|
|
33914
|
+
}
|
|
33915
|
+
function addExecuteTool(server, codeModeBaseUrl, authStrategy, disableTools, toolDescriptions) {
|
|
33916
|
+
const executeUrl = `${codeModeBaseUrl}/api/code-mode/execute`;
|
|
33917
|
+
server.tool(
|
|
33918
|
+
EXECUTE_TOOL_NAME,
|
|
33919
|
+
toolDescriptions?.[EXECUTE_TOOL_NAME] ?? defaultToolDescriptions.ExecuteWixAPI,
|
|
33920
|
+
{
|
|
33921
|
+
code: external_exports.string().describe(
|
|
33922
|
+
"JavaScript async function() expression to execute against the Wix REST API. Has access to `wix.request({ method, url, body, headers })` and `siteId`."
|
|
33923
|
+
),
|
|
33924
|
+
siteId: external_exports.string().optional().describe(
|
|
33925
|
+
"Wix site ID to execute against. You can find site IDs using the ListWixSites tool or by querying the Wix API."
|
|
33926
|
+
)
|
|
33927
|
+
},
|
|
33928
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: false },
|
|
33929
|
+
async ({ code, siteId }) => {
|
|
33930
|
+
if (!siteId) {
|
|
33931
|
+
return {
|
|
33932
|
+
content: [
|
|
33933
|
+
{
|
|
33934
|
+
type: "text",
|
|
33935
|
+
text: "Error: siteId is required. You can list available sites using the ListWixSites tool or by querying the Wix Sites API.",
|
|
33936
|
+
isError: true
|
|
33937
|
+
}
|
|
33938
|
+
]
|
|
33939
|
+
};
|
|
33940
|
+
}
|
|
33941
|
+
logger2.log(
|
|
33942
|
+
`[ExecuteWixAPI] Executing code (${code.length} chars), siteId=${siteId}`
|
|
33943
|
+
);
|
|
33944
|
+
try {
|
|
33945
|
+
const authHeaders = await authStrategy.getSiteAuthHeaders(siteId);
|
|
33946
|
+
const resp = await fetch(executeUrl, {
|
|
33947
|
+
method: "POST",
|
|
33948
|
+
headers: {
|
|
33949
|
+
"Content-Type": "application/json",
|
|
33950
|
+
...authHeaders
|
|
33951
|
+
},
|
|
33952
|
+
body: JSON.stringify({ code, siteId })
|
|
33953
|
+
});
|
|
33954
|
+
if (!resp.ok) {
|
|
33955
|
+
const errorBody = await resp.text();
|
|
33956
|
+
logger2.log(`[ExecuteWixAPI] HTTP ${resp.status}: ${errorBody}`);
|
|
33957
|
+
return {
|
|
33958
|
+
content: [
|
|
33959
|
+
{
|
|
33960
|
+
type: "text",
|
|
33961
|
+
text: `Execute error (${resp.status}): ${errorBody}`,
|
|
33962
|
+
isError: true
|
|
33963
|
+
}
|
|
33964
|
+
]
|
|
33965
|
+
};
|
|
33966
|
+
}
|
|
33967
|
+
const data = await resp.json();
|
|
33968
|
+
if (data.error) {
|
|
33969
|
+
return {
|
|
33970
|
+
content: [
|
|
33971
|
+
{
|
|
33972
|
+
type: "text",
|
|
33973
|
+
text: `Execute error: ${data.error}`,
|
|
33974
|
+
isError: true
|
|
33975
|
+
}
|
|
33976
|
+
]
|
|
33977
|
+
};
|
|
33978
|
+
}
|
|
33979
|
+
const text = typeof data.result === "string" ? data.result : JSON.stringify(data.result, null, 2);
|
|
33980
|
+
return {
|
|
33981
|
+
content: [{ type: "text", text }]
|
|
33982
|
+
};
|
|
33983
|
+
} catch (err) {
|
|
33984
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
33985
|
+
logger2.log(`[ExecuteWixAPI] Error: ${message}`);
|
|
33986
|
+
return {
|
|
33987
|
+
content: [
|
|
33988
|
+
{ type: "text", text: `Execute error: ${message}`, isError: true }
|
|
33989
|
+
]
|
|
33990
|
+
};
|
|
33991
|
+
}
|
|
33992
|
+
}
|
|
33993
|
+
);
|
|
33994
|
+
}
|
|
33627
33995
|
export {
|
|
33628
33996
|
MENU_CONTENT_THRESHOLD,
|
|
33629
33997
|
RECIPES_INDEX_URL,
|
|
@@ -33631,6 +33999,7 @@ export {
|
|
|
33631
33999
|
VALID_DOCS_TOOLS,
|
|
33632
34000
|
WixMcpServer,
|
|
33633
34001
|
addApiCallTool,
|
|
34002
|
+
addCodeModeTools,
|
|
33634
34003
|
addCreateSiteWidgetTool,
|
|
33635
34004
|
addDocsResources,
|
|
33636
34005
|
addDocsTools,
|