Skip to main content
Glama

wpnav_delete_comment

Remove unwanted comments from WordPress by ID with optional permanent deletion. This action cannot be undone once executed.

Instructions

Delete a comment by ID. WARNING: This action cannot be undone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWordPress comment ID
forceNoForce permanent deletion (skip trash). Default: false

Implementation Reference

  • The core handler function that performs the deletion of a WordPress comment via REST API DELETE request to `/wp/v2/comments/${id}`. Supports optional `force` parameter for permanent deletion (bypassing trash). Includes validation, error handling for writes_disabled, and detailed error responses.
    handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Comment'); const params = new URLSearchParams(); if (args.force) { params.append('force', 'true'); } const result = await context.wpRequest(`/wp/v2/comments/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: args.force ? 'Comment permanently deleted' : 'Comment moved to trash', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'DELETE_FAILED', message: errorMessage, context: { resource_type: 'comment', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check comment ID exists with wpnav_get_comment', }, }, null, 2), }], isError: true, }; } },
  • The complete tool registration for 'wpnav_delete_comment' using toolRegistry.register. Includes full definition (name, description, inputSchema), handler reference, and category assignment within the registerContentTools function.
    toolRegistry.register({ definition: { name: 'wpnav_delete_comment', description: 'Delete a comment by ID. WARNING: This action cannot be undone.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress comment ID' }, force: { type: 'boolean', description: 'Force permanent deletion (skip trash). Default: false', default: false }, }, required: ['id'], }, }, handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Comment'); const params = new URLSearchParams(); if (args.force) { params.append('force', 'true'); } const result = await context.wpRequest(`/wp/v2/comments/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: args.force ? 'Comment permanently deleted' : 'Comment moved to trash', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'DELETE_FAILED', message: errorMessage, context: { resource_type: 'comment', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check comment ID exists with wpnav_get_comment', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.CONTENT, });
  • Static schema definition for the wpnav_delete_comment tool, likely used for client-side tool discovery, OpenAPI generation, or MCP protocol compliance.
    { name: 'wpnav_delete_comment', description: 'Delete a comment by ID. WARNING: This action cannot be undone.', inputSchema: { type: 'object' as const, properties: { id: { type: 'number' as const, description: 'WordPress comment ID', }, force: { type: 'boolean' as const, description: 'Force permanent deletion (skip trash). Default: false', default: false, }, }, 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