update_post
Modify an existing WordPress post by updating its title, content, or status using the WordPress MCP Server. Requires post ID and site credentials for authentication and customization.
Instructions
Update an existing WordPress post
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | New post content | |
| password | No | WordPress password (overrides WORDPRESS_PASSWORD env var) | |
| postId | Yes | Post ID to update | |
| siteUrl | No | WordPress site URL (overrides WORDPRESS_SITE_URL env var) | |
| status | No | New post status (draft, publish, etc.) | |
| title | No | New post title | |
| username | No | WordPress username (overrides WORDPRESS_USERNAME env var) |
Implementation Reference
- src/index.ts:239-255 (handler)Executes the update_post tool by validating the postId parameter, conditionally adding title, content, or status to the update data, and performing a POST request to the WordPress REST API endpoint `/posts/{postId}` to update the post.case 'update_post': if (!params.postId) { throw new McpError( ErrorCode.InvalidParams, 'Post ID is required for updating a post' ); } const updateData: Record<string, any> = {}; if (params.title) updateData.title = params.title; if (params.content) updateData.content = params.content; if (params.status) updateData.status = params.status; const updateResponse = await client.post( `/posts/${params.postId}`, updateData ); return updateResponse.data;
- src/index.ts:126-162 (schema)Tool registration including name, description, and input schema definition for the update_post tool.{ name: 'update_post', description: 'Update an existing 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)', }, postId: { type: 'number', description: 'Post ID to update', }, title: { type: 'string', description: 'New post title', }, content: { type: 'string', description: 'New post content', }, status: { type: 'string', description: 'New post status (draft, publish, etc.)', }, }, required: ['postId'], },
- src/index.ts:58-165 (registration)Registration of the ListToolsRequestSchema handler that exposes the update_post tool in the tools list.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { 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'], }, }, { name: 'get_posts', description: 'Get WordPress posts', 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)', }, perPage: { type: 'number', description: 'Number of posts per page', default: 10, }, page: { type: 'number', description: 'Page number', default: 1, }, }, }, }, { name: 'update_post', description: 'Update an existing 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)', }, postId: { type: 'number', description: 'Post ID to update', }, title: { type: 'string', description: 'New post title', }, content: { type: 'string', description: 'New post content', }, status: { type: 'string', description: 'New post status (draft, publish, etc.)', }, }, required: ['postId'], }, }, ], }));