wp_update_page
Modify existing WordPress pages by updating content, titles, or status through the MCP WordPress Server. Change page details without creating new content.
Instructions
Updates an existing 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. | |
| id | Yes | The ID of the page to update. | |
| title | No | The new title for the page. | |
| content | No | The new content for the page, in HTML format. | |
| status | No | The new status for the page. |
Implementation Reference
- src/tools/pages.ts:203-211 (handler)The main handler function for the wp_update_page tool. It casts parameters to UpdatePageRequest type, calls the WordPressClient's updatePage method, and returns a success message or throws an error.public async handleUpdatePage(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const updateParams = params as unknown as UpdatePageRequest & { id: number }; try { const page = await client.updatePage(updateParams); return `✅ Page ${page.id} updated successfully.`; } catch (_error) { throw new Error(`Failed to update page: ${getErrorMessage(_error)}`); } }
- src/tools/pages.ts:93-121 (registration)The tool registration object returned by PageTools.getTools(), defining the name, description, input parameters schema, and binding to the handleUpdatePage handler. This is collected by ToolRegistry and registered with the MCP server.{ name: "wp_update_page", description: "Updates an existing page.", parameters: [ { name: "id", type: "number", required: true, description: "The ID of the page to update.", }, { name: "title", type: "string", description: "The new title for the page.", }, { name: "content", type: "string", description: "The new content for the page, in HTML format.", }, { name: "status", type: "string", description: "The new status for the page.", enum: ["publish", "draft", "pending", "private"], }, ], handler: this.handleUpdatePage.bind(this), },
- src/types/wordpress.ts:431-433 (schema)TypeScript interface defining the input shape for updating a page, extending CreatePageRequest with required id. Used for type safety in the handler.export interface UpdatePageRequest extends Partial<CreatePageRequest> { id: number; }