delete_page
Remove a specific page from WordPress using its ID, with an option to force deletion bypassing the trash. Returns a boolean indicating success.
Instructions
Deletes a specific page from WordPress, it will return a boolean value to indicate if the deletion was successful.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Whether to bypass the trash and force deletion. Defaults to false. | |
| pageId | Yes | The ID of the page to delete. |
Implementation Reference
- src/index.js:244-255 (handler)The inline handler function for the MCP 'delete_page' tool. It invokes the deletePage helper from wp-api.js and returns a success response.async (input) => { // Handler await deletePage(input.pageId, input.force); return { content: [ { type: "text", text: "true", }, ], }; }
- src/index.js:229-243 (schema)Zod input schema defining parameters for the delete_page tool: pageId (required number) and force (optional boolean, default false).{ // Input Schema: Use plain object with Zod types pageId: z .number() .int() .positive() .describe("The ID of the page to delete."), force: z .boolean() .optional() .default(false) .describe( "Whether to bypass the trash and force deletion. Defaults to false." ), },
- src/index.js:226-256 (registration)Registration of the 'delete_page' tool on the MCP server using server.tool(), including description, input schema, and handler function.server.tool( "delete_page", "Deletes a specific page from WordPress, it will return a boolean value to indicate if the deletion was successful.", { // Input Schema: Use plain object with Zod types pageId: z .number() .int() .positive() .describe("The ID of the page to delete."), force: z .boolean() .optional() .default(false) .describe( "Whether to bypass the trash and force deletion. Defaults to false." ), }, async (input) => { // Handler await deletePage(input.pageId, input.force); return { content: [ { type: "text", text: "true", }, ], }; } );
- src/wp-api.js:71-76 (helper)Helper function that performs the actual page deletion via WordPress REST API delete endpoint, called by the tool handler.async function deletePage(pageId, force = true) { const client = getApiClient(); const response = await client.delete(`/wp-json/wp/v2/pages/${pageId}?force=${force}`); // WP delete usually returns the object before deletion or a specific structure return response.data; }