Skip to main content
Glama

wp_create_page

Create new WordPress pages by specifying title, content, and publishing status. Use this tool to add content to your WordPress site through the MCP WordPress Server.

Instructions

Creates a new page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
titleYesThe title for the page.
contentNoThe content for the page, in HTML format.
statusNoThe publishing status for the page.

Implementation Reference

  • Registration of the wp_create_page tool in PageTools.getTools() method, including name, description, input parameters schema, and reference to the handler function.
    {
      name: "wp_create_page",
      description: "Creates a new page.",
      parameters: [
        {
          name: "title",
          type: "string",
          required: true,
          description: "The title for the page.",
        },
        {
          name: "content",
          type: "string",
          description: "The content for the page, in HTML format.",
        },
        {
          name: "status",
          type: "string",
          description: "The publishing status for the page.",
          enum: ["publish", "draft", "pending", "private"],
        },
      ],
      handler: this.handleCreatePage.bind(this),
    },
  • The handler function that implements the core logic of wp_create_page: casts params to CreatePageRequest, calls WordPressClient.createPage(), and returns formatted success message or throws error.
    public async handleCreatePage(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const createParams = params as unknown as CreatePageRequest;
      try {
        const page = await client.createPage(createParams);
        return `✅ Page created successfully!\n- ID: ${page.id}\n- Title: ${page.title.rendered}\n- Link: ${page.link}`;
      } catch (_error) {
        throw new Error(`Failed to create page: ${getErrorMessage(_error)}`);
      }
    }
  • TypeScript interface defining the CreatePageRequest structure used for typing the parameters in the wp_create_page handler.
    export interface CreatePageRequest {
      title?: string;
      content?: string;
      author?: number;
      excerpt?: string;
      featured_media?: number;
      comment_status?: CommentStatus;
      ping_status?: PingStatus;
      menu_order?: number;
      meta?: WordPressMeta;
      parent?: number;
      template?: string;
      date?: string;
      date_gmt?: string;
      slug?: string;
      status?: PostStatus;
      password?: string;
    }

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/docdyhr/mcp-wordpress'

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