@elementor/elementor-v3-mcp 4.2.0-906 → 4.2.0-908

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/dist/index.mjs CHANGED
@@ -3,74 +3,6 @@ import { getAngieSdk } from "@elementor/editor-mcp";
3
3
  import { waitForElementorEditor } from "@elementor/elementor-mcp-common";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
 
6
- // src/mcp-description-resource.ts
7
- var V3_DESCRIPTION_URI = "elementor://elementor/server-description";
8
- var V3_DESCRIPTION = `## Elementor Page Builder
9
-
10
- ### Capabilities:
11
- **Page Management:**
12
- - Manage page settings, saving and routing pages
13
- - Control the editor UI, including switching between desktop, tablet, and mobile views
14
-
15
- **Global Styles:**
16
- - Work with global styles, helping manage shared design settings like colors and fonts across the site
17
-
18
- **AI-Powered Content Creation:**
19
- - Generate and edit text and insert it into the page
20
- - Generate images and place them on the canvas
21
-
22
- **Custom Styling & Code:**
23
- - Apply custom CSS to elements
24
- - Generate supported code snippets
25
-
26
- ### Limitations:
27
- **Element Management (Not Supported):**
28
- - Cannot create or edit individual Elementor elements such as widgets or containers
29
- - Cannot build page layouts or create containers
30
- - Cannot modify widget-level settings
31
- - Cannot apply motion effects
32
- - Cannot reorder sections or perform detailed canvas-level edits
33
- - Cannot create fully designed or polished pages
34
- - Cannot fully resolve responsiveness issues
35
- - Support for these editor-level capabilities is planned for Editor V4
36
-
37
- **Theme Builder:**
38
- - Cannot create or manage Theme Builder templates, including headers, footers, single posts, archives, products, loop items, or 404 pages
39
- - Cannot set display conditions for templates
40
- - Cannot configure popup triggers and advanced rules
41
-
42
- **System Settings:**
43
- - Cannot change Elementor system-level settings
44
- - Cannot activate or work with Editor V4
45
- - Cannot manage form submissions
46
- - Cannot add custom fonts or icons
47
- - Cannot manage user roles
48
- - Cannot roll back Elementor versions
49
- - Cannot place the site in maintenance mode
50
- - Cannot export the website
51
- - Cannot apply full website templates
52
-
53
- **Code & Widgets:**
54
- - Cannot register PHP code or create new custom widgets, though Angie may provide guidance, code snippets, or plugin suggestions where helpful
55
-
56
- **Note**: While page names can include terms like "header" or "footer", these won't function as actual theme parts without Theme Builder access.
57
-
58
- **Important**: When users ask "What can Angie do?" or similar questions about Angie's general capabilities, use the \`what-can-angie-do\` tool from the knowledge MCP server instead of generating your own response.`;
59
- function addV3DescriptionResource(server) {
60
- server.registerResource(
61
- "elementor-v3-server-description",
62
- V3_DESCRIPTION_URI,
63
- {
64
- title: "Elementor V3 Server Description",
65
- description: "Elementor V3 MCP capabilities and limitations",
66
- mimeType: "text/plain"
67
- },
68
- async (uri) => ({
69
- contents: [{ uri: uri.href, mimeType: "text/plain", text: V3_DESCRIPTION }]
70
- })
71
- );
72
- }
73
-
74
6
  // src/resources.ts
75
7
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
76
8
 
@@ -78,6 +10,9 @@ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
78
10
  var getElementor = () => window.elementor;
79
11
  var get$e = () => window.$e;
80
12
  var getElementorCommon = () => window.elementorCommon;
13
+ function getCurrentSelection() {
14
+ return Object.keys(getElementor()?.selection?.elements || {});
15
+ }
81
16
  function encodeToolJson(data) {
82
17
  return JSON.stringify(data).replaceAll('"', "'");
83
18
  }
@@ -169,6 +104,61 @@ function loadDocumentSchema(documentId) {
169
104
  return getDocumentSchema(documentId);
170
105
  }
171
106
 
