wpnav_revert_theme
Restore the previously active WordPress theme to undo recent theme changes using stored backup data.
Instructions
Revert to the previously active theme. WordPress stores the previous theme when switching. Use this to quickly undo a theme change.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/themes/index.ts:303-331 (handler)Handler function that POSTs to the custom /wpnav/v1/themes/revert endpoint to revert the active theme to the previous one, with error handling for writes_disabled and other failures.handler: async (args, context) => { try { const result = await context.wpRequest('/wpnav/v1/themes/revert', { method: 'POST', }); 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' : 'REVERT_FAILED', message: errorMessage, context: { resource_type: 'theme', suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Ensure a previous theme exists to revert to', }, }, null, 2), }], isError: true, }; } },
- src/tools/themes/index.ts:294-302 (schema)Input schema and metadata definition for the wpnav_revert_theme tool (no input parameters required).definition: { name: 'wpnav_revert_theme', description: 'Revert to the previously active theme. WordPress stores the previous theme when switching. Use this to quickly undo a theme change.', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/tools/themes/index.ts:293-333 (registration)Registration of the wpnav_revert_theme tool via toolRegistry.register within the registerThemeTools function.toolRegistry.register({ definition: { name: 'wpnav_revert_theme', description: 'Revert to the previously active theme. WordPress stores the previous theme when switching. Use this to quickly undo a theme change.', inputSchema: { type: 'object', properties: {}, required: [], }, }, handler: async (args, context) => { try { const result = await context.wpRequest('/wpnav/v1/themes/revert', { method: 'POST', }); 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' : 'REVERT_FAILED', message: errorMessage, context: { resource_type: 'theme', suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Ensure a previous theme exists to revert to', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.THEMES, });
- src/tools/index.ts:30-30 (registration)Invocation of registerThemeTools() which includes registration of wpnav_revert_theme.registerThemeTools();