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); }

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