@wix/mcp 1.0.82 → 1.0.83

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.
@@ -31679,6 +31679,32 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
31679
31679
 
31680
31680
  Call this when the user provides a specific template by \`metaSiteId\` or \`templateId\`. Use this only when the user gives a valid \`metaSiteId\` or \`templateId\` directly. To browse or choose a template first, call \`SearchSiteTemplates\`.
31681
31681
 
31682
+ `,
31683
+ SearchWixGraphQLOperations: dedent_default`
31684
+ Discover Wix GraphQL operations by intent (ranked keyword search over the root fields). Wix exposes ONE GraphQL schema over all Wix public APIs (Developer Preview) at POST https://www.wixapis.com/graphql/alpha: about 100 query roots and 580 mutation roots named <app><Service><Version><Verb/Entity>, e.g. \`storesProductsV3V3Products\`, \`crmContactsV4Contacts\`, \`crmContactsV4CreateContact\`, \`ecomOrdersV1SearchOrders\`.
31685
+
31686
+ GraphQL flow (3 steps, keep to it): SearchWixGraphQLOperations (find the operation) -> InspectWixGraphQLSchema (read its exact input and return types) -> ExecuteWixGraphQL (run it). Never write an operation or field name you did not see in one of these results.
31687
+
31688
+ When to prefer GraphQL over the REST tools:
31689
+ - Reading several related entities in ONE round-trip: related entities are resolved fields (product -> inventoryItems / collections, order -> fulfillments, booking -> contact), and independent root fields (products + contacts + orders) can share one request.
31690
+ - Picking exactly the fields you need, so responses stay small.
31691
+ - Answering "how many / list / show" questions: a query root plus \`pageInfo\` (\`hasNext\`, and \`total\` where the API provides it).
31692
+ Prefer the REST tools when a recipe or code example already gives you the exact REST call, for uploads/media, or when the GraphQL schema has no matching operation.
31693
+
31694
+ Conventions: query roots take \`queryInput\`; list roots (plural names) take \`queryInput: { query: { paging | cursorPaging, filter, sort } }\` and return \`{ items, pageInfo }\`; singular roots take the entity id. \`filter\`/\`sort\` are a JSON scalar in REST filter syntax (e.g. {"info.name.first": {"$eq": "Ada"}}) — pass them as variables. Mutations take \`input\`; a few read operations (search/list) are exposed as mutations, so search kind "all" unless you are sure.
31695
+ Results list \`kind name(arg: InputType): ReturnType\` plus a one-line description; pass the chosen name to InspectWixGraphQLSchema next.
31696
+ `,
31697
+ InspectWixGraphQLSchema: dedent_default`
31698
+ Read the exact Wix GraphQL schema for an operation and its types, as compact SDL with field descriptions. Pass \`operation\` (a root query/mutation name from SearchWixGraphQLOperations) to get its arguments, input type and return type expanded \`depth\` levels (default 2). Types that were referenced but not expanded are listed at the end — pass the ones you need in \`typeNames\` (optionally together with \`operation\`) instead of raising depth for everything.
31699
+ Use it before every ExecuteWixGraphQL call that introduces a new operation or new fields: read the INPUT type before writing a mutation or filter, and the RETURN type before writing the selection set. GraphQL rejects unknown fields and arguments, and every object-typed field needs its own selection set. \`JSON\` scalar fields (filter, sort, free-form data) accept any JSON — pass them as variables. Never guess a type or field name; if a validation error names a field, come back here.
31700
+ `,
31701
+ ExecuteWixGraphQL: dedent_default`
31702
+ Execute a GraphQL query or mutation against the Wix GraphQL API (POST https://www.wixapis.com/graphql/alpha) with the user's credentials. Authentication is injected — never add Authorization or site/account headers.
31703
+ Site targeting: site-level operations (anything that reads or writes inside a site: products, inventory, orders, contacts, bookings, CMS data, blog, members ...) require \`siteId\`; resolve it with GetSiteContext or ListWixSites first. Use \`scope: "account"\` only for account-level operations.
31704
+ Grounding: every root field, argument and selected field must come from SearchWixGraphQLOperations / InspectWixGraphQLSchema results in this conversation — never from memory. If the response says "Cannot query field" or "Unknown argument", re-inspect the schema and fix the name; do not retry with another guess.
31705
+ Compose: put independent reads in one document as several root fields, and use related-entity fields (e.g. \`inventoryItems\`, \`collections\`, \`fulfillments\`) instead of extra round-trips. Select only the fields you need; every object field needs a selection set. Variables: use them for \`JSON\` scalars (filter, sort) and plain scalars (String, Int, ID), declared in the document (e.g. \`query Q($f: JSON) { ... filter: $f ... }\`). Write mutation inputs and any object that contains an enum INLINE as GraphQL literals with enum values unquoted (e.g. \`input: { product: { name: "Mug", productType: PHYSICAL } }\`) — this endpoint fails with 503 when an enum value arrives inside an object-typed variable. For lists page with \`cursorPaging\` or \`paging\` exactly as the input type declares (never the other one), and request \`pageInfo { hasNext total }\`; \`total\` is only populated with offset \`paging\`, so for a cursor-paged list count by walking pages or use a count operation.
31706
+ Results: each root field fails independently — \`errors[].path\` names the failing field and \`errors[].extensions.message\` the cause (e.g. PERMISSION_DENIED); \`data\` still holds the fields that succeeded. Mutations return the created/updated entity — read the IDs from it and do not re-query to verify. Large results are truncated: narrow the selection or page size instead of re-running.
31707
+ Set \`hasMutations: true\` for any document containing a mutation root field.
31682
31708
  `,
