Skip to main content
Glama

wp_delete_page

Delete a WordPress page by ID, either permanently or by moving it to trash, for managing site content.

Instructions

Deletes a 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.
idYesThe ID of the page to delete.
forceNoIf true, permanently delete. If false, move to trash. Defaults to false.

Implementation Reference

  • The handler function that implements the core logic of the wp_delete_page tool. It calls the WordPressClient's deletePage method and formats the response.
    public async handleDeletePage(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id, force } = params as { id: number; force?: boolean };
      try {
        await client.deletePage(id, force);
        const action = params.force ? "permanently deleted" : "moved to trash";
        return `✅ Page ${id} has been ${action}.`;
      } catch (_error) {
        throw new Error(`Failed to delete page: ${getErrorMessage(_error)}`);
      }
  • The tool definition in PageTools.getTools(), which registers the wp_delete_page tool with its schema (parameters), description, and handler reference. This array is consumed by the ToolRegistry.
    {
      name: "wp_delete_page",
      description: "Deletes a page.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The ID of the page to delete.",
        },
        {
          name: "force",
          type: "boolean",
          description: "If true, permanently delete. If false, move to trash. Defaults to false.",
        },
      ],
      handler: this.handleDeletePage.bind(this),
    },
  • Registers all tool classes from src/tools/index.ts, including PageTools containing wp_delete_page, by calling getTools() and registering each tool with the MCP server.
    public registerAllTools(): void {
      // Register all tools from the tools directory
      Object.values(Tools).forEach((ToolClass) => {
        let toolInstance: { getTools(): unknown[] };
    
        // Cache and Performance tools need the clients map
        if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") {
          toolInstance = new ToolClass(this.wordpressClients);
        } else {
          toolInstance = new (ToolClass as new () => { getTools(): unknown[] })();
        }
    
        const tools = toolInstance.getTools();
    
        tools.forEach((tool: unknown) => {
          this.registerTool(tool as ToolDefinition);
        });
      });
    }

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