wp_create_comment
Add a comment to a WordPress post by specifying the post ID, comment content, and optional author details to facilitate user engagement and feedback.
Instructions
Creates a new comment on a post.
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. | |
| post | Yes | The ID of the post to comment on. | |
| content | Yes | The content of the comment. | |
| author_name | No | The name of the comment author. | |
| author_email | No | The email of the comment author. |
Implementation Reference
- src/tools/comments.ts:59-87 (registration)MCP tool registration for 'wp_create_comment', including name, description, input schema (parameters), and handler reference.{ name: "wp_create_comment", description: "Creates a new comment on a post.", parameters: [ { name: "post", type: "number", required: true, description: "The ID of the post to comment on.", }, { name: "content", type: "string", required: true, description: "The content of the comment.", }, { name: "author_name", type: "string", description: "The name of the comment author.", }, { name: "author_email", type: "string", description: "The email of the comment author.", }, ], handler: this.handleCreateComment.bind(this), },
- src/tools/comments.ts:199-207 (handler)The core handler function for the 'wp_create_comment' tool. It casts input parameters to CreateCommentRequest, calls the WordPressClient's createComment method, and returns a success message with the new comment ID or throws a formatted error.public async handleCreateComment(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const createParams = params as unknown as CreateCommentRequest; try { const comment = await client.createComment(createParams); return `✅ Comment created successfully with ID: ${comment.id}`; } catch (_error) { throw new Error(`Failed to create comment: ${getErrorMessage(_error)}`); } }