31683
31709
  CreateWixBusinessGuide: dedent_default`
31684
31710
  Provides comprehensive documentation for creating a new Wix business (site, app, etc.).
@@ -31798,7 +31824,8 @@ function mergeConfig(base, overrides) {
31798
31824
  dynamicContextEnabled: overrides.dynamicContextEnabled ?? base.dynamicContextEnabled,
31799
31825
  partnerContextEnabled: overrides.partnerContextEnabled ?? base.partnerContextEnabled,
31800
31826
  usePlatformizedSearch: overrides.usePlatformizedSearch ?? base.usePlatformizedSearch,
31801
- skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled
31827
+ skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled,
31828
+ graphqlEnabled: overrides.graphqlEnabled ?? base.graphqlEnabled
31802
31829
  };
31803
31830
  }
31804
31831
  var defaultConfig = {
@@ -32404,6 +32431,27 @@ var paramDescriptions = {
32404
32431
  mimeType: 'MIME type of the image (e.g. "image/jpeg", "image/png", "image/webp"). Required when imageBase64 does not include a data URL prefix.',
32405
32432
  displayName: "Optional display name for the file in Media Manager. If not provided, uses the original filename."
32406
32433
  },
32434
+ SearchWixGraphQLOperations: {
32435
+ query: 'Free-text intent or entity, e.g. "products with inventory", "create contact", "orders", "blog posts", "booking services". Operation names encode app + service + version + verb/entity (e.g. storesProductsV3V3Products, crmContactsV4CreateContact), so a noun plus a verb (query/get/create/update/delete) ranks best. You may also pass an exact operation name.',
32436
+ kind: 'Restrict to "query" (reads), "mutation" (writes \u2014 note a few reads such as search/list calls are exposed as mutations), or "all" (default).',
32437
+ maxResults: "Maximum number of operations to return (default 10, max 50).",
32438
+ reason: "One sentence describing the original user request and why you are looking for a GraphQL operation."
32439
+ },
32440
+ InspectWixGraphQLSchema: {
32441
+ operation: 'Exact root query or mutation name from SearchWixGraphQLOperations (e.g. "crmContactsV4Contacts"). Returns its arguments, input type and return type as compact SDL, expanded `depth` levels.',
32442
+ typeNames: 'Type names to expand, e.g. ones listed as "Not expanded" in a previous result, or a nested input/object/enum type you need before writing the request. Can be combined with `operation`.',
32443
+ depth: "How many levels of referenced types to expand (1-4, default 2). Level 1 is the given types, level 2 the types their fields reference, and so on. Keep it small and expand specific types with typeNames instead of dumping everything.",
32444
+ reason: "One sentence describing the original user request and why you need this part of the GraphQL schema."
32445
+ },
32446
+ ExecuteWixGraphQL: {
32447
+ query: "The GraphQL document (a query or a mutation). Every root field, argument and selected field MUST come from SearchWixGraphQLOperations / InspectWixGraphQLSchema results in this conversation, never from memory. Declare variables for filters, sort and large inputs, e.g. `query Q($f: JSON) { crmContactsV4Contacts(queryInput: { query: { filter: $f, paging: { limit: 50 } } }) { items { id } pageInfo { hasNext } } }`. Object-typed fields need a selection set. You can put several independent root fields in one document.",
32448
+ variables: 'Variables object for the document, as a JSON object (not a string). Use it for JSON-scalar filters/sort (REST filter syntax, e.g. {"info.name.first": {"$eq": "Ada"}}) and plain scalars. Do NOT pass object inputs that contain enum values (product types, statuses, registration types ...) through variables \u2014 write those inline in the document with the enum unquoted; the endpoint returns 503 otherwise.',
32449
+ operationName: "Operation to run when the document defines more than one named operation.",
32450
+ siteId: "The Wix site to run against. Required for site-level operations (anything reading or writing inside a site \u2014 products, orders, contacts, bookings, CMS, blog, members ...). Resolve it with GetSiteContext or ListWixSites; never pass a guessed value.",
32451
+ scope: '"site" (default when siteId is given) runs with a site-scoped credential; "account" runs account-level operations (sites, account settings) and ignores siteId.',
32452
+ hasMutations: "Whether this document creates, updates, deletes or otherwise mutates Wix data. True for any mutation root field (in any operation of the document) even when the intent is inspection; false only for pure queries. This flag alone decides whether a transient server error may be retried, so never mark a document that writes as false.",
32453
+ reason: "One sentence explaining the original user request and why you are running this GraphQL operation to complete it."
32454
+ },
32407
32455
  RunWixCliCommand: {
32408
32456
  appPath: "The full path to the Wix CLI app to run the command on.",
32409
32457
  extensionType: "The type of extension to generate. You MUST provide this for commands that generate extensions.",
@@ -41794,8 +41842,9 @@ async function buildHarmonySite({
41794
41842
  // src/site-widget-tools/suggested-domain-tool/index.ts
41795
41843
  var WIX_APIS_BASE_URL3 = "https://www.wixapis.com";
41796
41844
  var DEFAULT_SITE_NAME = /^my site(\s+\d+)?$/i;
41797
- function isDefaultSiteName(siteName) {
41798
- return DEFAULT_SITE_NAME.test(siteName.trim());
41845
+ var NON_LATIN_LETTER = /(?![\p{Script=Latin}])\p{L}/u;
41846
+ function isSearchableSiteName(siteName) {
41847
+ return !DEFAULT_SITE_NAME.test(siteName.trim()) && !NON_LATIN_LETTER.test(siteName);
41799
41848
  }
41800
41849
  async function fetchSiteDisplayName(siteAuthorization, siteId) {
41801
41850
  const response = await fetch(
@@ -41901,7 +41950,7 @@ function addSuggestedDomainTool(server, authStrategy) {
41901
41950
  structuredContent: { domains: [] }
41902
41951
  };
41903
41952
  }
41904
- if (!isDefaultSiteName(siteName) || !resolvedQuery) {
41953
+ if (isSearchableSiteName(siteName) || !resolvedQuery) {
41905
41954
  resolvedQuery = siteName;
41906
41955
  }
41907
41956
  } catch (error2) {
@@ -45322,6 +45371,765 @@ function truncateResponse(content, maxChars = DEFAULT_MAX_CHARS) {
45322
45371
  Response was ~${estimatedTokens.toLocaleString()} tokens (limit: ${limitTokens.toLocaleString()}). Refine your code to return less data.`;
45323
45372
  }
45324
45373
 
