Skip to main content
Glama

wp_get_post_revisions

Retrieve revision history for WordPress posts to track changes, view edit dates, and identify authors for content auditing and management.

Instructions

Retrieves the revision history for a specific post, including details about changes, dates, and authors for content management and auditing purposes.

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 post to get revisions for.

Implementation Reference

  • The primary handler function that implements the wp_get_post_revisions tool. It validates the post ID, fetches revisions using the WordPressClient, handles empty results and errors, and formats a detailed response listing each revision with ID, date, and title.
    export async function handleGetPostRevisions(
      client: WordPressClient,
      params: { id: number },
    ): Promise<WordPressPost[] | string> {
      try {
        const postId = validateId(params.id, "post ID");
        const revisions = await client.getPostRevisions(postId);
    
        if (revisions.length === 0) {
          return `No revisions found for post ${params.id}. This may be because revisions are disabled or the post has no revision history.`;
        }
    
        let response = `📚 **Post Revisions** (${revisions.length} total)\n\n`;
    
        revisions.forEach((revision, index) => {
          const date = new Date(revision.date);
          const formattedDate = date.toLocaleDateString("en-US", {
            year: "numeric",
            month: "short",
            day: "numeric",
            hour: "2-digit",
            minute: "2-digit",
          });
    
          response += `**Revision ${index + 1}**\n`;
          response += `- ID: ${revision.id}\n`;
          response += `- Date: ${formattedDate}\n`;
          response += `- Title: ${revision.title.rendered}\n`;
          if (index < revisions.length - 1) response += "\n";
        });
    
        return response;
      } catch (_error) {
        if (_error instanceof Error && _error.message.includes("404")) {
          return `Post with ID ${params.id} not found. Please verify the ID and try again.`;
        }
        throw new Error(`Failed to get post revisions: ${getErrorMessage(_error)}`);
      }
    }
  • The MCP tool schema definition for wp_get_post_revisions, specifying the input parameters (post ID) and description.
    export const getPostRevisionsTool: MCPTool = {
      name: "wp_get_post_revisions",
      description:
        "Retrieves the revision history for a specific post, including details about changes, dates, and authors for content management and auditing purposes.",
      inputSchema: {
        type: "object",
        properties: {
          id: {
            type: "number",
            description: "The ID of the post to get revisions for.",
          },
        },
        required: ["id"],
      },
    };
  • The registration mapping that binds the 'wp_get_post_revisions' tool name to its handler method (this.handleGetPostRevisions) in the PostTools class.
    private getHandlerForTool(toolName: string) {
      switch (toolName) {
        case "wp_list_posts":
          return this.handleListPosts.bind(this);
        case "wp_get_post":
          return this.handleGetPost.bind(this);
        case "wp_create_post":
          return this.handleCreatePost.bind(this);
        case "wp_update_post":
          return this.handleUpdatePost.bind(this);
        case "wp_delete_post":
          return this.handleDeletePost.bind(this);
        case "wp_get_post_revisions":
          return this.handleGetPostRevisions.bind(this);
        default:
          throw new Error(`Unknown tool: ${toolName}`);
      }
    }
  • The getTools method that registers all post tools, including wp_get_post_revisions, by attaching the resolved handler to each tool definition.
    public getTools(): unknown[] {
      return postToolDefinitions.map((toolDef) => ({
        ...toolDef,
        handler: this.getHandlerForTool(toolDef.name),
      }));
  • Wrapper handler method in PostTools class that extracts parameters and delegates to the core handleGetPostRevisions implementation.
    public async handleGetPostRevisions(
      client: WordPressClient,
      params: { id: number } | Record<string, unknown>,
    ): Promise<WordPressPost[] | string> {
      // Extract only the relevant parameters
      const revisionParams = {
        id: params.id as number,
      };
    
      return handleGetPostRevisions(client, revisionParams);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a retrieval/read operation but doesn't mention permission requirements, rate limits, pagination behavior, error conditions, or what happens when no revisions exist. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently communicates the core purpose and context. It's appropriately sized for a simple retrieval tool, though it could be slightly more front-loaded by moving the purpose statement earlier. Every part of the sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a retrieval tool with 100% schema coverage but no annotations and no output schema, the description provides adequate context about what the tool does but lacks important behavioral details. It doesn't explain what the return format looks like (critical with no output schema), error handling, or authentication requirements. The description is minimally complete but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions retrieving revisions for 'a specific post' which aligns with the 'id' parameter, but adds no syntax, format, or validation details. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Retrieves the revision history for a specific post' with specific details included (changes, dates, authors). It distinguishes from general post retrieval tools like wp_get_post, but doesn't explicitly differentiate from wp_get_page_revisions which serves a similar function for pages rather than posts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for 'content management and auditing purposes' but doesn't explicitly state when to use this tool versus alternatives. It doesn't provide guidance on prerequisites, when not to use it, or how it differs from wp_get_page_revisions for page content. The context is clear but lacks explicit alternatives or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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