@elementor/elementor-v3-mcp 4.2.0-907 → 4.2.0-909
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.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +188 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/editor-selection-listener.ts +47 -0
- package/src/elementor-mcp-server.ts +3 -0
- package/src/get-current-editor-selection.ts +75 -0
- package/src/resources.ts +32 -0
- package/src/types.ts +3 -0
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,8 @@ type McpToolResult = {
|
|
|
21
21
|
};
|
|
22
22
|
interface ElementorContainer {
|
|
23
23
|
id: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
type?: string;
|
|
24
26
|
model: {
|
|
25
27
|
id: string;
|
|
26
28
|
attributes?: Record<string, unknown>;
|
|
@@ -28,6 +30,7 @@ interface ElementorContainer {
|
|
|
28
30
|
title?: string;
|
|
29
31
|
};
|
|
30
32
|
get?: (key: string) => unknown;
|
|
33
|
+
widgetType?: string;
|
|
31
34
|
};
|
|
32
35
|
settings: {
|
|
33
36
|
attributes?: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ type McpToolResult = {
|
|
|
21
21
|
};
|
|
22
22
|
interface ElementorContainer {
|
|
23
23
|
id: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
type?: string;
|
|
24
26
|
model: {
|
|
25
27
|
id: string;
|
|
26
28
|
attributes?: Record<string, unknown>;
|
|
@@ -28,6 +30,7 @@ interface ElementorContainer {
|
|
|
28
30
|
title?: string;
|
|
29
31
|
};
|
|
30
32
|
get?: (key: string) => unknown;
|
|
33
|
+
widgetType?: string;
|
|
31
34
|
};
|
|
32
35
|
settings: {
|
|
33
36
|
attributes?: Record<string, unknown>;
|
package/dist/index.js
CHANGED
|
@@ -36,74 +36,6 @@ var import_editor_mcp = require("@elementor/editor-mcp");
|
|
|
36
36
|
var import_elementor_mcp_common = require("@elementor/elementor-mcp-common");
|
|
37
37
|
var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
38
38
|
|
|
39
|
-
// src/mcp-description-resource.ts
|
|
40
|
-
var V3_DESCRIPTION_URI = "elementor://elementor/server-description";
|
|
41
|
-
var V3_DESCRIPTION = `## Elementor Page Builder
|
|
42
|
-
|
|
43
|
-
### Capabilities:
|
|
44
|
-
**Page Management:**
|
|
45
|
-
- Manage page settings, saving and routing pages
|
|
46
|
-
- Control the editor UI, including switching between desktop, tablet, and mobile views
|
|
47
|
-
|
|
48
|
-
**Global Styles:**
|
|
49
|
-
- Work with global styles, helping manage shared design settings like colors and fonts across the site
|
|
50
|
-
|
|
51
|
-
**AI-Powered Content Creation:**
|
|
52
|
-
- Generate and edit text and insert it into the page
|
|
53
|
-
- Generate images and place them on the canvas
|
|
54
|
-
|
|
55
|
-
**Custom Styling & Code:**
|
|
56
|
-
- Apply custom CSS to elements
|
|
57
|
-
- Generate supported code snippets
|
|
58
|
-
|
|
59
|
-
### Limitations:
|
|
60
|
-
**Element Management (Not Supported):**
|
|
61
|
-
- Cannot create or edit individual Elementor elements such as widgets or containers
|
|
62
|
-
- Cannot build page layouts or create containers
|
|
63
|
-
- Cannot modify widget-level settings
|
|
64
|
-
- Cannot apply motion effects
|
|
65
|
-
- Cannot reorder sections or perform detailed canvas-level edits
|
|
66
|
-
- Cannot create fully designed or polished pages
|
|
67
|
-
- Cannot fully resolve responsiveness issues
|
|
68
|
-
- Support for these editor-level capabilities is planned for Editor V4
|
|
69
|
-
|
|
70
|
-
**Theme Builder:**
|
|
71
|
-
- Cannot create or manage Theme Builder templates, including headers, footers, single posts, archives, products, loop items, or 404 pages
|
|
72
|
-
- Cannot set display conditions for templates
|
|
73
|
-
- Cannot configure popup triggers and advanced rules
|
|
74
|
-
|
|
75
|
-
**System Settings:**
|
|
76
|
-
- Cannot change Elementor system-level settings
|
|
77
|
-
- Cannot activate or work with Editor V4
|
|
78
|
-
- Cannot manage form submissions
|
|
79
|
-
- Cannot add custom fonts or icons
|
|
80
|
-
- Cannot manage user roles
|
|
81
|
-
- Cannot roll back Elementor versions
|
|
82
|
-
- Cannot place the site in maintenance mode
|
|
83
|
-
- Cannot export the website
|
|
84
|
-
- Cannot apply full website templates
|
|
85
|
-
|
|
86
|
-
**Code & Widgets:**
|
|
87
|
-
- Cannot register PHP code or create new custom widgets, though Angie may provide guidance, code snippets, or plugin suggestions where helpful
|
|
88
|
-
|
|
89
|
-
**Note**: While page names can include terms like "header" or "footer", these won't function as actual theme parts without Theme Builder access.
|
|
90
|
-
|
|
91
|
-
**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.`;
|
|
92
|
-
function addV3DescriptionResource(server) {
|
|
93
|
-
server.registerResource(
|
|
94
|
-
"elementor-v3-server-description",
|
|
95
|
-
V3_DESCRIPTION_URI,
|
|
96
|
-
{
|
|
97
|
-
title: "Elementor V3 Server Description",
|
|
98
|
-
description: "Elementor V3 MCP capabilities and limitations",
|
|
99
|
-
mimeType: "text/plain"
|
|
100
|
-
},
|
|
101
|
-
async (uri) => ({
|
|
102
|
-
contents: [{ uri: uri.href, mimeType: "text/plain", text: V3_DESCRIPTION }]
|
|
103
|
-
})
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
39
|
// src/resources.ts
|
|
108
40
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
109
41
|
|
|
@@ -111,6 +43,9 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
111
43
|
var getElementor = () => window.elementor;
|
|
112
44
|
var get$e = () => window.$e;
|
|
113
45
|
var getElementorCommon = () => window.elementorCommon;
|
|
46
|
+
function getCurrentSelection() {
|
|
47
|
+
return Object.keys(getElementor()?.selection?.elements || {});
|
|
48
|
+
}
|
|
114
49
|
function encodeToolJson(data) {
|
|
115
50
|
return JSON.stringify(data).replaceAll('"', "'");
|
|
116
51
|
}
|
|
@@ -202,6 +137,61 @@ function loadDocumentSchema(documentId) {
|
|
|
202
137
|
return getDocumentSchema(documentId);
|
|
203
138
|
}
|
|
204
139
|
|
|
140
|
+
// src/get-current-editor-selection.ts
|
|
141
|
+
var ELEMENT_TYPE_LABELS = {
|
|
142
|
+
container: "Container",
|
|
143
|
+
section: "Section"
|
|
144
|
+
};
|
|
145
|
+
function getEditorPageTitle() {
|
|
146
|
+
const title = getElementor()?.documents?.getCurrent()?.config?.settings?.settings?.post_title;
|
|
147
|
+
return title || "Untitled";
|
|
148
|
+
}
|
|
149
|
+
function getElementDisplayName(container) {
|
|
150
|
+
if (container.label) {
|
|
151
|
+
return container.label;
|
|
152
|
+
}
|
|
153
|
+
const widgetType = container.model?.attributes?.widgetType ?? container.model?.widgetType;
|
|
154
|
+
if (widgetType) {
|
|
155
|
+
return widgetType.charAt(0).toUpperCase() + widgetType.slice(1).replace(/-/g, " ");
|
|
156
|
+
}
|
|
157
|
+
return ELEMENT_TYPE_LABELS[container.type ?? ""] ?? `Element ${container.id}`;
|
|
158
|
+
}
|
|
159
|
+
function getCurrentEditorSelection() {
|
|
160
|
+
const elementor = getElementor();
|
|
161
|
+
if (!elementor?.documents?.getCurrent) {
|
|
162
|
+
return { error: "Elementor is not available" };
|
|
163
|
+
}
|
|
164
|
+
const document = elementor.documents.getCurrent();
|
|
165
|
+
if (!document) {
|
|
166
|
+
return { error: "No active document found" };
|
|
167
|
+
}
|
|
168
|
+
const pageTitle = getEditorPageTitle();
|
|
169
|
+
const primaryId = getCurrentSelection()[0];
|
|
170
|
+
const container = primaryId ? elementor.getContainer(primaryId) : null;
|
|
171
|
+
const base = {
|
|
172
|
+
displayName: pageTitle,
|
|
173
|
+
documentId: document.id,
|
|
174
|
+
pageTitle,
|
|
175
|
+
selectedElementId: null,
|
|
176
|
+
selectedParentId: null,
|
|
177
|
+
selectedWidgetType: null,
|
|
178
|
+
selectedElementType: null
|
|
179
|
+
};
|
|
180
|
+
if (!container?.id) {
|
|
181
|
+
return base;
|
|
182
|
+
}
|
|
183
|
+
const widgetType = container.model?.attributes?.widgetType ?? null;
|
|
184
|
+
const elementType = container.type ?? container.model?.attributes?.elType ?? "widget";
|
|
185
|
+
return {
|
|
186
|
+
...base,
|
|
187
|
+
displayName: `${pageTitle} > ${getElementDisplayName(container)}`,
|
|
188
|
+
selectedElementId: container.id,
|
|
189
|
+
selectedParentId: container.parent?.id ?? null,
|
|
190
|
+
selectedWidgetType: widgetType,
|
|
191
|
+
selectedElementType: elementType
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
205
195
|
// src/resources.ts
|
|
206
196
|
var RESOURCE_NAME_ELEMENT_SETTINGS = "elementor-element-settings";
|
|
207
197
|
var RESOURCE_URI_ELEMENT_SETTINGS_TEMPLATE = "elementor://editor/element-settings/{elementId}";
|
|
@@ -209,6 +199,8 @@ var RESOURCE_NAME_WIDGET_CONFIG = "elementor-widget-config";
|
|
|
209
199
|
var RESOURCE_URI_WIDGET_CONFIG_TEMPLATE = "elementor://editor/widget-config/{widgetType}";
|
|
210
200
|
var RESOURCE_NAME_PAGE_SETTINGS = "elementor-page-settings";
|
|
211
201
|
var RESOURCE_URI_PAGE_SETTINGS = "elementor://editor/page-settings";
|
|
202
|
+
var RESOURCE_NAME_CURRENT_CONTEXT = "elementor-current-context";
|
|
203
|
+
var RESOURCE_URI_CURRENT_CONTEXT = "elementor://context/current-page";
|
|
212
204
|
function decodeResourceVariable(value) {
|
|
213
205
|
try {
|
|
214
206
|
let decoded = decodeURIComponent(value).replace(/[·]/g, "");
|
|
@@ -324,6 +316,133 @@ function addElementorResources(server) {
|
|
|
324
316
|
};
|
|
325
317
|
}
|
|
326
318
|
);
|
|
319
|
+
server.resource(
|
|
320
|
+
RESOURCE_NAME_CURRENT_CONTEXT,
|
|
321
|
+
RESOURCE_URI_CURRENT_CONTEXT,
|
|
322
|
+
{
|
|
323
|
+
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.'
|
|
324
|
+
},
|
|
325
|
+
async (uri) => {
|
|
326
|
+
const snapshot = getCurrentEditorSelection();
|
|
327
|
+
if ("error" in snapshot) {
|
|
328
|
+
throw new Error(snapshot.error);
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
contents: [
|
|
332
|
+
{
|
|
333
|
+
uri: uri.toString(),
|
|
334
|
+
mimeType: "application/json",
|
|
335
|
+
text: JSON.stringify(snapshot)
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/editor-selection-listener.ts
|
|
344
|
+
var SELECTION_COMMANDS = /* @__PURE__ */ new Set([
|
|
345
|
+
"document/elements/select",
|
|
346
|
+
"document/elements/deselect",
|
|
347
|
+
"document/elements/deselect-all",
|
|
348
|
+
"document/elements/toggle-selection",
|
|
349
|
+
"document/elements/select-all",
|
|
350
|
+
"editor/documents/switch"
|
|
351
|
+
]);
|
|
352
|
+
var DEBOUNCE_MS = 50;
|
|
353
|
+
var COMMAND_EVENT_NAME = "elementor/commands/run/after";
|
|
354
|
+
function setupEditorSelectionListener(server) {
|
|
355
|
+
let debounceTimer = null;
|
|
356
|
+
const sendUpdate = () => {
|
|
357
|
+
void server.server.sendResourceUpdated({ uri: RESOURCE_URI_CURRENT_CONTEXT }).catch((error) => {
|
|
358
|
+
const isSafeError = error?.message?.includes("Not connected") || error?.message?.includes("does not support notifying about resources");
|
|
359
|
+
if (!isSafeError) {
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
const handleCommandRun = (event) => {
|
|
365
|
+
if (!(event instanceof CustomEvent)) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const command = event.detail?.command;
|
|
369
|
+
if (!command || !SELECTION_COMMANDS.has(command)) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (debounceTimer) {
|
|
373
|
+
clearTimeout(debounceTimer);
|
|
374
|
+
}
|
|
375
|
+
debounceTimer = setTimeout(sendUpdate, DEBOUNCE_MS);
|
|
376
|
+
};
|
|
377
|
+
window.addEventListener(COMMAND_EVENT_NAME, handleCommandRun);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// src/mcp-description-resource.ts
|
|
381
|
+
var V3_DESCRIPTION_URI = "elementor://elementor/server-description";
|
|
382
|
+
var V3_DESCRIPTION = `## Elementor Page Builder
|
|
383
|
+
|
|
384
|
+
### Capabilities:
|
|
385
|
+
**Page Management:**
|
|
386
|
+
- Manage page settings, saving and routing pages
|
|
387
|
+
- Control the editor UI, including switching between desktop, tablet, and mobile views
|
|
388
|
+
|
|
389
|
+
**Global Styles:**
|
|
390
|
+
- Work with global styles, helping manage shared design settings like colors and fonts across the site
|
|
391
|
+
|
|
392
|
+
**AI-Powered Content Creation:**
|
|
393
|
+
- Generate and edit text and insert it into the page
|
|
394
|
+
- Generate images and place them on the canvas
|
|
395
|
+
|
|
396
|
+
**Custom Styling & Code:**
|
|
397
|
+
- Apply custom CSS to elements
|
|
398
|
+
- Generate supported code snippets
|
|
399
|
+
|
|
400
|
+
### Limitations:
|
|
401
|
+
**Element Management (Not Supported):**
|
|
402
|
+
- Cannot create or edit individual Elementor elements such as widgets or containers
|
|
403
|
+
- Cannot build page layouts or create containers
|
|
404
|
+
- Cannot modify widget-level settings
|
|
405
|
+
- Cannot apply motion effects
|
|
406
|
+
- Cannot reorder sections or perform detailed canvas-level edits
|
|
407
|
+
- Cannot create fully designed or polished pages
|
|
408
|
+
- Cannot fully resolve responsiveness issues
|
|
409
|
+
- Support for these editor-level capabilities is planned for Editor V4
|
|
410
|
+
|
|
411
|
+
**Theme Builder:**
|
|
412
|
+
- Cannot create or manage Theme Builder templates, including headers, footers, single posts, archives, products, loop items, or 404 pages
|
|
413
|
+
- Cannot set display conditions for templates
|
|
414
|
+
- Cannot configure popup triggers and advanced rules
|
|
415
|
+
|
|
416
|
+
**System Settings:**
|
|
417
|
+
- Cannot change Elementor system-level settings
|
|
418
|
+
- Cannot activate or work with Editor V4
|
|
419
|
+
- Cannot manage form submissions
|
|
420
|
+
- Cannot add custom fonts or icons
|
|
421
|
+
- Cannot manage user roles
|
|
422
|
+
- Cannot roll back Elementor versions
|
|
423
|
+
- Cannot place the site in maintenance mode
|
|
424
|
+
- Cannot export the website
|
|
425
|
+
- Cannot apply full website templates
|
|
426
|
+
|
|
427
|
+
**Code & Widgets:**
|
|
428
|
+
- Cannot register PHP code or create new custom widgets, though Angie may provide guidance, code snippets, or plugin suggestions where helpful
|
|
429
|
+
|
|
430
|
+
**Note**: While page names can include terms like "header" or "footer", these won't function as actual theme parts without Theme Builder access.
|
|
431
|
+
|
|
432
|
+
**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.`;
|
|
433
|
+
function addV3DescriptionResource(server) {
|
|
434
|
+
server.registerResource(
|
|
435
|
+
"elementor-v3-server-description",
|
|
436
|
+
V3_DESCRIPTION_URI,
|
|
437
|
+
{
|
|
438
|
+
title: "Elementor V3 Server Description",
|
|
439
|
+
description: "Elementor V3 MCP capabilities and limitations",
|
|
440
|
+
mimeType: "text/plain"
|
|
441
|
+
},
|
|
442
|
+
async (uri) => ({
|
|
443
|
+
contents: [{ uri: uri.href, mimeType: "text/plain", text: V3_DESCRIPTION }]
|
|
444
|
+
})
|
|
445
|
+
);
|
|
327
446
|
}
|
|
328
447
|
|
|
329
448
|
// src/tools/ai-tool.ts
|
|
@@ -1112,6 +1231,7 @@ async function createElementorServer() {
|
|
|
1112
1231
|
addRoutesTool(server);
|
|
1113
1232
|
addAiTool(server);
|
|
1114
1233
|
addStylingTool(server);
|
|
1234
|
+
setupEditorSelectionListener(server);
|
|
1115
1235
|
const sdk = (0, import_editor_mcp.getAngieSdk)();
|
|
1116
1236
|
await sdk.waitForReady();
|
|
1117
1237
|
sdk.registerLocalServer({ server, version: VERSION, description: V3_DESCRIPTION, name: "Elementor" });
|