@yashwant.dharmdas/elementor-mcp 3.1.0 → 3.2.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 +94 -0
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -992,6 +992,100 @@ function createMcpServer(sites) {
992
992
  return { content: [{ type: "text", text: `Error enabling Elementor: ${error.response?.data?.message || error.message}` }], isError: true };
993
993
  }
994
994
  });
995
+ // ── Group 9: Screenshot ──────────────────────────────────────────────────────
996
+ server.tool("screenshot-page", "Take a full-page screenshot of a published WordPress page using the system-installed Google Chrome browser. Returns the screenshot as an image so you can visually review design, layout, and content. Requires the page to be publicly accessible (status: publish).", {
997
+ page_id: z.string().describe("WordPress Page ID"),
998
+ full_page: z.boolean().optional().describe("Capture the full scrollable page height (default: true)"),
999
+ width: z.number().optional().describe("Viewport width in pixels (default: 1440)"),
1000
+ site: siteParam,
1001
+ }, async ({ page_id, full_page, width, site }) => {
1002
+ try {
1003
+ const { wpUrl, authHeader } = resolveSite(sites, site);
1004
+ // ── 1. Resolve the page's public URL from WP REST API ──────────────
1005
+ const pageRes = await axios.get(`${wpUrl}/wp-json/wp/v2/pages/${page_id}`, {
1006
+ headers: { Authorization: authHeader },
1007
+ });
1008
+ const pageUrl = pageRes.data.link;
1009
+ if (!pageUrl)
1010
+ throw new Error("Could not resolve public URL for this page.");
1011
+ // ── 2. Detect system Chrome ──────────────────────────────────────
1012
+ const chromePaths = [
1013
+ // Windows
1014
+ "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
1015
+ "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
1016
+ // macOS
1017
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
1018
+ // Linux
1019
+ "/usr/bin/google-chrome",
1020
+ "/usr/bin/google-chrome-stable",
1021
+ "/usr/bin/chromium-browser",
1022
+ "/usr/bin/chromium",
1023
+ ];
1024
+ let executablePath;
1025
+ for (const p of chromePaths) {
1026
+ if (fs.existsSync(p)) {
1027
+ executablePath = p;
1028
+ break;
1029
+ }
1030
+ }
1031
+ if (!executablePath) {
1032
+ throw new Error("Google Chrome not found on this machine.\n" +
1033
+ "Install Chrome from https://www.google.com/chrome/ and ensure it is in a standard location.\n" +
1034
+ "Checked paths:\n" + chromePaths.map(p => ` • ${p}`).join("\n"));
1035
+ }
1036
+ // ── 3. Launch puppeteer-core with system Chrome ─────────────────
1037
+ let puppeteer;
1038
+ try {
1039
+ puppeteer = await import("puppeteer-core");
1040
+ }
1041
+ catch {
1042
+ throw new Error("puppeteer-core is not installed. Run: npm install puppeteer-core\n" +
1043
+ "(or reinstall @yashwant.dharmdas/elementor-mcp — it is bundled as a dependency)");
1044
+ }
1045
+ const browser = await puppeteer.launch({
1046
+ executablePath,
1047
+ headless: true,
1048
+ args: [
1049
+ "--no-sandbox",
1050
+ "--disable-setuid-sandbox",
1051
+ "--disable-dev-shm-usage",
1052
+ "--disable-gpu",
1053
+ ],
1054
+ });
1055
+ try {
1056
+ const page = await browser.newPage();
1057
+ await page.setViewport({ width: width ?? 1440, height: 900, deviceScaleFactor: 1 });
1058
+ await page.goto(pageUrl, { waitUntil: "networkidle2", timeout: 30_000 });
1059
+ // Small pause to let JS-heavy pages finish rendering
1060
+ await new Promise(resolve => setTimeout(resolve, 1000));
1061
+ const screenshotBuffer = await page.screenshot({
1062
+ fullPage: full_page ?? true,
1063
+ type: "png",
1064
+ });
1065
+ const base64 = Buffer.isBuffer(screenshotBuffer)
1066
+ ? screenshotBuffer.toString("base64")
1067
+ : Buffer.from(screenshotBuffer).toString("base64");
1068
+ return {
1069
+ content: [
1070
+ {
1071
+ type: "image",
1072
+ data: base64,
1073
+ mimeType: "image/png",
1074
+ },
1075
+ ],
1076
+ };
1077
+ }
1078
+ finally {
1079
+ await browser.close();
1080
+ }
1081
+ }
1082
+ catch (error) {
1083
+ return {
1084
+ content: [{ type: "text", text: `Error taking screenshot: ${error.message}` }],
1085
+ isError: true,
1086
+ };
1087
+ }
1088
+ });
995
1089
  return server;
996
1090
  }
997
1091
  // ─── Entry Point ──────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yashwant.dharmdas/elementor-mcp",
3
- "version": "3.1.0",
3
+ "version": "3.2.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",
@@ -19,6 +19,7 @@
19
19
  "@modelcontextprotocol/sdk": "^1.26.0",
20
20
  "ajv": "^8.12.0",
21
21
  "axios": "^1.6.0",
22
+ "puppeteer-core": "^22.15.0",
22
23
  "zod": "^3.22.4"
23
24
  },
24
25
  "devDependencies": {