@yashwant.dharmdas/elementor-mcp 3.4.0 → 3.5.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 +68 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -849,42 +849,70 @@ function createMcpServer(sites) {
849
849
  return { content: [{ type: "text", text: `Error: ${e.response?.data?.message || e.message}` }], isError: true };
850
850
  }
851
851
  });
852
- server.tool("create-custom-code", "Create a new custom code snippet (requires Elementor Pro).", {
853
- title: z.string(),
854
- code: z.string(),
855
- location: z.string().optional().describe("head or body"),
856
- status: z.string().optional(),
852
+ server.tool("create-custom-code", "Create a new custom code snippet (requires Elementor Pro). Supports the full Publish Settings — set condition='entire_site' so the snippet actually applies sitewide (otherwise it has no effect even when published).", {
853
+ title: z.string().describe("Snippet title (e.g. 'Favicon Code')"),
854
+ code: z.string().describe("Raw code to inject (HTML, JS, or CSS)"),
855
+ location: z.string().optional().describe("Where to inject: 'head', 'body_start', 'body_end' (default: head)"),
856
+ status: z.string().optional().describe("Post status: 'publish' (default) or 'draft'. Use 'publish' to make the snippet active immediately."),
857
+ priority: z.number().optional().describe("Load priority — lower number = earlier. Default: 10"),
858
+ condition: z.enum(["entire_site", "specific_page", "post_type"]).optional().describe("Where the snippet applies. 'entire_site' = sitewide (most common, required for favicons/global tags). Default: entire_site"),
859
+ page_id: z.string().optional().describe("Required when condition='specific_page'. Apply only to this page."),
860
+ post_type: z.string().optional().describe("Required when condition='post_type'. WordPress post type slug (e.g. 'page', 'post', 'astra-portfolio')."),
857
861
  site: siteParam,
858
- }, async ({ title, code, location, status, site }) => {
862
+ }, async ({ title, code, location, status, priority, condition, page_id, post_type, site }) => {
859
863
  try {
860
864
  const { wpUrl, authHeader } = resolveSite(sites, site);
861
- const r = await axios.post(`${wpUrl}/wp-json/erc/v1/site/custom-code`, { title, code, location: location || "head", status: status || "draft" }, { headers: { Authorization: authHeader } });
865
+ const body = {
866
+ title,
867
+ code,
868
+ location: location || "head",
869
+ status: status || "publish",
870
+ priority: priority ?? 10,
871
+ condition: condition || "entire_site",
872
+ };
873
+ if (condition === "specific_page" && page_id)
874
+ body.page_id = page_id;
875
+ if (condition === "post_type" && post_type)
876
+ body.post_type = post_type;
877
+ const r = await axios.post(`${wpUrl}/wp-json/erc/v1/site/custom-code`, body, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
862
878
  return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
863
879
  }
864
880
  catch (e) {
865
881
  return { content: [{ type: "text", text: `Error: ${e.response?.data?.message || e.message}` }], isError: true };
866
882
  }
867
883
  });
868
- server.tool("update-custom-code", "Update a custom code snippet (requires Elementor Pro).", {
869
- snippet_id: z.string(),
884
+ server.tool("update-custom-code", "Update a custom code snippet (requires Elementor Pro). Can also update Publish Settings — condition, priority, and status.", {
885
+ snippet_id: z.string().describe("ID of the custom code snippet"),
870
886
  title: z.string().optional(),
871
887
  code: z.string().optional(),
872
- location: z.string().optional(),
873
- status: z.string().optional(),
888
+ location: z.string().optional().describe("'head', 'body_start', or 'body_end'"),
889
+ status: z.string().optional().describe("'publish' or 'draft'"),
890
+ priority: z.number().optional().describe("Load priority (lower = earlier)"),
891
+ condition: z.enum(["entire_site", "specific_page", "post_type"]).optional().describe("Where the snippet applies"),
892
+ page_id: z.string().optional().describe("Required when condition='specific_page'"),
893
+ post_type: z.string().optional().describe("Required when condition='post_type'"),
874
894
  site: siteParam,
875
- }, async ({ snippet_id, title, code, location, status, site }) => {
895
+ }, async ({ snippet_id, title, code, location, status, priority, condition, page_id, post_type, site }) => {
876
896
  try {
877
897
  const { wpUrl, authHeader } = resolveSite(sites, site);
878
898
  const body = {};
879
- if (title)
899
+ if (title !== undefined)
880
900
  body.title = title;
881
- if (code)
901
+ if (code !== undefined)
882
902
  body.code = code;
883
- if (location)
903
+ if (location !== undefined)
884
904
  body.location = location;
885
- if (status)
905
+ if (status !== undefined)
886
906
  body.status = status;
887
- const r = await axios.put(`${wpUrl}/wp-json/erc/v1/site/custom-code/${snippet_id}`, body, { headers: { Authorization: authHeader } });
907
+ if (priority !== undefined)
908
+ body.priority = priority;
909
+ if (condition !== undefined)
910
+ body.condition = condition;
911
+ if (page_id !== undefined)
912
+ body.page_id = page_id;
913
+ if (post_type !== undefined)
914
+ body.post_type = post_type;
915
+ const r = await axios.put(`${wpUrl}/wp-json/erc/v1/site/custom-code/${snippet_id}`, body, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
888
916
  return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
889
917
  }
890
918
  catch (e) {
@@ -1906,6 +1934,29 @@ function createMcpServer(sites) {
1906
1934
  return { content: [{ type: "text", text: `Error setting Z-index: ${error.response?.data?.message || error.message}` }], isError: true };
1907
1935
  }
1908
1936
  });
1937
+ // ── Group 26: Favicon ─────────────────────────────────────────────────────────
1938
+ server.tool("upload-favicon", "Set the WordPress Site Icon (favicon) — equivalent to Customize → Site Identity → Select Site Icon. Accepts either a URL of an image already in the media library, a media attachment ID, or a remote URL to fetch and upload first.", {
1939
+ favicon_url: z.string().optional().describe("URL of the favicon image. If the URL is from the same WP media library, the existing attachment is reused; otherwise the image is downloaded and uploaded as a new media item."),
1940
+ favicon_id: z.number().optional().describe("WordPress media attachment ID of an already-uploaded favicon image (preferred when known)"),
1941
+ site: siteParam,
1942
+ }, async ({ favicon_url, favicon_id, site }) => {
1943
+ try {
1944
+ if (!favicon_url && !favicon_id) {
1945
+ return { content: [{ type: "text", text: "Provide either favicon_url or favicon_id." }], isError: true };
1946
+ }
1947
+ const { wpUrl, authHeader } = resolveSite(sites, site);
1948
+ const body = {};
1949
+ if (favicon_id)
1950
+ body.favicon_id = favicon_id;
1951
+ if (favicon_url)
1952
+ body.favicon_url = favicon_url;
1953
+ const r = await axios.post(`${wpUrl}/wp-json/erc/v1/site/favicon`, body, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
1954
+ return { content: [{ type: "text", text: JSON.stringify(r.data, null, 2) }] };
1955
+ }
1956
+ catch (error) {
1957
+ return { content: [{ type: "text", text: `Error setting favicon: ${error.response?.data?.message || error.message}` }], isError: true };
1958
+ }
1959
+ });
1909
1960
  // ── Group 25: Video Overlay ───────────────────────────────────────────────────
1910
1961
  server.tool("update-video-overlay", "Set the image overlay on an Elementor video widget so the video appears to load immediately on page load. The overlay image (typically the video thumbnail or hero image) is shown until the user clicks play. This is the correct fix for 'video not loading immediately' QA issues — not changing the video URL.", {
1911
1962
  page_id: z.string().describe("WordPress Page ID containing the video widget"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yashwant.dharmdas/elementor-mcp",
3
- "version": "3.4.0",
3
+ "version": "3.5.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",