45374
+ // src/graphql/constants.ts
45375
+ var WIX_GRAPHQL_ENDPOINT = "https://www.wixapis.com/graphql/alpha";
45376
+ var SEARCH_GRAPHQL_TOOL_NAME = "SearchWixGraphQLOperations";
45377
+ var INSPECT_GRAPHQL_TOOL_NAME = "InspectWixGraphQLSchema";
45378
+ var EXECUTE_GRAPHQL_TOOL_NAME = "ExecuteWixGraphQL";
45379
+ var GRAPHQL_TOOL_NAMES = [
45380
+ SEARCH_GRAPHQL_TOOL_NAME,
45381
+ INSPECT_GRAPHQL_TOOL_NAME,
45382
+ EXECUTE_GRAPHQL_TOOL_NAME
45383
+ ];
45384
+
45385
+ // src/graphql/introspection.ts
45386
+ var TYPE_REF_FRAGMENT = `
45387
+ fragment TR on __Type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }`;
45388
+ var ROOT_OPERATIONS_QUERY = `{
45389
+ __schema {
45390
+ queryType { fields { name description args { name type { ...TR } } type { ...TR } } }
45391
+ mutationType { fields { name description args { name type { ...TR } } type { ...TR } } }
45392
+ }
45393
+ }${TYPE_REF_FRAGMENT}`;
45394
+ var TYPE_DETAILS_FRAGMENT = `
45395
+ fragment TD on __Type {
45396
+ kind name description
45397
+ fields { name description type { ...TR } args { name type { ...TR } } }
45398
+ inputFields { name description type { ...TR } defaultValue }
45399
+ enumValues { name description }
45400
+ possibleTypes { name }
45401
+ }`;
45402
+ var ROOT_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
45403
+ var rootCache;
45404
+ var typeCache = /* @__PURE__ */ new Map();
45405
+ function resetGraphqlSchemaCache() {
45406
+ rootCache = void 0;
45407
+ typeCache.clear();
45408
+ }
45409
+ var RETRY_DELAYS_MS = [800, 2e3, 4e3];
45410
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
45411
+ async function fetchWithRetry(fetchImpl, url, init, delays = RETRY_DELAYS_MS) {
45412
+ let attempt = 0;
45413
+ for (; ; ) {
45414
+ const resp = await fetchImpl(url, init);
45415
+ if (resp.status < 500 || attempt >= delays.length) return resp;
45416
+ await sleep(delays[attempt++]);
45417
+ }
45418
+ }
45419
+ async function postIntrospection(query, options) {
45420
+ const fetchImpl = options.fetchImpl ?? fetch;
45421
+ const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
45422
+ const resp = await fetchWithRetry(
45423
+ fetchImpl,
45424
+ endpoint,
45425
+ {
45426
+ method: "POST",
45427
+ headers: {
45428
+ "Content-Type": "application/json",
45429
+ Accept: "application/json"
45430
+ },
45431
+ body: JSON.stringify({ query })
45432
+ },
45433
+ options.retryDelaysMs
45434
+ );
45435
+ const text = await resp.text();
45436
+ if (!resp.ok) {
45437
+ const body = /^\s*<(!doctype|html)/i.test(text) ? "(HTML error page \u2014 the endpoint is temporarily unavailable; try again in a moment)" : text.slice(0, 500);
45438
+ throw new Error(
45439
+ `GraphQL introspection failed (${resp.status} ${resp.statusText}): ${body}`
45440
+ );
45441
+ }
45442
+ const json = JSON.parse(text);
45443
+ if (json.errors?.length && !json.data) {
45444
+ throw new Error(
45445
+ `GraphQL introspection returned errors: ${JSON.stringify(json.errors).slice(0, 500)}`
45446
+ );
45447
+ }
45448
+ return json.data;
45449
+ }
45450
+ function getRootOperations(options = {}) {
45451
+ const now = Date.now();
45452
+ if (rootCache && now - rootCache.fetchedAt < ROOT_CACHE_TTL_MS) {
45453
+ return rootCache.promise;
45454
+ }
45455
+ const promise = postIntrospection(ROOT_OPERATIONS_QUERY, options).then(
45456
+ (data) => {
45457
+ const toOps = (fields, kind) => (fields ?? []).map((f2) => ({
45458
+ kind,
45459
+ name: f2.name,
45460
+ description: f2.description ?? "",
45461
+ args: f2.args ?? [],
45462
+ type: f2.type
45463
+ }));
45464
+ return [
45465
+ ...toOps(data?.__schema?.queryType?.fields, "query"),
45466
+ ...toOps(data?.__schema?.mutationType?.fields, "mutation")
45467
+ ];
45468
+ }
45469
+ );
45470
+ promise.catch(() => {
45471
+ if (rootCache?.promise === promise) rootCache = void 0;
45472
+ });
45473
+ rootCache = { promise, fetchedAt: now };
45474
+ return promise;
45475
+ }
45476
+ var GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;
45477
+ var TYPE_BATCH_SIZE = 10;
45478
+ async function getTypes(names, options = {}) {
45479
+ const unique = [...new Set(names)].filter((n) => GRAPHQL_NAME.test(n));
45480
+ const missing = unique.filter((n) => !typeCache.has(n));
45481
+ for (let start = 0; start < missing.length; start += TYPE_BATCH_SIZE) {
45482
+ const chunk = missing.slice(start, start + TYPE_BATCH_SIZE);
45483
+ const selections = chunk.map((n, i) => `t${i}: __type(name: "${n}") { ...TD }`).join("\n");
45484
+ const query = `{
45485
+ ${selections}
45486
+ }${TYPE_DETAILS_FRAGMENT}${TYPE_REF_FRAGMENT}`;
45487
+ const batch = postIntrospection(query, options);
45488
+ chunk.forEach((n, i) => {
45489
+ const p2 = batch.then(
45490
+ (data) => data?.[`t${i}`] ?? null
45491
+ );
45492
+ p2.catch(() => {
45493
+ if (typeCache.get(n) === p2) typeCache.delete(n);
45494
+ });
45495
+ typeCache.set(n, p2);
45496
+ });
45497
+ await batch.catch(() => void 0);
45498
+ }
45499
+ const result = /* @__PURE__ */ new Map();
45500
+ await Promise.all(
45501
+ unique.map(async (n) => {
45502
+ result.set(n, await typeCache.get(n));
45503
+ })
45504
+ );
45505
+ return result;
45506
+ }
45507
+ function renderTypeRef(ref) {
45508
+ if (!ref) return "Unknown";
45509
+ if (ref.kind === "NON_NULL") return `${renderTypeRef(ref.ofType)}!`;
45510
+ if (ref.kind === "LIST") return `[${renderTypeRef(ref.ofType)}]`;
45511
+ return ref.name ?? "Unknown";
45512
+ }
45513
+ function namedType(ref) {
45514
+ let cur = ref;
45515
+ while (cur && (cur.kind === "NON_NULL" || cur.kind === "LIST")) {
45516
+ cur = cur.ofType ?? null;
45517
+ }
45518
+ return cur?.name ?? null;
45519
+ }
45520
+ var BUILTIN_SCALARS = /* @__PURE__ */ new Set([
45521
+ "String",
45522
+ "Int",
45523
+ "Float",
45524
+ "Boolean",
45525
+ "ID",
45526
+ "JSON"
45527
+ ]);
45528
+ function isBuiltinScalar(name) {
45529
+ return !!name && BUILTIN_SCALARS.has(name);
45530
+ }
45531
+ function oneLine(text, max) {
45532
+ if (!text) return "";
45533
+ const flat = text.replace(/\s+/g, " ").trim();
45534
+ return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
45535
+ }
45536
+ function renderField(field, isInput) {
45537
+ const args = !isInput && field.args?.length ? `(${field.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ")})` : "";
45538
+ const def = isInput && field.defaultValue != null ? ` = ${field.defaultValue}` : "";
45539
+ const comment = field.description ? ` # ${oneLine(field.description, 140)}` : "";
45540
+ return ` ${field.name}${args}: ${renderTypeRef(field.type)}${def}${comment}`;
45541
+ }
45542
+ function renderType(type) {
45543
+ const references = /* @__PURE__ */ new Set();
45544
+ const collect = (ref) => {
45545
+ const n = namedType(ref);
45546
+ if (n && !isBuiltinScalar(n) && n !== type.name) references.add(n);
45547
+ };
45548
+ const header = type.description ? `# ${oneLine(type.description, 200)}
45549
+ ` : "";
45550
+ let body;
45551
+ switch (type.kind) {
45552
+ case "ENUM":
45553
+ body = `enum ${type.name} {
45554
+ ${(type.enumValues ?? []).map(
45555
+ (v) => ` ${v.name}${v.description ? ` # ${oneLine(v.description, 100)}` : ""}`
45556
+ ).join("\n")}
45557
+ }`;
45558
+ break;
45559
+ case "INPUT_OBJECT":
45560
+ (type.inputFields ?? []).forEach((f2) => collect(f2.type));
45561
+ body = `input ${type.name} {
45562
+ ${(type.inputFields ?? []).map((f2) => renderField(f2, true)).join("\n")}
45563
+ }`;
45564
+ break;
45565
+ case "UNION":
45566
+ (type.possibleTypes ?? []).forEach((p2) => references.add(p2.name));
45567
+ body = `union ${type.name} = ${(type.possibleTypes ?? []).map((p2) => p2.name).join(" | ")}`;
45568
+ break;
45569
+ case "SCALAR":
45570
+ body = `scalar ${type.name}`;
45571
+ break;
45572
+ default: {
45573
+ (type.fields ?? []).forEach((f2) => {
45574
+ collect(f2.type);
45575
+ f2.args?.forEach((a2) => collect(a2.type));
45576
+ });
45577
+ const keyword = type.kind === "INTERFACE" ? "interface" : "type";
45578
+ body = `${keyword} ${type.name} {
45579
+ ${(type.fields ?? []).map((f2) => renderField(f2, false)).join("\n")}
45580
+ }`;
45581
+ }
45582
+ }
45583
+ return { text: header + body, references: [...references] };
45584
+ }
45585
+ function renderOperationSignature(op) {
45586
+ const args = op.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ");
45587
+ return `${op.kind === "query" ? "Query" : "Mutation"}.${op.name}(${args}): ${renderTypeRef(op.type)}`;
45588
+ }
45589
+ async function expandTypes(rootTypeNames, options = {}) {
45590
+ const depth = Math.max(1, Math.min(options.depth ?? 2, 5));
45591
+ const maxTypes = options.maxTypes ?? 40;
45592
+ const rendered = [];
45593
+ const unknown2 = [];
45594
+ const seen = /* @__PURE__ */ new Set();
45595
+ let frontier = [...new Set(rootTypeNames)].filter((n) => !isBuiltinScalar(n));
45596
+ let level = 1;
45597
+ let overflow = [];
45598
+ while (frontier.length > 0 && level <= depth) {
45599
+ const room = maxTypes - seen.size;
45600
+ if (room <= 0) {
45601
+ overflow = frontier;
45602
+ break;
45603
+ }
45604
+ const batch = frontier.slice(0, room);
45605
+ overflow = frontier.slice(room);
45606
+ batch.forEach((n) => seen.add(n));
45607
+ const types = await getTypes(batch, options);
45608
+ const next = /* @__PURE__ */ new Set();
45609
+ for (const name of batch) {
45610
+ const type = types.get(name);
45611
+ if (!type) {
45612
+ unknown2.push(name);
45613
+ continue;
45614
+ }
45615
+ const { text, references } = renderType(type);
45616
+ rendered.push(text);
45617
+ references.forEach((r) => {
45618
+ if (!seen.has(r)) next.add(r);
45619
+ });
45620
+ }
45621
+ frontier = [...next];
45622
+ level++;
45623
+ }
45624
+ const unexpanded = [.../* @__PURE__ */ new Set([...overflow, ...frontier])].filter(
45625
+ (n) => !seen.has(n) && !isBuiltinScalar(n)
45626
+ );
45627
+ return { rendered, unexpanded, unknown: unknown2 };
45628
+ }
45629
+
45630
+ // src/graphql/search.ts
45631
+ function tokenize(text) {
45632
+ return text.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 0);
45633
+ }
45634
+ var STOP_WORDS = /* @__PURE__ */ new Set([
45635
+ "a",
45636
+ "an",
45637
+ "the",
45638
+ "of",
45639
+ "for",
45640
+ "to",
45641
+ "in",
45642
+ "on",
45643
+ "with",
45644
+ "and",
45645
+ "or",
45646
+ "by",
45647
+ "all",
45648
+ "my",
45649
+ "me",
45650
+ "i",
45651
+ "from",
45652
+ "is",
45653
+ "are",
45654
+ "be",
45655
+ "it",
45656
+ "this",
45657
+ "that",
45658
+ "wix",
45659
+ "api",
45660
+ "graphql"
45661
+ ]);
45662
+ function stem(token) {
45663
+ if (token.length > 4 && token.endsWith("ies"))
45664
+ return `${token.slice(0, -3)}y`;
45665
+ if (token.length > 3 && token.endsWith("es") && !token.endsWith("ses"))
45666
+ return token.slice(0, -1);
45667
+ if (token.length > 3 && token.endsWith("s") && !token.endsWith("ss"))
45668
+ return token.slice(0, -1);
45669
+ return token;
45670
+ }
45671
+ var VERB_SYNONYMS = {
45672
+ list: ["query", "list", "search"],
45673
+ find: ["query", "search", "get"],
45674
+ fetch: ["get", "query"],
45675
+ read: ["get", "query"],
45676
+ show: ["get", "query"],
45677
+ count: ["count", "query"],
45678
+ add: ["create", "add"],
45679
+ new: ["create"],
45680
+ insert: ["create"],
45681
+ edit: ["update"],
45682
+ change: ["update"],
45683
+ modify: ["update"],
45684
+ set: ["update"],
45685
+ remove: ["delete", "remove"],
45686
+ destroy: ["delete"],
45687
+ cancel: ["cancel", "delete"],
45688
+ customer: ["contact", "member"],
45689
+ client: ["contact", "member"],
45690
+ item: ["product", "item"],
45691
+ inventory: ["inventory", "stock"],
45692
+ stock: ["inventory", "stock"],
45693
+ post: ["post", "blog"],
45694
+ article: ["post", "blog"],
45695
+ appointment: ["booking", "session"],
45696
+ collection: ["collection", "category", "data"],
45697
+ cms: ["data", "collection"],
45698
+ store: ["stores", "store"]
45699
+ };
45700
+ function expandQueryTokens(tokens) {
45701
+ const out = /* @__PURE__ */ new Set();
45702
+ for (const raw of tokens) {
45703
+ if (STOP_WORDS.has(raw)) continue;
45704
+ const s2 = stem(raw);
45705
+ out.add(s2);
45706
+ for (const syn of VERB_SYNONYMS[raw] ?? VERB_SYNONYMS[s2] ?? []) {
45707
+ out.add(stem(syn));
45708
+ }
45709
+ }
45710
+ return out;
45711
+ }
45712
+ var READ_VERBS = /* @__PURE__ */ new Set([
45713
+ "list",
45714
+ "get",
45715
+ "query",
45716
+ "find",
45717
+ "fetch",
45718
+ "read",
45719
+ "show",
45720
+ "retrieve",
45721
+ "search",
45722
+ "count",
45723
+ "view",
45724
+ "see"
45725
+ ]);
45726
+ var WRITE_VERBS = /* @__PURE__ */ new Set([
45727
+ "create",
45728
+ "add",
45729
+ "new",
45730
+ "insert",
45731
+ "update",
45732
+ "edit",
45733
+ "change",
45734
+ "modify",
45735
+ "set",
45736
+ "delete",
45737
+ "remove",
45738
+ "destroy",
45739
+ "cancel",
45740
+ "bulk",
45741
+ "merge",
45742
+ "publish",
45743
+ "send"
45744
+ ]);
45745
+ var isVersionToken = (t) => t === "v" || /^\d+$/.test(t);
45746
+ function stripMarkdown(text) {
45747
+ return text.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/[`*_]/g, "");
45748
+ }
45749
+ function firstSentence(text, max = 220) {
45750
+ const flat = stripMarkdown(text).replace(/\s+/g, " ").trim();
45751
+ const cut = flat.search(/(?<=[.!?])\s/);
45752
+ const sentence = cut > 0 ? flat.slice(0, cut) : flat;
45753
+ return sentence.length > max ? `${sentence.slice(0, max - 1)}\u2026` : sentence;
45754
+ }
45755
+ var indexCache = /* @__PURE__ */ new WeakMap();
45756
+ function indexOperations(ops) {
45757
+ let indexed = indexCache.get(ops);
45758
+ if (!indexed) {
45759
+ indexed = ops.map((op) => ({
45760
+ op,
45761
+ nameTokens: new Set(tokenize(op.name).map(stem)),
45762
+ descTokens: new Set(tokenize(op.description.slice(0, 600)).map(stem))
45763
+ }));
45764
+ indexCache.set(ops, indexed);
45765
+ }
45766
+ return indexed;
45767
+ }
45768
+ function searchOperations(ops, query, options = {}) {
45769
+ const { kind = "all", maxResults = 10 } = options;
45770
+ const rawTokens = tokenize(query);
45771
+ const terms = expandQueryTokens(rawTokens);
45772
+ const originalTerms = new Set(
45773
+ rawTokens.filter((t) => !STOP_WORDS.has(t)).map(stem)
45774
+ );
45775
+ const exactName = query.trim();
45776
+ const hasWriteVerb = rawTokens.some((t) => WRITE_VERBS.has(t));
45777
+ const nounTokens = rawTokens.filter(
45778
+ (t) => !STOP_WORDS.has(t) && !READ_VERBS.has(t) && !WRITE_VERBS.has(t)
45779
+ );
45780
+ const pluralIntent = nounTokens.length > 0 && nounTokens.some((t) => stem(t) !== t);
45781
+ const readIntent = !hasWriteVerb;
45782
+ const matches = [];
45783
+ for (const { op, nameTokens, descTokens } of indexOperations(ops)) {
45784
+ if (kind !== "all" && op.kind !== kind) continue;
45785
+ let score = 0;
45786
+ let originalHits = 0;
45787
+ const matchedNameTokens = /* @__PURE__ */ new Set();
45788
+ for (const term of terms) {
45789
+ const isOriginal = originalTerms.has(term);
45790
+ if (op.kind === "query" && readIntent && READ_VERBS.has(term)) {
45791
+ score += isOriginal ? 4 : 2;
45792
+ if (isOriginal) originalHits++;
45793
+ if (nameTokens.has(term)) matchedNameTokens.add(term);
45794
+ continue;
45795
+ }
45796
+ if (nameTokens.has(term)) {
45797
+ matchedNameTokens.add(term);
45798
+ score += isOriginal ? 4 : 2;
45799
+ if (isOriginal) originalHits++;
45800
+ continue;
45801
+ }
45802
+ let prefixHit = false;
45803
+ for (const nt2 of nameTokens) {
45804
+ if (term.length >= 3 && (nt2.startsWith(term) || term.startsWith(nt2))) {
45805
+ prefixHit = true;
45806
+ matchedNameTokens.add(nt2);
45807
+ break;
45808
+ }
45809
+ }
45810
+ if (prefixHit) {
45811
+ score += isOriginal ? 2 : 1;
45812
+ if (isOriginal) originalHits++;
45813
+ continue;
45814
+ }
45815
+ if (descTokens.has(term)) {
45816
+ score += 1;
45817
+ if (isOriginal) originalHits++;
45818
+ }
45819
+ }
45820
+ if (score <= 0 && op.name !== exactName) continue;
45821
+ if (op.name === exactName) score += 100;
45822
+ if (originalTerms.size > 0 && originalHits === originalTerms.size) {
45823
+ score += 3;
45824
+ }
45825
+ const lastToken = tokenize(op.name).filter((t) => !isVersionToken(t)).pop();
45826
+ if (lastToken && nounTokens.length > 0) {
45827
+ const pluralOp = stem(lastToken) !== lastToken;
45828
+ score += pluralOp === pluralIntent ? 0.5 : -0.5;
45829
+ }
45830
+ if (/DoNotCall/i.test(op.name)) score -= 2;
45831
+ for (const nt2 of nameTokens) {
45832
+ if (!isVersionToken(nt2) && !matchedNameTokens.has(nt2)) score -= 0.3;
45833
+ }
45834
+ if (readIntent && op.kind === "mutation" && [...nameTokens].some((t) => WRITE_VERBS.has(t))) {
45835
+ score -= 6;
45836
+ }
45837
+ if (op.kind === "query" && readIntent) score += 1;
45838
+ const version2 = op.name.match(/V(\d+)/);
45839
+ if (version2) score += Math.min(Number(version2[1]), 5) * 0.1;
45840
+ if (!op.description) score -= 0.5;
45841
+ score -= op.name.length / 200;
45842
+ if (score <= 0) continue;
45843
+ matches.push({
45844
+ operation: op.name,
45845
+ kind: op.kind,
45846
+ signature: `${op.name}(${op.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ")}): ${renderTypeRef(op.type)}`,
45847
+ description: firstSentence(op.description),
45848
+ inputType: op.args[0] ? namedType(op.args[0].type) : null,
45849
+ returnType: namedType(op.type),
45850
+ score: Math.round(score * 100) / 100
45851
+ });
45852
+ }
45853
+ matches.sort(
45854
+ (a2, b2) => b2.score - a2.score || a2.operation.localeCompare(b2.operation)
45855
+ );
45856
+ return matches.slice(0, Math.max(1, Math.min(maxResults, 50)));
45857
+ }
45858
+
45859
+ // src/graphql/index.ts
45860
+ var textResult = (text) => ({
45861
+ content: [{ type: "text", text }]
45862
+ });
45863
+ var errorResult2 = (text) => ({
45864
+ isError: true,
45865
+ content: [{ type: "text", text }]
45866
+ });
45867
+ var SCHEMA_MAX_RESPONSE_CHARS = 48e3;
45868
+ function addGraphqlTools(server, options = {}) {
45869
+ const { authStrategy, disableTools = [], toolDescriptions } = options;
45870
+ const getDescription = (name) => toolDescriptions?.[name] ?? defaultToolDescriptions[name];
45871
+ if (!disableTools.includes(SEARCH_GRAPHQL_TOOL_NAME)) {
45872
+ addSearchGraphqlTool(
45873
+ server,
45874
+ getDescription(SEARCH_GRAPHQL_TOOL_NAME),
45875
+ options
45876
+ );
45877
+ }
45878
+ if (!disableTools.includes(INSPECT_GRAPHQL_TOOL_NAME)) {
45879
+ addInspectGraphqlTool(
45880
+ server,
45881
+ getDescription(INSPECT_GRAPHQL_TOOL_NAME),
45882
+ options
45883
+ );
45884
+ }
45885
+ if (authStrategy && !disableTools.includes(EXECUTE_GRAPHQL_TOOL_NAME)) {
45886
+ addExecuteGraphqlTool(
45887
+ server,
45888
+ getDescription(EXECUTE_GRAPHQL_TOOL_NAME),
45889
+ authStrategy,
45890
+ options
45891
+ );
45892
+ }
45893
+ }
45894
+ function introspectionOptions(options) {
45895
+ return {
45896
+ endpoint: options.endpoint,
45897
+ fetchImpl: options.fetchImpl,
45898
+ retryDelaysMs: options.retryDelaysMs
45899
+ };
45900
+ }
45901
+ function addSearchGraphqlTool(server, description, options) {
45902
+ const d2 = desc("SearchWixGraphQLOperations");
45903
+ server.tool(
45904
+ SEARCH_GRAPHQL_TOOL_NAME,
45905
+ description,
45906
+ {
45907
+ query: external_exports.string().describe(d2.query),
45908
+ kind: external_exports.enum(["query", "mutation", "all"]).optional().describe(d2.kind),
45909
+ maxResults: external_exports.number().int().min(1).max(50).optional().describe(d2.maxResults),
45910
+ reason: external_exports.string().describe(d2.reason)
45911
+ },
45912
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
45913
+ async ({ query, kind, maxResults, reason }) => {
45914
+ logger2.log(
45915
+ `[${SEARCH_GRAPHQL_TOOL_NAME}] query="${query}" kind=${kind ?? "all"} reason="${reason}"`
45916
+ );
45917
+ try {
45918
+ const ops = await getRootOperations(introspectionOptions(options));
45919
+ const matches = searchOperations(ops, query, {
45920
+ kind: kind ?? "all",
45921
+ maxResults: maxResults ?? 10
45922
+ });
45923
+ if (matches.length === 0) {
45924
+ return textResult(
45925
+ `No GraphQL operations matched "${query}". Try other words for the entity (e.g. "contact" instead of "customer", "product" instead of "item") or the verb (query/get/create/update/delete), or search a single noun.`
45926
+ );
45927
+ }
45928
+ const lines = matches.map(
45929
+ (m2, i) => `${i + 1}. ${m2.kind} ${m2.signature}
45930
+ ${m2.description || "(no description)"}`
45931
+ );
45932
+ const text = [
45933
+ `Top ${matches.length} of ${ops.length} Wix GraphQL root operations for "${query}":`,
45934
+ "",
45935
+ ...lines,
45936
+ "",
45937
+ `Next: call ${INSPECT_GRAPHQL_TOOL_NAME} with \`operation\` set to the chosen name to read its exact input type and return type before writing the request.`
45938
+ ].join("\n");
45939
+ return textResult(text);
45940
+ } catch (err) {
45941
+ const message = err instanceof Error ? err.message : String(err);
45942
+ logger2.log(`[${SEARCH_GRAPHQL_TOOL_NAME}] Error: ${message}`);
45943
+ return errorResult2(`GraphQL schema search error: ${message}`);
45944
+ }
45945
+ }
45946
+ );
45947
+ }
45948
+ function addInspectGraphqlTool(server, description, options) {
45949
+ const d2 = desc("InspectWixGraphQLSchema");
45950
+ const maxChars = options.maxResponseSize ?? SCHEMA_MAX_RESPONSE_CHARS;
45951
+ server.tool(
45952
+ INSPECT_GRAPHQL_TOOL_NAME,
45953
+ description,
45954
+ {
45955
+ operation: external_exports.string().optional().describe(d2.operation),
45956
+ typeNames: external_exports.array(external_exports.string()).optional().describe(d2.typeNames),
45957
+ depth: external_exports.number().int().min(1).max(4).optional().describe(d2.depth),
45958
+ reason: external_exports.string().describe(d2.reason)
45959
+ },
45960
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
45961
+ async ({ operation, typeNames, depth, reason }) => {
45962
+ logger2.log(
45963
+ `[${INSPECT_GRAPHQL_TOOL_NAME}] operation=${operation ?? "-"} typeNames=${JSON.stringify(typeNames ?? [])} depth=${depth ?? 2} reason="${reason}"`
45964
+ );
45965
+ if (!operation && !(typeNames && typeNames.length > 0)) {
45966
+ return errorResult2(
45967
+ "Pass `operation` (a root query/mutation name from SearchWixGraphQLOperations) and/or `typeNames` (type names to expand)."
45968
+ );
45969
+ }
45970
+ try {
45971
+ const io2 = introspectionOptions(options);
45972
+ const sections = [];
45973
+ const roots = [];
45974
+ if (operation) {
45975
+ const ops = await getRootOperations(io2);
45976
+ const op = ops.find((o) => o.name === operation);
45977
+ if (!op) {
45978
+ const suggestions = searchOperations(ops, operation, {
45979
+ maxResults: 5
45980
+ });
45981
+ return errorResult2(
45982
+ `No root operation named "${operation}". ${suggestions.length ? `Did you mean: ${suggestions.map((s2) => `${s2.kind} ${s2.operation}`).join(", ")}? Use SearchWixGraphQLOperations to discover the exact name.` : "Use SearchWixGraphQLOperations to discover the exact name."}`
45983
+ );
45984
+ }
45985
+ sections.push(
45986
+ `# ${renderOperationSignature(op)}`,
45987
+ op.description ? op.description.trim().split("\n").map((l) => `# ${l}`).join("\n") : "# (no description)"
45988
+ );
45989
+ op.args.forEach((a2) => {
45990
+ const n = namedType(a2.type);
45991
+ if (n) roots.push(n);
45992
+ });
45993
+ const ret = namedType(op.type);
45994
+ if (ret) roots.push(ret);
45995
+ }
45996
+ if (typeNames?.length) roots.push(...typeNames);
45997
+ const { rendered, unexpanded, unknown: unknown2 } = await expandTypes(roots, {
45998
+ ...io2,
45999
+ depth: depth ?? 2
46000
+ });
46001
+ sections.push(...rendered);
46002
+ if (unknown2.length) {
46003
+ sections.push(
46004
+ `# Unknown type names (not in the schema): ${unknown2.join(", ")}`
46005
+ );
46006
+ }
46007
+ if (unexpanded.length) {
46008
+ sections.push(
46009
+ `# Not expanded (pass any of these in \`typeNames\` to read them): ${unexpanded.join(", ")}`
46010
+ );
46011
+ }
46012
+ sections.push(
46013
+ "# Notes: `JSON` scalar fields (filter, sort, free-form data) take any JSON \u2014 pass them as variables. Every object-typed field in a selection needs its own { ... } selection set. Only fields listed above exist. Paging: use exactly the paging style the input type declares \u2014 `paging` (offset) or `cursorPaging` (cursor) \u2014 never the other one. `pageInfo.total` is only populated with offset paging; with cursor paging, count by walking pages (`pageInfo.hasNext` + cursor) or use a dedicated count operation if one exists."
46014
+ );
46015
+ return textResult(truncateResponse(sections.join("\n\n"), maxChars));
46016
+ } catch (err) {
46017
+ const message = err instanceof Error ? err.message : String(err);
46018
+ logger2.log(`[${INSPECT_GRAPHQL_TOOL_NAME}] Error: ${message}`);
46019
+ return errorResult2(`GraphQL schema inspection error: ${message}`);
46020
+ }
46021
+ }
46022
+ );
46023
+ }
46024
+ function addExecuteGraphqlTool(server, description, authStrategy, options) {
46025
+ const d2 = desc("ExecuteWixGraphQL");
46026
+ const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
46027
+ const fetchImpl = options.fetchImpl ?? fetch;
46028
+ server.tool(
46029
+ EXECUTE_GRAPHQL_TOOL_NAME,
46030
+ description,
46031
+ {
46032
+ query: external_exports.string().describe(d2.query),
46033
+ variables: external_exports.record(external_exports.unknown()).optional().describe(d2.variables),
46034
+ operationName: external_exports.string().optional().describe(d2.operationName),
46035
+ siteId: external_exports.string().optional().describe(d2.siteId),
46036
+ scope: external_exports.enum(["site", "account"]).optional().describe(d2.scope),
46037
+ hasMutations: external_exports.boolean().describe(d2.hasMutations),
46038
+ reason: external_exports.string().describe(d2.reason)
46039
+ },
46040
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
46041
+ async ({ query, variables, operationName, siteId, scope, hasMutations, reason }, extra) => {
46042
+ const effectiveScope = scope ?? (siteId ? "site" : "account");
46043
+ logger2.log(
46044
+ `[${EXECUTE_GRAPHQL_TOOL_NAME}] scope=${effectiveScope} siteId=${siteId ?? "none"} hasMutations=${hasMutations} operationName=${operationName ?? "-"} reason="${reason}"`
46045
+ );
46046
+ if (effectiveScope === "site" && !siteId) {
46047
+ return errorResult2(
46048
+ 'A `siteId` is required for site-level GraphQL operations (anything that reads or writes inside a site). Resolve it with GetSiteContext or ListWixSites, or set scope: "account" for account-level operations.'
46049
+ );
46050
+ }
46051
+ if (!query.trim()) {
46052
+ return errorResult2("`query` must be a non-empty GraphQL document.");
46053
+ }
46054
+ const authHeaders = effectiveScope === "site" ? await authStrategy.getSiteAuthHeaders(siteId) : await authStrategy.getAccountAuthHeaders();
46055
+ try {
46056
+ const init = {
46057
+ method: "POST",
46058
+ headers: {
46059
+ "Content-Type": "application/json",
46060
+ Accept: "application/json",
46061
+ ...authHeaders
46062
+ },
46063
+ body: JSON.stringify({
46064
+ query,
46065
+ ...variables ? { variables } : {},
46066
+ ...operationName ? { operationName } : {}
46067
+ })
46068
+ };
46069
+ const resp = hasMutations ? await fetchImpl(endpoint, init) : await fetchWithRetry(
46070
+ fetchImpl,
46071
+ endpoint,
46072
+ init,
46073
+ options.retryDelaysMs
46074
+ );
46075
+ const requestId = resp.headers?.get("x-wix-request-id") ?? void 0;
46076
+ extra?.setToolBiParams?.({ siteId, requestId });
46077
+ const text = await resp.text();
46078
+ if (!resp.ok) {
46079
+ await authStrategy.enforceValidWixToken?.({
46080
+ status: resp.status,
46081
+ response: { status: resp.status }
46082
+ });
46083
+ const body2 = /^\s*<(!doctype|html)/i.test(text) ? "(HTML error page)" : text.slice(0, 2e3);
46084
+ const hasObjectVariables = !!variables && Object.values(variables).some(
46085
+ (v) => v !== null && typeof v === "object"
46086
+ );
46087
+ const hint = resp.status >= 500 ? hasObjectVariables ? ` The Wix GraphQL endpoint (Developer Preview) returns 503 when an object-typed variable carries an enum value. Rewrite the document with the input INLINE as a GraphQL literal (enum values unquoted, e.g. productType: PHYSICAL), keep variables only for JSON scalars and plain scalars, and retry once. If it still fails and REST tools (ExecuteWixAPI / CallWixSiteAPI) are available, use the equivalent REST method.` : ` The Wix GraphQL endpoint (Developer Preview) failed for this operation. Do not retry the same document more than once. If REST tools (ExecuteWixAPI / CallWixSiteAPI) are available, complete the task through the equivalent REST method instead; otherwise report the failure with the request id.` : "";
46088
+ return errorResult2(
46089
+ `Wix GraphQL request failed: ${resp.status} ${resp.statusText}.${requestId ? ` request id: ${requestId}.` : ""}${hint}
46090
+ ${body2}`
46091
+ );
46092
+ }
46093
+ let json;
46094
+ try {
46095
+ json = JSON.parse(text);
46096
+ } catch {
46097
+ return errorResult2(
46098
+ `Wix GraphQL returned a non-JSON body:
46099
+ ${text.slice(0, 2e3)}`
46100
+ );
46101
+ }
46102
+ const hasData = json.data != null && Object.values(json.data).some((v) => v !== null && v !== void 0);
46103
+ const errors = json.errors ?? [];
46104
+ if (!hasData && errors.length > 0) {
46105
+ const permissionDenied = errors.some(
46106
+ (e) => e.extensions?.message === "PERMISSION_DENIED"
46107
+ );
46108
+ return errorResult2(
46109
+ [
46110
+ `Wix GraphQL returned errors and no data${requestId ? ` (request id: ${requestId})` : ""}:`,
46111
+ JSON.stringify(errors, null, 2).slice(0, 4e3),
46112
+ permissionDenied ? "PERMISSION_DENIED usually means the operation is site-level and was called without the right `siteId`, the app behind it is not installed on the site, or the credential lacks that permission scope." : 'Validation errors ("Cannot query field ...", "Unknown argument ...") mean a name was guessed \u2014 re-read the exact fields with InspectWixGraphQLSchema and retry.'
46113
+ ].join("\n")
46114
+ );
46115
+ }
46116
+ const body = { data: json.data };
46117
+ if (errors.length > 0) {
46118
+ body.errors = errors;
46119
+ body.note = "Partial result: some root fields failed (see errors[].path). Fields present in data succeeded.";
46120
+ }
46121
+ return textResult(truncateResponse(body, options.maxResponseSize));
46122
+ } catch (err) {
46123
+ rethrowIfUnauthorized(err);
46124
+ await authStrategy.enforceValidWixToken?.(err);
46125
+ const message = err instanceof Error ? err.message : String(err);
46126
+ logger2.log(`[${EXECUTE_GRAPHQL_TOOL_NAME}] Error: ${message}`);
46127
+ return errorResult2(`Wix GraphQL execution error: ${message}`);
46128
+ }
46129
+ }
46130
+ );
46131
+ }
46132
+
45325
46133
  // src/code-mode/validation.ts
