wpnav_install_theme
Install WordPress themes from WordPress.org using theme slugs. Optionally activate themes immediately after installation to customize your site's appearance.
Instructions
Install a WordPress theme from WordPress.org by slug. Optionally activate after installation. Uses WP Navigator custom endpoint.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Theme slug from WordPress.org (e.g., "flavor", "flavor-developer") | |
| activate | No | Activate theme after installation (default: false) |
Implementation Reference
- src/tools/themes/index.ts:95-130 (handler)The handler function that implements the core logic of the wpnav_install_theme tool. It validates input, makes a POST request to the custom WP Navigator endpoint /wpnav/v1/themes/install, and handles success/error responses.handler: async (args, context) => { try { validateRequired(args, ['slug']); const result = await context.wpRequest('/wpnav/v1/themes/install', { method: 'POST', body: JSON.stringify({ slug: args.slug, activate: args.activate || false, }), }); 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' : 'INSTALL_FAILED', message: errorMessage, context: { resource_type: 'theme', slug: args.slug, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme slug exists on WordPress.org', }, }, null, 2), }], isError: true, }; } },
- src/tools/themes/index.ts:95-129 (handler)The handler function that implements the wpnav_install_theme tool. It validates the slug input, sends a POST request to the custom /wpnav/v1/themes/install endpoint with the slug and optional activate flag, returns the result or a formatted error response.handler: async (args, context) => { try { validateRequired(args, ['slug']); const result = await context.wpRequest('/wpnav/v1/themes/install', { method: 'POST', body: JSON.stringify({ slug: args.slug, activate: args.activate || false, }), }); 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' : 'INSTALL_FAILED', message: errorMessage, context: { resource_type: 'theme', slug: args.slug, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme slug exists on WordPress.org', }, }, null, 2), }], isError: true, }; }
- src/tools/themes/index.ts:83-94 (schema)The input schema and metadata definition for the wpnav_install_theme tool, specifying required 'slug' parameter and optional 'activate' boolean.definition: { name: 'wpnav_install_theme', description: 'Install a WordPress theme from WordPress.org by slug. Optionally activate after installation. Uses WP Navigator custom endpoint.', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Theme slug from WordPress.org (e.g., "flavor", "flavor-developer")' }, activate: { type: 'boolean', description: 'Activate theme after installation (default: false)', default: false }, }, required: ['slug'], }, },
- src/tools/themes/index.ts:82-132 (registration)The toolRegistry.register call that registers the wpnav_install_theme tool, including its name, description, input schema, handler, and category.toolRegistry.register({ definition: { name: 'wpnav_install_theme', description: 'Install a WordPress theme from WordPress.org by slug. Optionally activate after installation. Uses WP Navigator custom endpoint.', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Theme slug from WordPress.org (e.g., "flavor", "flavor-developer")' }, activate: { type: 'boolean', description: 'Activate theme after installation (default: false)', default: false }, }, required: ['slug'], }, }, handler: async (args, context) => { try { validateRequired(args, ['slug']); const result = await context.wpRequest('/wpnav/v1/themes/install', { method: 'POST', body: JSON.stringify({ slug: args.slug, activate: args.activate || false, }), }); 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' : 'INSTALL_FAILED', message: errorMessage, context: { resource_type: 'theme', slug: args.slug, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme slug exists on WordPress.org', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.THEMES, });
- src/tools/themes/index.ts:82-132 (registration)The toolRegistry.register call that registers the wpnav_install_theme tool, including its definition (schema), handler, and category.toolRegistry.register({ definition: { name: 'wpnav_install_theme', description: 'Install a WordPress theme from WordPress.org by slug. Optionally activate after installation. Uses WP Navigator custom endpoint.', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Theme slug from WordPress.org (e.g., "flavor", "flavor-developer")' }, activate: { type: 'boolean', description: 'Activate theme after installation (default: false)', default: false }, }, required: ['slug'], }, }, handler: async (args, context) => { try { validateRequired(args, ['slug']); const result = await context.wpRequest('/wpnav/v1/themes/install', { method: 'POST', body: JSON.stringify({ slug: args.slug, activate: args.activate || false, }), }); 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' : 'INSTALL_FAILED', message: errorMessage, context: { resource_type: 'theme', slug: args.slug, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check theme slug exists on WordPress.org', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.THEMES, });
- src/tools/themes/index.ts:83-94 (schema)The input schema definition for the wpnav_install_theme tool, specifying parameters slug (required string) and activate (optional boolean).definition: { name: 'wpnav_install_theme', description: 'Install a WordPress theme from WordPress.org by slug. Optionally activate after installation. Uses WP Navigator custom endpoint.', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Theme slug from WordPress.org (e.g., "flavor", "flavor-developer")' }, activate: { type: 'boolean', description: 'Activate theme after installation (default: false)', default: false }, }, required: ['slug'], }, },
- src/tools.ts:1039-1058 (schema)Static tool schema definition in the exported tools array, used for MCP tool discovery.{ name: 'wpnav_install_theme', description: 'Install a WordPress theme from WordPress.org by slug. Changes are logged in audit trail.', inputSchema: { type: 'object' as const, properties: { slug: { type: 'string' as const, description: 'Theme slug from WordPress.org (e.g., "twentytwentyfour")', }, activate: { type: 'boolean' as const, description: 'Activate theme after installation (default: false)', default: false, }, }, required: ['slug'], }, },
- src/tools/index.ts:30-30 (registration)Call to registerThemeTools() which includes registration of wpnav_install_theme among other theme tools.registerThemeTools();
- src/tools.ts:1039-1040 (registration)Tool definition listing in src/tools.ts that documents the wpnav_install_theme schema.{ name: 'wpnav_install_theme',