PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / assets / js / packages / elementor-kit-mcp / elementor-kit-mcp.js

elementor-kit-mcp.js in Elementor Website Builder – more than just a page builder 4.3.2, at assets/js/packages/elementor-kit-mcp/elementor-kit-mcp.js

280 lines 13.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(_elementor_editor_mcp, _elementor_elementor_mcp_common, _elementor_schema) {
2
3 //#region \0rolldown/runtime.js
4 var __defProp = Object.defineProperty;
5 var __name = (target, value) => __defProp(target, "name", {
6 value,
7 configurable: true
8 });
9 var __exportAll = (all, no_symbols) => {
10 let target = {};
11 for (var name in all) {
12 __defProp(target, name, {
13 get: all[name],
14 enumerable: true
15 });
16 }
17 if (!no_symbols) {
18 __defProp(target, Symbol.toStringTag, { value: "Module" });
19 }
20 return target;
21 };
22
23 //#endregion
24
25 //#region packages/packages/core/elementor-kit-mcp/src/mcp-description-resource.ts
26 var KIT_DESCRIPTION_URI = "elementor://kit/server-description";
27 var KIT_DESCRIPTION = `## Elementor Kit Settings Management
28
29 ### Capabilities:
30 **Global Design System:**
31 - Create, update, name, and delete global colors (both system and custom)
32 - Create, update, name, and delete global fonts (both system and custom)
33
34 **Site Identity:**
35 - Insert site logo
36 - Set site favicon
37 - Update site name
38 - Modify site description
39
40 ### Limitations:
41 **Theme Style Settings:**
42 - Cannot set or update Elementor Theme Style settings including typography, buttons, images, form fields, Hello Theme header, or Hello Theme footer that affect the entire website appearance
43
44 **Site-Wide Settings:**
45 - Cannot set site-wide background (color or image)
46 - Cannot configure mobile browser background
47 - Cannot modify global layout settings such as content width, container padding, and widget gaps (the default space between widgets)
48
49 **Note**: Angie can adjust all of these layout properties at the container or page level - just not site-wide.`;
50 function addKitDescriptionResource(server) {
51 server.registerResource("elementor-kit-server-description", KIT_DESCRIPTION_URI, {
52 title: "Elementor Kit Server Description",
53 description: "Elementor Kit capabilities and limitations",
54 mimeType: "text/plain"
55 }, async (uri) => ({ contents: [{
56 uri: uri.href,
57 mimeType: "text/plain",
58 text: KIT_DESCRIPTION
59 }] }));
60 }
61
62 //#endregion
63 //#region packages/packages/core/elementor-kit-mcp/src/elementor-kit-mcp-server.ts
64 var RESOURCE_NAME_KIT_FONTS = "elementor-kit-fonts";
65 var RESOURCE_URI_KIT_FONTS = "elementor://kit/fonts";
66 var RESOURCE_NAME_KIT_SCHEMA = "elementor-kit-schema";
67 var RESOURCE_URI_KIT_SCHEMA_TEMPLATE = "elementor://kit/schema/{tab}";
68 var RESOURCE_NAME_KIT_SETTINGS = "elementor-kit-settings";
69 var RESOURCE_URI_KIT_SETTINGS = "elementor://kit/settings";
70 var VERSION = "2.0.0";
71 async function fetchKitFonts() {
72 return (0, _elementor_elementor_mcp_common.callWpApi)(`/angie/v1/elementor-kit/fonts`, "GET");
73 }
74 async function fetchKitSchema() {
75 return (0, _elementor_elementor_mcp_common.callWpApi)(`/angie/v1/elementor-kit/schema`, "GET");
76 }
77 async function fetchKitSettings() {
78 return (0, _elementor_elementor_mcp_common.callWpApi)(`/angie/v1/elementor-kit`, "GET");
79 }
80 async function validateFonts(systemTypography, customTypography) {
81 const fontsResponse = await fetchKitFonts();
82 const availableFonts = Object.keys(fontsResponse.data.fonts || {});
83 const invalidFonts = [];
84 [systemTypography, customTypography].forEach((typography) => {
85 if (typography) typography.forEach((item) => {
86 if (item.typography_font_family && !availableFonts.includes(item.typography_font_family)) invalidFonts.push(item.typography_font_family);
87 });
88 });
89 if (invalidFonts.length > 0) return `Please use available fonts only. Invalid fonts: ${invalidFonts.join(", ")}. Available fonts: ${availableFonts.join(", ")}`;
90 return "";
91 }
92 function sanitizeMediaFields(obj) {
93 const mediaFields = ["site_logo", "site_icon"];
94 const sanitized = { ...obj };
95 for (const field of mediaFields) if (field in sanitized && sanitized[field] === "") sanitized[field] = 0;
96 return sanitized;
97 }
98 var baseColorSchema = _elementor_schema.z.object({
99 title: _elementor_schema.z.string(),
100 color: _elementor_schema.z.string()
101 });
102 var baseTypographySchema = _elementor_schema.z.object({
103 title: _elementor_schema.z.string(),
104 typography_typography: _elementor_schema.z.string(),
105 typography_font_family: _elementor_schema.z.string().describe("Font family name that must be from the available Elementor fonts list. Use the get-fonts endpoint (/angie/v1/elementor-kit/fonts) to get the complete list of available fonts. Only use fonts that exist in this list to avoid validation errors."),
106 typography_font_weight: _elementor_schema.z.string(),
107 typography_font_size: _elementor_schema.z.object({
108 unit: _elementor_schema.z.string(),
109 size: _elementor_schema.z.number()
110 }).optional(),
111 typography_font_size_tablet: _elementor_schema.z.object({
112 unit: _elementor_schema.z.string(),
113 size: _elementor_schema.z.number()
114 }).optional(),
115 typography_font_size_mobile: _elementor_schema.z.object({
116 unit: _elementor_schema.z.string(),
117 size: _elementor_schema.z.number()
118 }).optional(),
119 typography_line_height: _elementor_schema.z.object({
120 unit: _elementor_schema.z.string(),
121 size: _elementor_schema.z.number()
122 }).optional()
123 }).passthrough();
124 var systemColorItemSchema = baseColorSchema.extend({ _id: _elementor_schema.z.enum([
125 "primary",
126 "secondary",
127 "text",
128 "accent"
129 ]) });
130 var systemTypographyItemSchema = baseTypographySchema.extend({ _id: _elementor_schema.z.enum([
131 "primary",
132 "secondary",
133 "text",
134 "accent"
135 ]) });
136 var customColorItemSchema = baseColorSchema.extend({ _id: _elementor_schema.z.string() });
137 var customTypographyItemSchema = baseTypographySchema.extend({ _id: _elementor_schema.z.string() });
138 var systemColorsSchema = _elementor_schema.z.array(systemColorItemSchema).length(4);
139 var systemTypographySchema = _elementor_schema.z.array(systemTypographyItemSchema).length(4);
140 var customColorsSchema = _elementor_schema.z.array(customColorItemSchema);
141 var customTypographySchema = _elementor_schema.z.array(customTypographyItemSchema);
142 var generalPatchSchema = _elementor_schema.z.record(_elementor_schema.z.unknown()).describe("General patch object for any other Elementor kit settings like spacing, buttons, forms, layout settings, etc.");
143 var SERVER_INSTRUCTIONS = "Manages Elementor global design system: colors, typography, and site identity.";
144 async function createElementorKitServer() {
145 await (0, _elementor_elementor_mcp_common.waitForElementorEditor)();
146 const server = new _elementor_editor_mcp.McpServer({
147 name: "elementor-kit-server",
148 version: VERSION,
149 title: "Elementor Kit"
150 }, {
151 instructions: SERVER_INSTRUCTIONS,
152 capabilities: { resources: { subscribe: true } }
153 });
154 addKitDescriptionResource(server);
155 const getAvailableTabs = async () => {
156 const kitSchema = await fetchKitSchema();
157 return Object.keys(kitSchema.data || {});
158 };
159 server.registerResource(RESOURCE_NAME_KIT_FONTS, RESOURCE_URI_KIT_FONTS, {
160 title: "Elementor Kit Available Fonts",
161 description: "Complete list of all available font families that can be used in Elementor, including system fonts, Google fonts, and custom uploaded fonts"
162 }, async (uri) => {
163 const fontsResponse = await fetchKitFonts();
164 return { contents: [{
165 uri: uri.href,
166 mimeType: "application/json",
167 text: JSON.stringify(fontsResponse, null, 2)
168 }] };
169 });
170 server.registerResource(RESOURCE_NAME_KIT_SETTINGS, RESOURCE_URI_KIT_SETTINGS, {
171 title: "Elementor Kit Current Settings",
172 description: "Complete current Elementor global kit configuration including all system and custom colors, typography settings, spacing, buttons, forms, and other site-wide design settings"
173 }, async (uri) => {
174 const currentSettings = await fetchKitSettings();
175 return { contents: [{
176 uri: uri.href,
177 mimeType: "application/json",
178 text: JSON.stringify(currentSettings, null, 2)
179 }] };
180 });
181 server.registerResource(RESOURCE_NAME_KIT_SCHEMA, new _elementor_editor_mcp.ResourceTemplate(RESOURCE_URI_KIT_SCHEMA_TEMPLATE, { list: async () => {
182 return { resources: (await getAvailableTabs()).map((tab) => {
183 return {
184 uri: `elementor://kit/schema/${tab}`,
185 name: `${RESOURCE_NAME_KIT_SCHEMA}-${tab}`,
186 title: `Elementor Kit Schema - ${tab}`,
187 description: `Schema definition for Elementor kit ${tab} settings tab`,
188 mimeType: "application/json"
189 };
190 }) };
191 } }), {
192 title: "Elementor Kit Schema",
193 description: "Complete schema definition for a specific Elementor kit settings tab, showing all available fields, their types, valid values, and configuration options"
194 }, async (uri, variables) => {
195 const tab = Array.isArray(variables.tab) ? variables.tab[0] : variables.tab;
196 if (!tab) throw new Error("Tab parameter is required");
197 const kitSchema = await fetchKitSchema();
198 const tabSchema = kitSchema.data?.[tab];
199 if (!tabSchema) throw new Error(`No schema found for tab '${tab}'. Available tabs: ${Object.keys(kitSchema.data).join(", ")}`);
200 return { contents: [{
201 uri: uri.toString(),
202 mimeType: "application/json",
203 text: JSON.stringify(tabSchema, null, 2)
204 }] };
205 });
206 server.registerTool("update-elementor-kit-settings-colors-and-fonts", {
207 description: `This tool applies configuration changes to Elementor global kit settings that control site-wide design elements. Use this when you need to modify global colors, typography, spacing, buttons, form fields, or other theme-wide settings that affect the entire website appearance.
208
209 The tool will permanently update the site's global design settings and return a success confirmation with the updated configuration data.`,
210 inputSchema: {
211 systemColors: systemColorsSchema.optional().nullable().describe("System colors array with exactly 4 items having IDs: primary, secondary, text, accent"),
212 systemTypography: systemTypographySchema.optional().nullable().describe("System typography array with exactly 4 items having IDs: primary, secondary, text, accent"),
213 customColors: customColorsSchema.optional().nullable().describe("Custom colors array - flexible structure for additional color definitions"),
214 customTypography: customTypographySchema.optional().nullable().describe("Custom typography array - flexible structure for additional font definitions (no color field needed)"),
215 patchObject: generalPatchSchema.optional().nullable().describe("General patch object for any other Elementor kit settings like spacing, buttons, forms, layout settings, etc."),
216 confirmationMessage: _elementor_schema.z.string().describe("REQUIRED: Provide a clear explanation in **markdown format** of what Elementor kit settings will be changed and their potential impact on the site's global design. This message will be shown to the user before proceeding. Be specific about which design elements are being modified (colors, typography, spacing, etc.) and how they will affect the entire website. Examples: \"You're about to update the global **primary color** from `blue` to `green`. This will change **buttons**, **links**, and **accent colors** throughout your entire site.\" or \"You're about to change the **primary font** from `Roboto` to `Open Sans`. This will affect **headings** across all pages.\"")
217 },
218 annotations: {
219 title: "Update Elementor Kit Settings",
220 destructiveHint: true
221 },
222 _meta: { "angie/requiredResources": [{
223 uri: KIT_DESCRIPTION_URI,
224 whenToUse: "Read first for kit capabilities and limitations"
225 }] }
226 }, async ({ systemColors, systemTypography, customColors, customTypography, patchObject, confirmationMessage }) => {
227 (0, _elementor_elementor_mcp_common.requireConfirmationMessage)(confirmationMessage, "Elementor kit settings");
228 const invalidFonts = await validateFonts(systemTypography, customTypography);
229 if (invalidFonts) throw new Error(invalidFonts);
230 const completePatchObject = {
231 ...systemColors && { system_colors: systemColors },
232 ...systemTypography && { system_typography: systemTypography },
233 ...customColors && { custom_colors: customColors },
234 ...customTypography && { custom_typography: customTypography },
235 ...sanitizeMediaFields(patchObject || {})
236 };
237 if (Object.keys(completePatchObject).length === 0) throw new Error("At least one update must be provided (systemColors, systemTypography, customColors, customTypography, or patchObject)");
238 const response = await (0, _elementor_elementor_mcp_common.callWpApi)(`/angie/v1/elementor-kit`, "POST", completePatchObject);
239 return { content: [{
240 type: "text",
241 text: JSON.stringify({
242 success: true,
243 message: "Settings updated successfully",
244 data: response,
245 appliedSettings: completePatchObject
246 }, null, 2)
247 }] };
248 });
249 const sdk = (0, _elementor_editor_mcp.getAngieSdk)();
250 await sdk.waitForReady();
251 sdk.registerLocalServer({
252 server,
253 version: VERSION,
254 description: SERVER_INSTRUCTIONS,
255 name: "elementor-kit-server"
256 });
257 return server;
258 }
259
260 //#endregion
261 //#region packages/packages/core/elementor-kit-mcp/src/init.ts
262 function init() {
263 createElementorKitServer();
264 }
265
266 //#endregion
267 //#region packages/packages/core/elementor-kit-mcp/src/index.ts
268 var src_exports = /* @__PURE__ */ __exportAll({
269 createElementorKitServer: () => createElementorKitServer,
270 init: () => init
271 });
272
273 //#endregion
274 //#region \0elementor-package-library-entry
275 (window.elementorV2 = window.elementorV2 || {}).elementorKitMcp = src_exports;
276
277 //#endregion
278 })(elementorV2.editorMcp, elementorV2.elementorMcpCommon, elementorV2.schema);
279 window.elementorV2.elementorKitMcp?.init?.();
280 //# sourceMappingURL=elementor-kit-mcp.js.map