45326
46134
  var EXECUTE_FUNCTION_EXPRESSION_HINT = 'ExecuteWixAPI code must be a function expression, not a script body. Pass code like: async () => { const response = await wix.request({ scope: "site", method: "GET", url: "https://www.wixapis.com/..." }); return response.data; }. Do not write top-level const/await/return outside the function and do not invoke the function yourself.';
45327
46135
  function validateExecuteCode(code) {
@@ -45807,6 +46615,20 @@ function createWixToolkit(options) {
45807
46615
  maxResponseSize
45808
46616
  });
45809
46617
  }
46618
+ const requestedGraphqlTools = GRAPHQL_TOOL_NAMES.filter(
46619
+ (name) => requestedTools.has(name)
46620
+ );
46621
+ if (requestedGraphqlTools.length > 0) {
46622
+ addGraphqlTools(server, {
46623
+ authStrategy,
46624
+ disableTools: [
46625
+ ...disableTools ?? [],
46626
+ ...GRAPHQL_TOOL_NAMES.filter((n) => !requestedTools.has(n))
46627
+ ],
46628
+ toolDescriptions: effectiveToolDescriptions,
46629
+ maxResponseSize
46630
+ });
46631
+ }
45810
46632
  } else {
45811
46633
  addApiCallTool(
45812
46634
  server,
@@ -45992,13 +46814,17 @@ export {
45992
46814
  DEFAULT_OPENAI_SECURITY_SCHEMES,
45993
46815
  EDIT_SITE_TOOL_NAME,
45994
46816
  EXECUTE_FUNCTION_EXPRESSION_HINT,
46817
+ EXECUTE_GRAPHQL_TOOL_NAME,
45995
46818
  GET_SUGGESTED_DOMAINS_TOOL_NAME,
46819
+ GRAPHQL_TOOL_NAMES,
45996
46820
  IMPORT_CLAUDE_DESIGN_TOOL_NAME,
46821
+ INSPECT_GRAPHQL_TOOL_NAME,
45997
46822
  MENU_CONTENT_THRESHOLD,
45998
46823
  OPENAI_WIDGET_MIME_TYPE,
45999
46824
  OPEN_AI_SITE_WIDGET_CSP,
46000
46825
  PULL_SITE_JOB_TOOL_NAME,
46001
46826
  RECIPES_INDEX_URL,
46827
+ SEARCH_GRAPHQL_TOOL_NAME,
46002
46828
  SEARCH_SITE_TEMPLATES_TOOL_NAME,
46003
46829
  SITE_BUILDER_TOOL_NAME,
46004
46830
  SITE_CREATION_COPY,
@@ -46011,6 +46837,7 @@ export {
46011
46837
  VALID_DOCS_TOOLS,
46012
46838
  WIXEL_ICON_PNG_URL,
46013
46839
  WIXEL_ICON_SVG_URL,
46840
+ WIX_GRAPHQL_ENDPOINT,
46014
46841
  WIX_SITE_CREATION_TOOL_NAME,
46015
46842
  WixFetchError,
46016
46843
  WixMcpServer,
@@ -46027,6 +46854,7 @@ export {
46027
46854
  addGetWixelAssetTool,
46028
46855
  addGetWixelJobStatusTool,
46029
46856
  addGetWixelProjectAssetsTool,
46857
+ addGraphqlTools,
46030
46858
  addImportClaudeDesignTool,
46031
46859
  addListWixelEventsTool,
46032
46860
  addMarkWixelJobAsFulfilledTool,
@@ -46036,6 +46864,7 @@ export {
46036
46864
  addSendWixelMessageTool,
46037
46865
  addSiteCreationWidgetTools,
46038
46866
  addStartWixelSessionTool,
46867
+ addSuggestedDomainTool,
46039
46868
  addSupportTool,
46040
46869
  addWixSiteCreationTool,
46041
46870
  addWixelSessionTools,
@@ -46060,6 +46889,7 @@ export {
46060
46889
  mergeConfig,
46061
46890
  normalizeMenuContent,
46062
46891
  parseDirectChildren,
46892
+ resetGraphqlSchemaCache,
46063
46893
  rethrowIfUnauthorized,
46064
46894
  summarizeLargeMenu,
46065
46895
  toWidget,