@yashwant.dharmdas/elementor-mcp 3.7.0 → 3.9.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.
Files changed (2) hide show
  1. package/dist/index.js +46 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -182,13 +182,20 @@ function createMcpServer(sites) {
182
182
  return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
183
183
  }
184
184
  });
185
- server.tool("get-data", "Get the full raw Elementor JSON element tree for a page (all elements with all settings). Use this before find-elements, patch-data, or any bulk transform.", {
185
+ server.tool("get-data", "Get the Elementor JSON for a page. **ALWAYS pass compact=true and strip_responsive=true for any page that isn't tiny** — this strips style/typography/spacing/responsive bulk and keeps only structure + content (60-80% smaller). Without compact, large pages will exceed Claude's tool-response size limit and get auto-saved to a file (forcing slow Python parsing). For surgical lookups (find one widget by type or condition) use find-elements instead it's even smaller and runs server-side.", {
186
186
  page_id: z.string().describe("WordPress Page ID"),
187
+ compact: z.boolean().optional().describe("Strip style/typography/spacing/empty fields. Use true unless you specifically need style data."),
188
+ strip_responsive: z.boolean().optional().describe("Also drop _tablet, _mobile, _laptop, _widescreen variants. Use true with compact=true."),
187
189
  site: siteParam,
188
- }, async ({ page_id, site }) => {
190
+ }, async ({ page_id, compact, strip_responsive, site }) => {
189
191
  try {
190
192
  const { wpUrl, authHeader } = resolveSite(sites, site);
191
- const r = await axios.get(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/data`, { headers: { Authorization: authHeader } });
193
+ const params = {};
194
+ if (compact !== undefined)
195
+ params.compact = compact ? "1" : "0";
196
+ if (strip_responsive !== undefined)
197
+ params.strip_responsive = strip_responsive ? "1" : "0";
198
+ const r = await axios.get(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/data`, { headers: { Authorization: authHeader }, params });
192
199
  return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
193
200
  }
194
201
  catch (error) {
@@ -227,6 +234,42 @@ function createMcpServer(sites) {
227
234
  return { content: [{ type: "text", text: `Error: ${error.response?.data?.message || error.message}` }], isError: true };
228
235
  }
229
236
  });
237
+ 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.", {
238
+ page_id: z.string().describe("WordPress Page ID"),
239
+ element_id: z.string().describe("Elementor Element ID of the widget whose link you want to change"),
240
+ url: z.string().optional().describe("URL to set, e.g. 'https://example.com'. Required unless clear=true."),
241
+ open_in_new_tab: z.boolean().optional().describe("Native Elementor 'Open in new window' toggle. Maps to link.is_external = 'on'."),
242
+ nofollow: z.boolean().optional().describe("Native Elementor 'Add nofollow' toggle. Maps to link.nofollow = 'on'."),
243
+ custom_attributes: z.string().optional().describe("Custom HTML link attributes, Elementor format: 'key|value,key|value'."),
244
+ clear: z.boolean().optional().describe("Set true to remove the link entirely (url='' and all flags reset)."),
245
+ link_field: z.string().optional().describe("Settings key holding the link object. Default 'link'. Override only for non-standard widgets."),
246
+ site: siteParam,
247
+ }, async ({ page_id, element_id, url, open_in_new_tab, nofollow, custom_attributes, clear, link_field, site }) => {
248
+ try {
249
+ if (!clear && (url === undefined || url === null || String(url).trim() === "")) {
250
+ return { content: [{ type: "text", text: "Provide a non-empty url, OR set clear=true to remove the link." }], isError: true };
251
+ }
252
+ const { wpUrl, authHeader } = resolveSite(sites, site);
253
+ const body = {};
254
+ if (url !== undefined)
255
+ body.url = url;
256
+ if (open_in_new_tab !== undefined)
257
+ body.open_in_new_tab = open_in_new_tab;
258
+ if (nofollow !== undefined)
259
+ body.nofollow = nofollow;
260
+ if (custom_attributes !== undefined)
261
+ body.custom_attributes = custom_attributes;
262
+ if (clear !== undefined)
263
+ body.clear = clear;
264
+ if (link_field !== undefined)
265
+ body.link_field = link_field;
266
+ 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" } });
267
+ return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
268
+ }
269
+ catch (error) {
270
+ return { content: [{ type: "text", text: `Error setting element link: ${error.response?.data?.message || error.message}` }], isError: true };
271
+ }
272
+ });
230
273
  server.tool("merge-element-settings", "Deep-merge settings into a specific Elementor element without replacing the full element. Use for small setting adjustments.", {
231
274
  page_id: z.string().describe("WordPress Page ID"),
232
275
  element_id: z.string().describe("Elementor Element ID"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yashwant.dharmdas/elementor-mcp",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "MCP server for controlling Elementor via Claude — supports multiple WordPress sites",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",