wp_get_comment
Retrieve a specific WordPress comment by its unique ID to access comment details, moderate content, or analyze user feedback. Use this tool to fetch individual comments from your WordPress site for review or management purposes.
Instructions
Retrieves a single comment by its ID.
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 unique identifier for the comment. |
Implementation Reference
- src/tools/comments.ts:46-58 (registration)Tool registration definition in CommentTools.getTools() method, including name, description, input parameters schema, and binding to the handler function.{ name: "wp_get_comment", description: "Retrieves a single comment by its ID.", parameters: [ { name: "id", type: "number", required: true, description: "The unique identifier for the comment.", }, ], handler: this.handleGetComment.bind(this), },
- src/tools/comments.ts:182-197 (handler)The main handler function that implements the wp_get_comment tool logic: extracts comment ID, fetches comment via WordPressClient, formats details, and returns formatted string or throws error.public async handleGetComment(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { try { const { id } = params as { id: number }; const comment = await client.getComment(id); const content = `**Comment Details (ID: ${comment.id})**\n\n` + `- **Author:** ${comment.author_name}\n` + `- **Post ID:** ${comment.post}\n` + `- **Date:** ${new Date(comment.date).toLocaleString()}\n` + `- **Status:** ${comment.status}\n` + `- **Content:** ${comment.content.rendered}`; return content; } catch (_error) { throw new Error(`Failed to get comment: ${getErrorMessage(_error)}`); } }