create_post
Generate and publish WordPress posts by specifying title, content, and status. Automate post creation through REST API integration with JSON-RPC 2.0 protocol.
Instructions
Create a new WordPress post
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Post content | |
| password | No | WordPress password (overrides WORDPRESS_PASSWORD env var) | |
| siteUrl | No | WordPress site URL (overrides WORDPRESS_SITE_URL env var) | |
| status | No | Post status (draft, publish, etc.) | draft |
| title | Yes | Post title | |
| username | No | WordPress username (overrides WORDPRESS_USERNAME env var) |
Implementation Reference
- src/index.ts:216-229 (handler)The handler logic for the 'create_post' tool. It validates that title and content are provided, then uses axios to POST to the WordPress /posts endpoint with the provided title, content, and optional status (default 'draft'), returning the created post data.case 'create_post': if (!params.title || !params.content) { throw new McpError( ErrorCode.InvalidParams, 'Title and content are required for creating a post' ); } const createResponse = await client.post('/posts', { title: params.title, content: params.content, status: params.status || 'draft', }); return createResponse.data;
- src/index.ts:63-93 (schema)Input schema for the 'create_post' tool, defining properties for siteUrl, username, password, title, content, status with required fields title and content.inputSchema: { type: 'object', properties: { siteUrl: { type: 'string', description: 'WordPress site URL (overrides WORDPRESS_SITE_URL env var)', }, username: { type: 'string', description: 'WordPress username (overrides WORDPRESS_USERNAME env var)', }, password: { type: 'string', description: 'WordPress password (overrides WORDPRESS_PASSWORD env var)', }, title: { type: 'string', description: 'Post title', }, content: { type: 'string', description: 'Post content', }, status: { type: 'string', description: 'Post status (draft, publish, etc.)', default: 'draft', }, }, required: ['title', 'content'], },
- src/index.ts:60-94 (registration)Registration of the 'create_post' tool in the ListToolsRequestSchema handler response, including name, description, and full input schema.{ name: 'create_post', description: 'Create a new WordPress post', inputSchema: { type: 'object', properties: { siteUrl: { type: 'string', description: 'WordPress site URL (overrides WORDPRESS_SITE_URL env var)', }, username: { type: 'string', description: 'WordPress username (overrides WORDPRESS_USERNAME env var)', }, password: { type: 'string', description: 'WordPress password (overrides WORDPRESS_PASSWORD env var)', }, title: { type: 'string', description: 'Post title', }, content: { type: 'string', description: 'Post content', }, status: { type: 'string', description: 'Post status (draft, publish, etc.)', default: 'draft', }, }, required: ['title', 'content'], }, },