107
+ // src/get-current-editor-selection.ts
108
+ var ELEMENT_TYPE_LABELS = {
109
+ container: "Container",
110
+ section: "Section"
111
+ };
112
+ function getEditorPageTitle() {
113
+ const title = getElementor()?.documents?.getCurrent()?.config?.settings?.settings?.post_title;
114
+ return title || "Untitled";
115
+ }
116
+ function getElementDisplayName(container) {
117
+ if (container.label) {
118
+ return container.label;
119
+ }
120
+ const widgetType = container.model?.attributes?.widgetType ?? container.model?.widgetType;
121
+ if (widgetType) {
122
+ return widgetType.charAt(0).toUpperCase() + widgetType.slice(1).replace(/-/g, " ");
123
+ }
124
+ return ELEMENT_TYPE_LABELS[container.type ?? ""] ?? `Element ${container.id}`;
125
+ }
126
+ function getCurrentEditorSelection() {
127
+ const elementor = getElementor();
128
+ if (!elementor?.documents?.getCurrent) {
129
+ return { error: "Elementor is not available" };
130
+ }
131
+ const document = elementor.documents.getCurrent();
132
+ if (!document) {
133
+ return { error: "No active document found" };
134
+ }
135
+ const pageTitle = getEditorPageTitle();
136
+ const primaryId = getCurrentSelection()[0];
137
+ const container = primaryId ? elementor.getContainer(primaryId) : null;
138
+ const base = {
139
+ displayName: pageTitle,
140
+ documentId: document.id,
141
+ pageTitle,
142
+ selectedElementId: null,
143
+ selectedParentId: null,
144
+ selectedWidgetType: null,
145
+ selectedElementType: null
146
+ };
147
+ if (!container?.id) {
148
+ return base;
149
+ }
150
+ const widgetType = container.model?.attributes?.widgetType ?? null;
151
+ const elementType = container.type ?? container.model?.attributes?.elType ?? "widget";
152
+ return {
153
+ ...base,
154
+ displayName: `${pageTitle} > ${getElementDisplayName(container)}`,
155
+ selectedElementId: container.id,
156
+ selectedParentId: container.parent?.id ?? null,
157
+ selectedWidgetType: widgetType,
158
+ selectedElementType: elementType
159
+ };
160
+ }
161
+
172
162
  // src/resources.ts
173
163
  var RESOURCE_NAME_ELEMENT_SETTINGS = "elementor-element-settings";
174
164
  var RESOURCE_URI_ELEMENT_SETTINGS_TEMPLATE = "elementor://editor/element-settings/{elementId}";
@@ -176,6 +166,8 @@ var RESOURCE_NAME_WIDGET_CONFIG = "elementor-widget-config";
176
166
  var RESOURCE_URI_WIDGET_CONFIG_TEMPLATE = "elementor://editor/widget-config/{widgetType}";
177
167
  var RESOURCE_NAME_PAGE_SETTINGS = "elementor-page-settings";
178
168
  var RESOURCE_URI_PAGE_SETTINGS = "elementor://editor/page-settings";
169
+ var RESOURCE_NAME_CURRENT_CONTEXT = "elementor-current-context";
170
+ var RESOURCE_URI_CURRENT_CONTEXT = "elementor://context/current-page";
179
171
  function decodeResourceVariable(value) {
180
172
  try {
181
173
  let decoded = decodeURIComponent(value).replace(/[·]/g, "");
@@ -291,6 +283,133 @@ function addElementorResources(server) {
291
283
  };
292
284
  }
293
285
  );
