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
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| title | Yes | The title for the page. | |
| content | No | The content for the page, in HTML format. | |
| status | No | The publishing status for the page. |
Implementation Reference
- src/tools/pages.ts:69-92 (registration)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), },
- src/tools/pages.ts:193-201 (handler)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)}`); } }
- src/types/wordpress.ts:412-429 (schema)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; }