Skip to main content
Glama

wp_get_page_revisions

Retrieve revision history for a WordPress page to track changes, restore previous versions, or compare content updates.

Instructions

Retrieves revisions for a specific 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 get revisions for.

Implementation Reference

  • The main handler function for the 'wp_get_page_revisions' tool. It extracts the page ID from parameters, fetches revisions using WordPressClient.getPageRevisions, formats a user-friendly list of revisions (author and modified date), or returns a no-revisions message. Handles errors gracefully.
    public async handleGetPageRevisions(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id } = params as { id: number };
      try {
        const revisions = await client.getPageRevisions(id);
        if (revisions.length === 0) {
          return `No revisions found for page ${id}.`;
        }
        const content =
          `Found ${revisions.length} revisions for page ${id}:\n\n` +
          revisions
            .map((r) => `- Revision by user ID ${r.author} at ${new Date(r.modified).toLocaleString()}`)
            .join("\n");
        return content;
      } catch (_error) {
        throw new Error(`Failed to get page revisions: ${getErrorMessage(_error)}`);
      }
    }
  • Tool registration within PageTools.getTools(). Defines the tool name, description, input parameters (page ID), and binds the handler function for MCP tool registry.
    {
      name: "wp_get_page_revisions",
      description: "Retrieves revisions for a specific page.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The ID of the page to get revisions for.",
        },
      ],
      handler: this.handleGetPageRevisions.bind(this),
    },
  • Input schema definition for the tool, specifying the required 'id' parameter of type number with description.
    {
      name: "wp_get_page_revisions",
      description: "Retrieves revisions for a specific page.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The ID of the page to get revisions for.",
        },
      ],
      handler: this.handleGetPageRevisions.bind(this),
    },
  • Core API helper method in PagesOperations that performs the actual HTTP GET request to WordPress REST API endpoint `/wp-json/wp/v2/pages/{id}/revisions` via the base client.
    async getPageRevisions(id: number): Promise<WordPressPage[]> {
      return this.client.get<WordPressPage[]>(`pages/${id}/revisions`);
    }

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