286
+ server.resource(
287
+ RESOURCE_NAME_CURRENT_CONTEXT,
288
+ RESOURCE_URI_CURRENT_CONTEXT,
289
+ {
290
+ description: 'Current Elementor editor focus: which page the user is working on and which element (if any) is selected. Returns displayName formatted as "<PageTitle>" or "<PageTitle> > <ElementName>", plus documentId, selectedElementId, selectedParentId, selectedWidgetType, and selectedElementType.'
291
+ },
292
+ async (uri) => {
293
+ const snapshot = getCurrentEditorSelection();
294
+ if ("error" in snapshot) {
295
+ throw new Error(snapshot.error);
296
+ }
297
+ return {
298
+ contents: [
299
+ {
300
+ uri: uri.toString(),
301
+ mimeType: "application/json",
302
+ text: JSON.stringify(snapshot)
303
+ }
304
+ ]
305
+ };
306
+ }
307
+ );
308
+ }
309
+
310
+ // src/editor-selection-listener.ts
311
+ var SELECTION_COMMANDS = /* @__PURE__ */ new Set([
312
+ "document/elements/select",
313
+ "document/elements/deselect",
314
+ "document/elements/deselect-all",
315
+ "document/elements/toggle-selection",
316
+ "document/elements/select-all",
317
+ "editor/documents/switch"
318
+ ]);
319
+ var DEBOUNCE_MS = 50;
320
+ var COMMAND_EVENT_NAME = "elementor/commands/run/after";
321
+ function setupEditorSelectionListener(server) {
322
+ let debounceTimer = null;
323
+ const sendUpdate = () => {
324
+ void server.server.sendResourceUpdated({ uri: RESOURCE_URI_CURRENT_CONTEXT }).catch((error) => {
325
+ const isSafeError = error?.message?.includes("Not connected") || error?.message?.includes("does not support notifying about resources");
326
+ if (!isSafeError) {
327
+ throw error;
328
+ }
329
+ });
330
+ };
331
+ const handleCommandRun = (event) => {
332
+ if (!(event instanceof CustomEvent)) {
333
+ return;
334
+ }
335
+ const command = event.detail?.command;
336
+ if (!command || !SELECTION_COMMANDS.has(command)) {
337
+ return;
338
+ }
339
+ if (debounceTimer) {
340
+ clearTimeout(debounceTimer);
341
+ }
342
+ debounceTimer = setTimeout(sendUpdate, DEBOUNCE_MS);
343
+ };
344
+ window.addEventListener(COMMAND_EVENT_NAME, handleCommandRun);
345
+ }
346
+
347
+ // src/mcp-description-resource.ts
348
+ var V3_DESCRIPTION_URI = "elementor://elementor/server-description";
349
+ var V3_DESCRIPTION = `## Elementor Page Builder
350
+
351
+ ### Capabilities:
352
+ **Page Management:**
353
+ - Manage page settings, saving and routing pages
354
+ - Control the editor UI, including switching between desktop, tablet, and mobile views
355
+
356
+ **Global Styles:**
357
+ - Work with global styles, helping manage shared design settings like colors and fonts across the site
358
+
359
+ **AI-Powered Content Creation:**
360
+ - Generate and edit text and insert it into the page
361
+ - Generate images and place them on the canvas
362
+
363
+ **Custom Styling & Code:**
364
+ - Apply custom CSS to elements
365
+ - Generate supported code snippets
366
+
367
+ ### Limitations:
368
+ **Element Management (Not Supported):**
369
+ - Cannot create or edit individual Elementor elements such as widgets or containers
370
+ - Cannot build page layouts or create containers
371
+ - Cannot modify widget-level settings
372
+ - Cannot apply motion effects
373
+ - Cannot reorder sections or perform detailed canvas-level edits
374
+ - Cannot create fully designed or polished pages
375
+ - Cannot fully resolve responsiveness issues
376
+ - Support for these editor-level capabilities is planned for Editor V4
377
+
378
+ **Theme Builder:**
379
+ - Cannot create or manage Theme Builder templates, including headers, footers, single posts, archives, products, loop items, or 404 pages
380
+ - Cannot set display conditions for templates
381
+ - Cannot configure popup triggers and advanced rules
382
+
383
+ **System Settings:**
384
+ - Cannot change Elementor system-level settings
385
+ - Cannot activate or work with Editor V4
386
+ - Cannot manage form submissions
387
+ - Cannot add custom fonts or icons
388
+ - Cannot manage user roles
389
+ - Cannot roll back Elementor versions
390
+ - Cannot place the site in maintenance mode
391
+ - Cannot export the website
392
+ - Cannot apply full website templates
393
+
394
+ **Code & Widgets:**
395
+ - Cannot register PHP code or create new custom widgets, though Angie may provide guidance, code snippets, or plugin suggestions where helpful
396
+
397
+ **Note**: While page names can include terms like "header" or "footer", these won't function as actual theme parts without Theme Builder access.
398
+
399
+ **Important**: When users ask "What can Angie do?" or similar questions about Angie's general capabilities, use the \`what-can-angie-do\` tool from the knowledge MCP server instead of generating your own response.`;
400
+ function addV3DescriptionResource(server) {
401
+ server.registerResource(
402
+ "elementor-v3-server-description",
403
+ V3_DESCRIPTION_URI,
404
+ {
405
+ title: "Elementor V3 Server Description",
406
+ description: "Elementor V3 MCP capabilities and limitations",
407
+ mimeType: "text/plain"
408
+ },
409
+ async (uri) => ({
410
+ contents: [{ uri: uri.href, mimeType: "text/plain", text: V3_DESCRIPTION }]
411
+ })
412
+ );
294
413
  }
295
414
 
296
415
  // src/tools/ai-tool.ts
@@ -1079,6 +1198,7 @@ async function createElementorServer() {
1079
1198
  addRoutesTool(server);
1080
1199
  addAiTool(server);
1081
1200
  addStylingTool(server);
1201
+ setupEditorSelectionListener(server);
1082
1202
  const sdk = getAngieSdk();
1083
1203
  await sdk.waitForReady();
1084
1204
  sdk.registerLocalServer({ server, version: VERSION, description: V3_DESCRIPTION, name: "Elementor" });