wpnav_delete_theme
Delete an installed WordPress theme that is not currently active. Switch to a different theme first, and ensure no child themes are using it.
Instructions
Delete an installed WordPress theme. The theme must not be active - switch to a different theme first. Cannot delete parent theme while child theme is active.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stylesheet | Yes | Theme stylesheet from wpnav_list_themes "stylesheet" field (e.g., "flavor") |
Implementation Reference
- src/tools/themes/index.ts:255-286 (handler)The async handler function that validates the stylesheet parameter and sends a DELETE request to the `/wpnav/v1/themes/{stylesheet}` endpoint to delete the theme. Handles errors including writes_disabled.handler: async (args, context) => { try { validateRequired(args, ['stylesheet']); const result = await context.wpRequest(`/wpnav/v1/themes/${args.stylesheet}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(result, 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: 'theme', stylesheet: args.stylesheet, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme is not active and exists with wpnav_list_themes', }, }, null, 2), }], isError: true, }; } },
- src/tools/themes/index.ts:244-254 (schema)The tool definition including name, description, and inputSchema for validating the 'stylesheet' parameter.definition: { name: 'wpnav_delete_theme', description: 'Delete an installed WordPress theme. The theme must not be active - switch to a different theme first. Cannot delete parent theme while child theme is active.', inputSchema: { type: 'object', properties: { stylesheet: { type: 'string', description: 'Theme stylesheet from wpnav_list_themes "stylesheet" field (e.g., "flavor")' }, }, required: ['stylesheet'], }, },
- src/tools/themes/index.ts:243-288 (registration)The toolRegistry.register call that registers the wpnav_delete_theme tool with its schema, handler, and category.toolRegistry.register({ definition: { name: 'wpnav_delete_theme', description: 'Delete an installed WordPress theme. The theme must not be active - switch to a different theme first. Cannot delete parent theme while child theme is active.', inputSchema: { type: 'object', properties: { stylesheet: { type: 'string', description: 'Theme stylesheet from wpnav_list_themes "stylesheet" field (e.g., "flavor")' }, }, required: ['stylesheet'], }, }, handler: async (args, context) => { try { validateRequired(args, ['stylesheet']); const result = await context.wpRequest(`/wpnav/v1/themes/${args.stylesheet}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(result, 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: 'theme', stylesheet: args.stylesheet, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme is not active and exists with wpnav_list_themes', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.THEMES, });
- src/tools.ts:1089-1103 (schema)Static tool schema definition exported in tools.ts, likely for MCP tool listing or validation.{ name: 'wpnav_delete_theme', description: 'Delete a WordPress theme by stylesheet name. Theme must not be active. WARNING: This permanently deletes the theme files.', inputSchema: { type: 'object' as const, properties: { stylesheet: { type: 'string' as const, description: 'Theme stylesheet name (slug)', }, }, required: ['stylesheet'], }, },