Skip to main content
Glama

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
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe ID of the comment to update.
contentNoThe updated content for the comment.
statusNoThe new status for the comment.

Implementation Reference

  • 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)}`); } }
  • 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), },
  • 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"; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server