@yashwant.dharmdas/elementor-mcp 3.11.1 → 3.12.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 +41 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -422,9 +422,9 @@ function createMcpServer(sites) {
|
|
|
422
422
|
}
|
|
423
423
|
});
|
|
424
424
|
// ── Group 2: Page & Site Config ───────────────────────────────────────────
|
|
425
|
-
server.tool("update-page-settings", "Update Elementor page-level settings
|
|
425
|
+
server.tool("update-page-settings", "Update Elementor page-level settings — merges with existing settings on _elementor_page_settings post meta. Common keys: hide_title ('yes' or ''), template ('elementor_canvas', 'elementor_header_footer', 'default'), custom_css. For the common 'Hide Title' toggle prefer the dedicated hide-page-title tool which handles one or many pages with a clean boolean.", {
|
|
426
426
|
page_id: z.string().describe("WordPress Page ID"),
|
|
427
|
-
settings: z.string().describe("Settings object to merge as stringified JSON"),
|
|
427
|
+
settings: z.string().describe("Settings object to merge as stringified JSON, e.g. '{\"hide_title\":\"yes\"}'"),
|
|
428
428
|
site: siteParam,
|
|
429
429
|
}, async ({ page_id, settings, site }) => {
|
|
430
430
|
let parsed;
|
|
@@ -443,6 +443,45 @@ function createMcpServer(sites) {
|
|
|
443
443
|
return { content: [{ type: "text", text: `Error updating page settings: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
444
444
|
}
|
|
445
445
|
});
|
|
446
|
+
server.tool("hide-page-title", "Toggle Elementor's 'Hide Title' setting on one OR MANY pages in a single call. Equivalent to opening each page in Elementor → Page Settings → flipping the 'Hide Title' switch. Writes hide_title='yes' (or '' to unhide) to _elementor_page_settings post meta. Use this right after create-page-from-file to hide the WordPress title that appears above your Elementor hero section. Clears the Elementor cache so the change is visible immediately.", {
|
|
447
|
+
page_ids: z.array(z.string()).min(1).describe("One or more WordPress page IDs. Pass multiple to batch — e.g. all 5 service pages at once."),
|
|
448
|
+
hide: z.boolean().optional().describe("true = hide the title (default), false = show the title."),
|
|
449
|
+
site: siteParam,
|
|
450
|
+
}, async ({ page_ids, hide, site }) => {
|
|
451
|
+
try {
|
|
452
|
+
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
453
|
+
const hideValue = (hide ?? true) ? "yes" : "";
|
|
454
|
+
const results = [];
|
|
455
|
+
for (const page_id of page_ids) {
|
|
456
|
+
try {
|
|
457
|
+
const r = await axios.patch(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/settings`, { hide_title: hideValue }, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
|
|
458
|
+
results.push({ page_id, success: true, hide_title: hideValue, result: r.data });
|
|
459
|
+
}
|
|
460
|
+
catch (err) {
|
|
461
|
+
results.push({ page_id, success: false, error: err.response?.data?.message || err.message });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
// Clear cache once at the end so all pages refresh
|
|
465
|
+
await axios.post(`${wpUrl}/wp-json/erc/v1/site/clear-cache`, {}, { headers: { Authorization: authHeader } }).catch(() => { });
|
|
466
|
+
const failed = results.filter(r => !r.success);
|
|
467
|
+
return {
|
|
468
|
+
content: [{
|
|
469
|
+
type: "text",
|
|
470
|
+
text: JSON.stringify({
|
|
471
|
+
total: page_ids.length,
|
|
472
|
+
succeeded: results.length - failed.length,
|
|
473
|
+
failed: failed.length,
|
|
474
|
+
hide: hide ?? true,
|
|
475
|
+
results,
|
|
476
|
+
}, null, 2),
|
|
477
|
+
}],
|
|
478
|
+
isError: failed.length === page_ids.length,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
return { content: [{ type: "text", text: `Error toggling hide-title: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
483
|
+
}
|
|
484
|
+
});
|
|
446
485
|
server.tool("get-theme-context", "Get a summary of the active WordPress theme, Elementor version, active kit ID, Pro status, and viewport breakpoints.", { site: siteParam }, async ({ site }) => {
|
|
447
486
|
try {
|
|
448
487
|
const { wpUrl, authHeader } = resolveSite(sites, site);
|
package/package.json
CHANGED