Skip to main content
Glama

create_page

Create a new WordPress page with Elementor data, specifying title, status, content, and required JSON-formatted Elementor data, returning the page ID upon success.

Instructions

Creates a new page in WordPress with Elementor data, it will return the created page ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoThe standard WordPress content for the page (optional).
elementor_dataYesThe Elementor page data as a JSON string (required for create).
statusNoThe status for the page (e.g., 'publish', 'draft'). Defaults to 'draft' on create.
titleYesThe title for the new page (required).

Implementation Reference

  • src/index.js:34-70 (registration)
    MCP tool registration for 'create_page', including description, input schema, and handler function that delegates to wp-api createPage.
    server.tool( "create_page", "Creates a new page in WordPress with Elementor data, it will return the created page ID.", { // Input Schema: Use plain object with Zod types title: z.string().describe("The title for the new page (required)."), status: z .enum(["publish", "future", "draft", "pending", "private"]) .optional() .describe( "The status for the page (e.g., 'publish', 'draft'). Defaults to 'draft' on create." ), content: z .string() .optional() .describe("The standard WordPress content for the page (optional)."), elementor_data: z .string() .describe( "The Elementor page data as a JSON string (required for create)." ), }, async (input) => { // Handler function const newPage = await createPage(input); // Return the result object directly return { content: [ { type: "text", text: `${newPage.id}`, }, ], }; // Errors thrown here will be handled by McpServer } );
  • MCP tool handler for create_page: calls createPage from wp-api and returns the new page ID as text content.
    async (input) => { // Handler function const newPage = await createPage(input); // Return the result object directly return { content: [ { type: "text", text: `${newPage.id}`, }, ], }; // Errors thrown here will be handled by McpServer }
  • Zod input schema for create_page tool defining parameters: title (required), status, content, elementor_data (JSON string).
    // Input Schema: Use plain object with Zod types title: z.string().describe("The title for the new page (required)."), status: z .enum(["publish", "future", "draft", "pending", "private"]) .optional() .describe( "The status for the page (e.g., 'publish', 'draft'). Defaults to 'draft' on create." ), content: z .string() .optional() .describe("The standard WordPress content for the page (optional)."), elementor_data: z .string() .describe( "The Elementor page data as a JSON string (required for create)." ), },
  • Core helper function createPage that performs the WordPress REST API POST to /wp/v2/pages with Elementor meta data, including validation.
    async function createPage(pageData) { const client = getApiClient(); // Ensure Elementor data is properly nested under meta const payload = { title: pageData.title, status: pageData.status || 'draft', // Default to draft content: pageData.content || '', // Optional standard content meta: { _elementor_data: pageData.elementor_data // MUST be a JSON string } // Add other WP fields as needed (e.g., template, author, etc.) }; // Validate elementor_data is a string if (typeof payload.meta._elementor_data !== 'string') { throw new Error('elementor_data must be provided as a JSON string.'); } try { JSON.parse(payload.meta._elementor_data); // Basic validation it's parsable JSON } catch (e) { throw new Error('elementor_data is not valid JSON string.'); } const response = await client.post('/wp-json/wp/v2/pages', payload); return response.data; // Return the created page object }

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