wp_get_post
Retrieve a WordPress post by its ID to access the full content, title, excerpt, status, date, slug, and link for content management or analysis.
Instructions
Get a single post by ID with full content.
Args:
post_id: The ID of the post to retrieve.
Returns:
Post with id, title, content (raw), excerpt, status, date, slug, and link.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"post_id": "<post_id>"
},
"name": "wp_get_post"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes |
Implementation Reference
- src/wordpress_mcp/server.py:105-116 (handler)The handler function for the 'wp_get_post' tool, registered via @mcp.tool() decorator. It retrieves the WordPressClient instance and calls its get_post method to fetch the post data.
@mcp.tool() def wp_get_post(post_id: int) -> dict: """Get a single post by ID with full content. Args: post_id: The ID of the post to retrieve. Returns: Post with id, title, content (raw), excerpt, status, date, slug, and link. """ client = get_client() return client.get_post(post_id) - src/wordpress_mcp/client.py:184-197 (helper)Supporting method in WordPressClient that performs the actual API call to retrieve a single post by ID from the WordPress REST API and formats the response.
def get_post(self, post_id: int) -> dict: """Get a single post by ID with full content.""" post = self._get(f"posts/{post_id}", params={"context": "edit"}, require_auth=True) return { "id": post["id"], "title": post["title"]["raw"] if isinstance(post["title"], dict) else post["title"], "content": post["content"]["raw"] if isinstance(post["content"], dict) else post["content"], "excerpt": post["excerpt"]["raw"] if isinstance(post["excerpt"], dict) else post["excerpt"], "status": post["status"], "date": post["date"], "slug": post["slug"], "link": post.get("link", ""), }