Skip to main content
Glama

wpnav_update_comment

Modify WordPress comment status or content and log changes in the audit trail. Use to approve, hold, mark as spam, trash, or edit comment text.

Instructions

Update a comment. Can change status (approve/hold/spam) or content. Changes are logged in audit trail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWordPress comment ID
statusNoComment status: approve, hold, spam, trash
contentNoComment content

Implementation Reference

  • The async handler function implementing the core logic of wpnav_update_comment: validates input, constructs update payload for status/content, performs WP REST API POST to /wp/v2/comments/{id}, returns success/error messages.
    handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Comment'); const updateData: any = {}; if (args.status) updateData.status = args.status; if (args.content) updateData.content = args.content; if (Object.keys(updateData).length === 0) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'validation_failed', code: 'VALIDATION_FAILED', message: 'At least one field (status or content) must be provided', context: { resource_type: 'comment', resource_id: id }, }, null, 2), }], isError: true, }; } const result = await context.wpRequest(`/wp/v2/comments/${id}`, { method: 'POST', body: JSON.stringify(updateData), }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, status: result.status, message: 'Comment updated successfully' }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; return { content: [{ type: 'text', text: JSON.stringify({ error: 'operation_failed', code: 'UPDATE_FAILED', message: errorMessage, context: { resource_type: 'comment', resource_id: args.id, suggestion: 'Use wpnav_get_comment to verify comment exists' }, }, null, 2), }], isError: true, }; } },
  • The toolRegistry.register call that registers wpnav_update_comment with its definition (name, description, inputSchema), handler, and category.
    toolRegistry.register({ definition: { name: 'wpnav_update_comment', description: 'Update a comment. Can change status (approve/hold/spam) or content. Changes are logged in audit trail.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress comment ID' }, status: { type: 'string', enum: ['approve', 'hold', 'spam', 'trash'], description: 'Comment status: approve, hold, spam, trash' }, content: { type: 'string', description: 'Comment content' }, }, required: ['id'], }, }, handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Comment'); const updateData: any = {}; if (args.status) updateData.status = args.status; if (args.content) updateData.content = args.content; if (Object.keys(updateData).length === 0) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'validation_failed', code: 'VALIDATION_FAILED', message: 'At least one field (status or content) must be provided', context: { resource_type: 'comment', resource_id: id }, }, null, 2), }], isError: true, }; } const result = await context.wpRequest(`/wp/v2/comments/${id}`, { method: 'POST', body: JSON.stringify(updateData), }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, status: result.status, message: 'Comment updated successfully' }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; return { content: [{ type: 'text', text: JSON.stringify({ error: 'operation_failed', code: 'UPDATE_FAILED', message: errorMessage, context: { resource_type: 'comment', resource_id: args.id, suggestion: 'Use wpnav_get_comment to verify comment exists' }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.CONTENT, });
  • The input schema definition for wpnav_update_comment exported in the main tools list for MCP tool discovery.
    { name: 'wpnav_update_comment', description: 'Update a comment. Can change status (approve/hold/spam) or content. Changes are logged in audit trail.', inputSchema: { type: 'object' as const, properties: { id: { type: 'number' as const, description: 'WordPress comment ID', }, status: { type: 'string' as const, description: 'Comment status: approve, hold, spam, trash', enum: ['approve', 'hold', 'spam', 'trash'], }, content: { type: 'string' as const, description: 'Comment content', }, }, required: ['id'], },

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/littlebearapps/wp-navigator-mcp'

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