@yashwant.dharmdas/elementor-mcp 3.7.0 → 3.8.0
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.js +36 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -227,6 +227,42 @@ function createMcpServer(sites) {
|
|
|
227
227
|
return { content: [{ type: "text", text: `Error: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
|
+
server.tool("set-element-link", "Set, replace, or clear the link on any Elementor widget that has a link (button, heading, image, icon-box, etc.). Updates the NATIVE Elementor link object (url + is_external + nofollow + custom_attributes) — exactly the same fields the editor writes when you set a link in the UI. Use this instead of patch-data or merge-element-settings for any link change; it guarantees 'Open in new tab' uses the native Elementor toggle (is_external) and not a fake HTML attribute.", {
|
|
231
|
+
page_id: z.string().describe("WordPress Page ID"),
|
|
232
|
+
element_id: z.string().describe("Elementor Element ID of the widget whose link you want to change"),
|
|
233
|
+
url: z.string().optional().describe("URL to set, e.g. 'https://example.com'. Required unless clear=true."),
|
|
234
|
+
open_in_new_tab: z.boolean().optional().describe("Native Elementor 'Open in new window' toggle. Maps to link.is_external = 'on'."),
|
|
235
|
+
nofollow: z.boolean().optional().describe("Native Elementor 'Add nofollow' toggle. Maps to link.nofollow = 'on'."),
|
|
236
|
+
custom_attributes: z.string().optional().describe("Custom HTML link attributes, Elementor format: 'key|value,key|value'."),
|
|
237
|
+
clear: z.boolean().optional().describe("Set true to remove the link entirely (url='' and all flags reset)."),
|
|
238
|
+
link_field: z.string().optional().describe("Settings key holding the link object. Default 'link'. Override only for non-standard widgets."),
|
|
239
|
+
site: siteParam,
|
|
240
|
+
}, async ({ page_id, element_id, url, open_in_new_tab, nofollow, custom_attributes, clear, link_field, site }) => {
|
|
241
|
+
try {
|
|
242
|
+
if (!clear && (url === undefined || url === null || String(url).trim() === "")) {
|
|
243
|
+
return { content: [{ type: "text", text: "Provide a non-empty url, OR set clear=true to remove the link." }], isError: true };
|
|
244
|
+
}
|
|
245
|
+
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
246
|
+
const body = {};
|
|
247
|
+
if (url !== undefined)
|
|
248
|
+
body.url = url;
|
|
249
|
+
if (open_in_new_tab !== undefined)
|
|
250
|
+
body.open_in_new_tab = open_in_new_tab;
|
|
251
|
+
if (nofollow !== undefined)
|
|
252
|
+
body.nofollow = nofollow;
|
|
253
|
+
if (custom_attributes !== undefined)
|
|
254
|
+
body.custom_attributes = custom_attributes;
|
|
255
|
+
if (clear !== undefined)
|
|
256
|
+
body.clear = clear;
|
|
257
|
+
if (link_field !== undefined)
|
|
258
|
+
body.link_field = link_field;
|
|
259
|
+
const r = await axios.post(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/elements/${element_id}/link`, body, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
|
|
260
|
+
return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
return { content: [{ type: "text", text: `Error setting element link: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
264
|
+
}
|
|
265
|
+
});
|
|
230
266
|
server.tool("merge-element-settings", "Deep-merge settings into a specific Elementor element without replacing the full element. Use for small setting adjustments.", {
|
|
231
267
|
page_id: z.string().describe("WordPress Page ID"),
|
|
232
268
|
element_id: z.string().describe("Elementor Element ID"),
|
package/package.json
CHANGED