Skip to main content
Glama

Switch the theme

wp_activate_theme
Destructive

Activates an installed WordPress theme by its directory slug, checks site health and compatibility, and records an undo point to restore the previous theme if needed.

Instructions

Switch the active theme to an installed theme (wp_install_theme installs one), named by its directory as wp_list_themes lists it (e.g. "twentytwentyfour", a child theme, or "collection/theme" for a theme inside a collection). Refuses, with the reason, a theme that is broken (a child without its parent), that the network does not allow on this site, or whose PHP/WordPress requirement this site does not meet. Records an undo point that switches back to the previous theme; the token is returned in "undo" (null when no snapshot could be taken). A theme taken back after a failed check is replaced by the previous one again. Activating is checked like an update: test requests check the home page, this MCP endpoint, wp-admin/admin-post.php and the dashboard before and after, logged in as this connection's account (where a security plugin refuses that login, the dashboard is left out and the answer says so). Where a target then shows a new fatal error, stops answering, or this MCP endpoint loses its own answer, the activation is taken back in the same call; the answer, an error, names the error with file and line, and the files stay as they are, so a corrected version can be activated again. Code has to let WordPress finish every request: code that ends the answer itself (fastcgi_finish_request(), or exit in the shutdown action) is taken back too, since the test cannot tell it from a broken one, and background work belongs in WP-Cron. A fatal error that was there before keeps the activation with a warning; a site that cannot reach itself is activated without a test, with the warning "not checked". Where code on every request filters the active plugins or the theme, so the site does not load what WordPress lists as active, the answer says so and the list stays as it was. One activation, update or deploy into running code runs at a time; a second is refused and changes nothing. Not checked: other wp-admin screens, cron, AJAX, code that runs only on some pages or for other users; what an activation routine writes to the database stays.

Input Schema

NameRequiredDescriptionDefault
themeYesTheme folder (stylesheet) as wp_list_themes lists it in slug, e.g. "twentytwentyfour" or "collection/theme"; a child theme is named by its own folder, not its parent's.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv4.10.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Far exceeds the annotations: it discloses refusal conditions (broken child theme, network restriction, unmet PHP/WP requirement), the undo snapshot and its "undo" token (null when unavailable), the pre/post test-request set and what happens when a security plugin blocks login, automatic rollback on fatal error/endpoint failure, pre-existing fatals kept with a warning, the "not checked" fallback when the site can't reach itself, and the one-at-a-time lock. Nothing here contradicts readOnlyHint=false / destructiveHint=true / idempotentHint=false — it substantiates them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and naming, then progressive detail on refusals, testing and rollback — the ordering is sound and each block carries real information. It runs long and a few ideas repeat (the failed-check rollback is stated twice, and the undo point is revisited), which costs a point against a tighter version.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With one fully documented parameter, no output schema, and destructive/mutating semantics, the description carries the needed weight: it explains the return payload ("undo" token, null case), failure modes, and rollback guarantees. An agent has everything required to decide, call, and interpret the result.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and the description's naming guidance ("named by its directory as wp_list_themes lists it", the "collection/theme" example, child-theme-by-own-folder) largely restates the schema property description. The wp_list_themes cross-reference is a mild convenience but adds no format or validation detail beyond the schema, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ("Switch the active theme to an installed theme") and immediately differentiates siblings by naming wp_install_theme for installation and wp_list_themes for the naming convention. An agent can tell exactly which of the many theme/plugin tools to call without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent: install-then-activate is spelled out via the wp_install_theme cross-reference, and the closing "Not checked" paragraph draws the boundary of what this tool does not verify (other wp-admin screens, cron, AJAX, per-page/per-user code). It also states the concurrency exclusion — a second activation is refused and changes nothing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools