Skip to main content
Glama
aguaitech

Elementor MCP Server

by aguaitech

update_page

Update WordPress pages with Elementor data by specifying page ID, title, status, content, and JSON-based Elementor data. Verifies success with a boolean response.

Instructions

Updates an existing page in WordPress with Elementor data, it will return a boolean value to indicate if the update was successful.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoThe standard WordPress content for the page (optional).
elementor_dataNoThe Elementor page data as a JSON string. Optional for update.
pageIdYesThe ID of the page to update.
statusNoThe status for the page (e.g., 'publish', 'draft').
titleNoThe title for the page.

Implementation Reference

  • MCP tool handler for 'update_page' that extracts input, validates, calls the updatePage helper, and returns success indicator.
    async (input) => {
      // Handler
      const { pageId, ...updateData } = input;
      // Basic validation, although schema handles optionality
      if (Object.keys(updateData).length === 0) {
        throw new Error(
          "No update data provided (title, status, content, or elementor_data)."
        );
      }
      await updatePage(pageId, updateData);
      return {
        content: [
          {
            type: "text",
            text: "true",
          },
        ],
      };
    }
  • Zod input schema defining parameters for the update_page tool: pageId (required), title/status/content/elementor_data (optional).
    {
      // Input Schema: Use plain object with Zod types
      pageId: z
        .number()
        .int()
        .positive()
        .describe("The ID of the page to update."),
      title: z.string().optional().describe("The title for the page."),
      status: z
        .enum(["publish", "future", "draft", "pending", "private"])
        .optional()
        .describe("The status for the page (e.g., 'publish', 'draft')."),
      content: z
        .string()
        .optional()
        .describe("The standard WordPress content for the page (optional)."),
      elementor_data: z
        .string()
        .optional()
        .describe(
          "The Elementor page data as a JSON string. Optional for update."
        ),
    },
  • src/index.js:135-180 (registration)
    Registration of the 'update_page' tool on the MCP server using server.tool() with name, description, schema, and handler.
    server.tool(
      "update_page",
      "Updates an existing page in WordPress with Elementor data, it will return a boolean value to indicate if the update was successful.",
      {
        // Input Schema: Use plain object with Zod types
        pageId: z
          .number()
          .int()
          .positive()
          .describe("The ID of the page to update."),
        title: z.string().optional().describe("The title for the page."),
        status: z
          .enum(["publish", "future", "draft", "pending", "private"])
          .optional()
          .describe("The status for the page (e.g., 'publish', 'draft')."),
        content: z
          .string()
          .optional()
          .describe("The standard WordPress content for the page (optional)."),
        elementor_data: z
          .string()
          .optional()
          .describe(
            "The Elementor page data as a JSON string. Optional for update."
          ),
      },
      async (input) => {
        // Handler
        const { pageId, ...updateData } = input;
        // Basic validation, although schema handles optionality
        if (Object.keys(updateData).length === 0) {
          throw new Error(
            "No update data provided (title, status, content, or elementor_data)."
          );
        }
        await updatePage(pageId, updateData);
        return {
          content: [
            {
              type: "text",
              text: "true",
            },
          ],
        };
      }
    );
  • Core helper function updatePage that constructs the payload from input data, validates elementor_data, and performs the PUT-like update via WordPress REST API POST to /pages/{id}.
    async function updatePage(pageId, pageData) {
        const client = getApiClient();
    
        const payload = {};
        if (pageData.title) payload.title = pageData.title;
        if (pageData.status) payload.status = pageData.status;
        if (pageData.content) payload.content = pageData.content; // Use !== undefined to allow setting empty content
    
        if (pageData.elementor_data) {
            if (typeof pageData.elementor_data !== 'string') {
                 throw new Error('elementor_data must be provided as a JSON string.');
            }
             try {
                JSON.parse(pageData.elementor_data); // Basic validation
            } catch (e) {
                throw new Error('elementor_data is not valid JSON string.');
            }
            payload.meta = { _elementor_data: pageData.elementor_data };
        }
    
        if (Object.keys(payload).length === 0) {
            throw new Error("No update data provided.");
        }
    
        // WP uses POST for updates via ID route
        const response = await client.post(`/wp-json/wp/v2/pages/${pageId}`, payload);
        return response.data;
    }
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aguaitech/Elementor-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server