wp_update_post
Modify existing WordPress posts by updating title, content, status, or excerpt using the post ID. This tool helps maintain current content and manage publishing workflows.
Instructions
Update an existing WordPress post.
Args:
post_id: The ID of the post to update.
title: New title (optional).
content: New content (optional).
status: New status - 'draft', 'publish', 'pending', 'private', 'trash' (optional).
excerpt: New excerpt (optional).
Returns:
Updated post with id, title, status, date, and link.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes | ||
| title | No | ||
| content | No | ||
| status | No | ||
| excerpt | No |
Implementation Reference
- src/wordpress_mcp/server.py:141-164 (handler)MCP tool handler function for 'wp_update_post'. Includes input schema via type hints and docstring, registered using @mcp.tool() decorator, delegates to WordPressClient.update_post.@mcp.tool() def wp_update_post( post_id: int, title: str | None = None, content: str | None = None, status: str | None = None, excerpt: str | None = None, ) -> dict: """Update an existing WordPress post. Args: post_id: The ID of the post to update. title: New title (optional). content: New content (optional). status: New status - 'draft', 'publish', 'pending', 'private', 'trash' (optional). excerpt: New excerpt (optional). Returns: Updated post with id, title, status, date, and link. """ client = get_client() return client.update_post( post_id=post_id, title=title, content=content, status=status, excerpt=excerpt )
- src/wordpress_mcp/client.py:225-255 (helper)Core implementation logic in WordPressClient.update_post method: constructs update data, performs POST to WP REST API endpoint /posts/{post_id}, returns simplified post info.def update_post( self, post_id: int, title: str | None = None, content: str | None = None, status: str | None = None, excerpt: str | None = None, ) -> dict: """Update an existing post.""" data = {} if title is not None: data["title"] = title if content is not None: data["content"] = content if status is not None: data["status"] = status if excerpt is not None: data["excerpt"] = excerpt if not data: raise ValueError("At least one field must be provided to update") post = self._post(f"posts/{post_id}", data) return { "id": post["id"], "title": post["title"]["rendered"], "status": post["status"], "date": post["date"], "link": post["link"], }