@yashwant.dharmdas/elementor-mcp 3.10.0 → 3.11.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 +92 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1091,13 +1091,14 @@ function createMcpServer(sites) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
});
|
|
1093
1093
|
// ── Group 8: Page Creation & Publishing ──────────────────────────────────
|
|
1094
|
-
server.tool("create-page", "Create a new WordPress page, optionally publish it immediately, and enable the Elementor editor. Returns the page ID and direct Elementor edit URL.", {
|
|
1094
|
+
server.tool("create-page", "Create a new WordPress page, optionally publish it immediately, and enable the Elementor editor. Returns the page ID and direct Elementor edit URL. Supports any WordPress post type — use post_type='astra-portfolio' for Astra portfolio items, 'post' for blog posts, etc.", {
|
|
1095
1095
|
title: z.string().describe("Page title"),
|
|
1096
1096
|
status: z.enum(["draft", "publish", "private", "pending"]).optional().describe("Page status — default: draft"),
|
|
1097
1097
|
page_template: z.string().optional().describe("WordPress page template filename (e.g. 'elementor_canvas'). Leave blank for default."),
|
|
1098
1098
|
enable_elementor: z.boolean().optional().describe("Initialize the Elementor editor on this page (default: true)"),
|
|
1099
|
+
post_type: z.string().optional().describe("WordPress post type. Default: 'page'. Use 'astra-portfolio' for Astra portfolio, 'post' for blog posts, or any registered custom post type."),
|
|
1099
1100
|
site: siteParam,
|
|
1100
|
-
}, async ({ title, status, page_template, enable_elementor, site }) => {
|
|
1101
|
+
}, async ({ title, status, page_template, enable_elementor, post_type, site }) => {
|
|
1101
1102
|
try {
|
|
1102
1103
|
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
1103
1104
|
const body = {
|
|
@@ -1107,6 +1108,8 @@ function createMcpServer(sites) {
|
|
|
1107
1108
|
};
|
|
1108
1109
|
if (page_template)
|
|
1109
1110
|
body.page_template = page_template;
|
|
1111
|
+
if (post_type)
|
|
1112
|
+
body.post_type = post_type;
|
|
1110
1113
|
const r = await axios.post(`${wpUrl}/wp-json/erc/v1/pages`, body, {
|
|
1111
1114
|
headers: { Authorization: authHeader, "Content-Type": "application/json" },
|
|
1112
1115
|
});
|
|
@@ -1116,6 +1119,93 @@ function createMcpServer(sites) {
|
|
|
1116
1119
|
return { content: [{ type: "text", text: `Error creating page: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
1117
1120
|
}
|
|
1118
1121
|
});
|
|
1122
|
+
server.tool("import-template-to-page", "Push a local Elementor JSON file from disk directly to an existing page. The MCP server reads the file and sends it straight to WordPress — the JSON NEVER passes through Claude's context, so there is NO 25K-token limit. Use when you have generated a large Elementor JSON locally and need to push it to an existing page. File path must be accessible on this machine (where the MCP server is running).", {
|
|
1123
|
+
page_id: z.string().describe("WordPress Page ID to write the Elementor data to"),
|
|
1124
|
+
file_path: z.string().describe("Absolute path to the Elementor JSON file on disk (e.g. D:\\Project\\final-service-pages\\botox.json). Must contain a valid Elementor elements array."),
|
|
1125
|
+
site: siteParam,
|
|
1126
|
+
}, async ({ page_id, file_path, site }) => {
|
|
1127
|
+
try {
|
|
1128
|
+
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
1129
|
+
// Read file from local disk — bypasses Claude context entirely
|
|
1130
|
+
if (!fs.existsSync(file_path)) {
|
|
1131
|
+
return { content: [{ type: "text", text: `Error: File not found at path: ${file_path}` }], isError: true };
|
|
1132
|
+
}
|
|
1133
|
+
const raw = fs.readFileSync(file_path, "utf8");
|
|
1134
|
+
let elementorData;
|
|
1135
|
+
try {
|
|
1136
|
+
elementorData = JSON.parse(raw);
|
|
1137
|
+
}
|
|
1138
|
+
catch {
|
|
1139
|
+
return { content: [{ type: "text", text: `Error: File at ${file_path} is not valid JSON.` }], isError: true };
|
|
1140
|
+
}
|
|
1141
|
+
// Push to WordPress
|
|
1142
|
+
const r = await axios.put(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/data`, elementorData, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
|
|
1143
|
+
// Clear cache
|
|
1144
|
+
await axios.post(`${wpUrl}/wp-json/erc/v1/site/clear-cache`, {}, { headers: { Authorization: authHeader }, params: { post_id: page_id } }).catch(() => { });
|
|
1145
|
+
return { content: [{ type: "text", text: JSON.stringify({ success: true, page_id, file: file_path, result: r.data }, null, 2) }] };
|
|
1146
|
+
}
|
|
1147
|
+
catch (error) {
|
|
1148
|
+
return { content: [{ type: "text", text: `Error importing template: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
server.tool("create-page-from-file", "Create a new WordPress page AND populate it with Elementor data from a local JSON file — all in one step. The MCP server reads the file from disk and sends it straight to WordPress. The JSON NEVER passes through Claude's context, so there is NO 25K-token limit. This is the correct tool for the service-pages workflow: write a script that generates Elementor JSONs locally, then call this tool for each file. Supports any post_type (astra-portfolio, page, post, etc.). Steps internally: 1) create page → get ID, 2) push Elementor data from file, 3) clear cache.", {
|
|
1152
|
+
title: z.string().describe("Page title"),
|
|
1153
|
+
file_path: z.string().describe("Absolute path to the Elementor JSON file on disk (e.g. D:\\Project\\final-service-pages\\botox.json)"),
|
|
1154
|
+
post_type: z.string().optional().describe("WordPress post type. Default: 'page'. Use 'astra-portfolio' for Astra portfolio items, 'post' for blog posts, or any registered custom post type."),
|
|
1155
|
+
status: z.enum(["draft", "publish", "private", "pending"]).optional().describe("Page status — default: publish"),
|
|
1156
|
+
page_template: z.string().optional().describe("WordPress page template (e.g. 'elementor_canvas'). Leave blank for default."),
|
|
1157
|
+
site: siteParam,
|
|
1158
|
+
}, async ({ title, file_path, post_type, status, page_template, site }) => {
|
|
1159
|
+
try {
|
|
1160
|
+
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
1161
|
+
// Step 1: Read the Elementor JSON from disk
|
|
1162
|
+
if (!fs.existsSync(file_path)) {
|
|
1163
|
+
return { content: [{ type: "text", text: `Error: File not found at path: ${file_path}` }], isError: true };
|
|
1164
|
+
}
|
|
1165
|
+
const raw = fs.readFileSync(file_path, "utf8");
|
|
1166
|
+
let elementorData;
|
|
1167
|
+
try {
|
|
1168
|
+
elementorData = JSON.parse(raw);
|
|
1169
|
+
}
|
|
1170
|
+
catch {
|
|
1171
|
+
return { content: [{ type: "text", text: `Error: File at ${file_path} is not valid JSON.` }], isError: true };
|
|
1172
|
+
}
|
|
1173
|
+
// Step 2: Create the page
|
|
1174
|
+
const createBody = {
|
|
1175
|
+
title,
|
|
1176
|
+
status: status ?? "publish",
|
|
1177
|
+
enable_elementor: true,
|
|
1178
|
+
};
|
|
1179
|
+
if (post_type)
|
|
1180
|
+
createBody.post_type = post_type;
|
|
1181
|
+
if (page_template)
|
|
1182
|
+
createBody.page_template = page_template;
|
|
1183
|
+
const createRes = await axios.post(`${wpUrl}/wp-json/erc/v1/pages`, createBody, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
|
|
1184
|
+
const page_id = createRes.data.id;
|
|
1185
|
+
// Step 3: Push Elementor data from file (never entered Claude context)
|
|
1186
|
+
await axios.put(`${wpUrl}/wp-json/erc/v1/pages/${page_id}/data`, elementorData, { headers: { Authorization: authHeader, "Content-Type": "application/json" } });
|
|
1187
|
+
// Step 4: Clear cache
|
|
1188
|
+
await axios.post(`${wpUrl}/wp-json/erc/v1/site/clear-cache`, {}, { headers: { Authorization: authHeader }, params: { post_id: page_id } }).catch(() => { });
|
|
1189
|
+
return {
|
|
1190
|
+
content: [{
|
|
1191
|
+
type: "text",
|
|
1192
|
+
text: JSON.stringify({
|
|
1193
|
+
success: true,
|
|
1194
|
+
page_id,
|
|
1195
|
+
title,
|
|
1196
|
+
post_type: post_type ?? "page",
|
|
1197
|
+
status: status ?? "publish",
|
|
1198
|
+
url: createRes.data.url,
|
|
1199
|
+
edit_url: createRes.data.elementor_edit_url,
|
|
1200
|
+
file_used: file_path,
|
|
1201
|
+
}, null, 2),
|
|
1202
|
+
}],
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
catch (error) {
|
|
1206
|
+
return { content: [{ type: "text", text: `Error creating page from file: ${error.response?.data?.message || error.message}` }], isError: true };
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1119
1209
|
server.tool("publish-page", "Change the publish status of a WordPress page (publish, draft, private, pending, trash).", {
|
|
1120
1210
|
page_id: z.string().describe("WordPress Page ID"),
|
|
1121
1211
|
status: z.enum(["publish", "draft", "private", "pending", "trash"]).describe("Target status"),
|
package/package.json
CHANGED