Skip to main content
Glama

wpnav_delete_category

Delete a WordPress category by ID and reassign its posts to Uncategorized. This permanent action cannot be undone.

Instructions

Delete a WordPress category by ID. Posts in this category will be reassigned to Uncategorized. WARNING: This action cannot be undone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWordPress category ID
forceNoForce permanent deletion. Default: true

Implementation Reference

  • Executes the deletion of a WordPress category via WP REST API DELETE /wp/v2/categories/{id}. Validates ID, handles force param, returns success/error JSON responses with audit-friendly messages.
    handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Category'); const params = new URLSearchParams({ force: String(args.force !== false) }); const result = await context.wpRequest(`/wp/v2/categories/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: 'Category deleted successfully', }, 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: 'category', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check category ID exists with wpnav_get_category', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.TAXONOMY,
  • Input schema validating required 'id' (number) and optional 'force' (boolean, defaults true).
    inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress category ID' }, force: { type: 'boolean', description: 'Force permanent deletion. Default: true', default: true }, }, required: ['id'], },
  • Registers the wpnav_delete_category tool with toolRegistry, including definition (name, desc, schema), handler, and TAXONOMY category.
    toolRegistry.register({ definition: { name: 'wpnav_delete_category', description: 'Delete a WordPress category by ID. Posts in this category will be reassigned to Uncategorized. WARNING: This action cannot be undone.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress category ID' }, force: { type: 'boolean', description: 'Force permanent deletion. Default: true', default: true }, }, required: ['id'], }, }, handler: async (args, context) => { try { validateRequired(args, ['id']); const id = validateId(args.id, 'Category'); const params = new URLSearchParams({ force: String(args.force !== false) }); const result = await context.wpRequest(`/wp/v2/categories/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: 'Category deleted successfully', }, 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: 'category', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check category ID exists with wpnav_get_category', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.TAXONOMY, });
  • Duplicate schema definition in central tools list, likely for API documentation or schema generation.
    { name: 'wpnav_delete_category', description: 'Delete a WordPress category by ID. Posts in this category will be reassigned to Uncategorized. WARNING: This action cannot be undone.', inputSchema: { type: 'object' as const, properties: { id: { type: 'number' as const, description: 'WordPress category ID', }, force: { type: 'boolean' as const, description: 'Force permanent deletion. Default: true', default: true, }, }, 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