wp_create_post
Create and publish WordPress posts with customizable content, status, and excerpts using the WordPress REST API.
Instructions
Create a new WordPress post.
Args:
title: The title of the post.
content: The content/body of the post (supports HTML and Gutenberg blocks).
status: Post status - 'draft', 'publish', 'pending', 'private'. Default is 'draft'.
excerpt: Optional excerpt/summary of the post.
Returns:
Created post with id, title, status, date, and link.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| content | Yes | ||
| status | No | draft | |
| excerpt | No |
Implementation Reference
- src/wordpress_mcp/server.py:119-139 (handler)Handler function for the 'wp_create_post' tool, including registration via @mcp.tool() decorator and input schema via type hints and docstring. Delegates to WordPressClient.create_post.@mcp.tool() def wp_create_post( title: str, content: str, status: str = "draft", excerpt: str | None = None, ) -> dict: """Create a new WordPress post. Args: title: The title of the post. content: The content/body of the post (supports HTML and Gutenberg blocks). status: Post status - 'draft', 'publish', 'pending', 'private'. Default is 'draft'. excerpt: Optional excerpt/summary of the post. Returns: Created post with id, title, status, date, and link. """ client = get_client() return client.create_post(title=title, content=content, status=status, excerpt=excerpt)
- src/wordpress_mcp/client.py:199-223 (helper)Core helper method in WordPressClient that constructs the POST data and calls the WordPress REST API to create the post.def create_post( self, title: str, content: str, status: str = "draft", excerpt: str | None = None, ) -> dict: """Create a new post.""" data = { "title": title, "content": content, "status": status, } if excerpt: data["excerpt"] = excerpt post = self._post("posts", data) return { "id": post["id"], "title": post["title"]["rendered"], "status": post["status"], "date": post["date"], "link": post["link"], }