wp_update_comment
Modify existing WordPress comments by updating content or changing status using the MCP WordPress Server tool.
Instructions
Updates an existing comment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| id | Yes | The ID of the comment to update. | |
| content | No | The updated content for the comment. | |
| status | No | The new status for the comment. |
Implementation Reference
- src/tools/comments.ts:209-217 (handler)The handler function implementing the core logic of the 'wp_update_comment' tool. It casts input parameters to UpdateCommentRequest type, invokes the WordPress client's updateComment method, and returns a success message or throws an error.public async handleUpdateComment(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { try { const updateParams = params as unknown as UpdateCommentRequest & { id: number }; const comment = await client.updateComment(updateParams); return `✅ Comment ${comment.id} updated successfully. New status: ${comment.status}.`; } catch (_error) { throw new Error(`Failed to update comment: ${getErrorMessage(_error)}`); } }
- src/tools/comments.ts:88-111 (registration)Registration of the 'wp_update_comment' MCP tool in CommentTools.getTools(), defining name, description, input parameters schema, and binding to the handler function.{ name: "wp_update_comment", description: "Updates an existing comment.", parameters: [ { name: "id", type: "number", required: true, description: "The ID of the comment to update.", }, { name: "content", type: "string", description: "The updated content for the comment.", }, { name: "status", type: "string", description: "The new status for the comment.", enum: ["hold", "approve", "spam", "trash"], }, ], handler: this.handleUpdateComment.bind(this), },
- src/types/wordpress.ts:469-472 (schema)TypeScript interface UpdateCommentRequest defining the structure for comment update data, used for type safety in the tool handler. Extends CreateCommentRequest partially, adds required 'id' and optional 'status'.export interface UpdateCommentRequest extends Partial<Omit<CreateCommentRequest, "status">> { id: number; status?: "approved" | "unapproved" | "spam" | "trash"; }