Appearance
Run WP-CLI Commands with AI
Easy MCP AI can let your AI client run WP-CLI commands on your WordPress site, written the same way you would type them after wp in a terminal. This guide explains what the WP-CLI tool does, how to switch it on, which commands it refuses, and how approvals and the logs apply to it.
In this article
What the WP-CLI Tool Does
The tool is called wp_cli_run. Your AI client sends it one command, such as option get blogname or plugin list --format=csv, and gets back exactly what WP-CLI would print.
- No terminal or server access is needed. The command runs inside WordPress, as the WordPress user behind the connection. WP-CLI does not have to be installed on your server, and nothing runs in a shell.
- It follows the official WP-CLI syntax, so the AI client can use the commands it already knows. The AI client can ask the tool itself for
help,help <command>, orcli has-command "<command>"to see what is available. - It fills the gaps the other tools leave: the object cache, transients, scheduled (cron) events, rewrite rules, roles and capabilities, database maintenance, and language packs.
- Only administrators can use it. The connected WordPress user needs the
manage_optionscapability.
When a command does something another Easy MCP AI tool already does, the command runs through that tool, as described in Commands That Run Through Other Tools.
Switch the WP-CLI Tool On
The WP-CLI tool is switched off on every site until an administrator turns it on.
- In WordPress, go to Easy MCP AI > Tools.
- Search for
wp_cli_rununder Unrestricted access, then expand it. - Enable
wp_cli_runand review its Require approval control. Deployment-controlled choices are locked. - Click Save changes.
- Refresh the tool list in your AI client so it loads the new tool. See Enabled Tools Not Showing in Your AI Client for the steps in each client.
To switch it off again, disable wp_cli_run in Easy MCP AI > Tools and click Save changes. On sites you manage from code, you can switch it on with wp_cli_run=on in the EASY_MCP_AI_TOOLS constant instead, which also locks the checkbox. See Switch Tools On or Off from wp-config.php.
Switching the tool on for your site does not give it to every connection. Each connection also needs access to it:
- API tokens: a token with Full access includes it as soon as it is switched on. A Custom token needs
wp_cli_runselected. A Read-only token never includes it. See Creating and Managing API Tokens. - OAuth connections (such as ChatGPT, Claude, and Claude Code): a connection approved with Full access includes it. With Custom, the WP-CLI commands permission must be ticked on the approval screen; it starts unticked. To add it to an existing connection, connect the client again and approve it with that permission. See Managing OAuth Access.
Commands That Run Through Other Tools
Many WP-CLI commands do the same job as an existing Easy MCP AI tool. For example, plugin list uses the plugin list tool, user list uses the user list tool, and post delete uses the delete tools. When a command matches a tool like this, the command runs through that tool, so:
- That tool must be switched on for your site. If it is off, the command is refused with a message saying the tool is switched off and where an administrator can switch it on.
- The connection must be allowed to use that tool.
- Every check that tool makes still applies, and its changes are recorded under that tool's name.
Installing, deleting, and updating plugins, themes, and WordPress itself use six tools that are also switched off by default. Find and enable the required tool by its ID in Easy MCP AI > Tools:
| Tool | What it does | Capability the user needs |
|---|---|---|
wp_install_plugin | Installs a plugin by wordpress.org slug or from a ZIP or URL, without activating it | install_plugins; ZIP sources also need upload_plugins |
wp_delete_plugin | Deletes an inactive plugin's files without running its uninstall routine | delete_plugins |
wp_uninstall_plugin | Runs a plugin's uninstall routine, which removes its data, then deletes its files | delete_plugins |
wp_install_theme | Installs a theme by wordpress.org slug or from a ZIP or URL, plus its wordpress.org parent if available and needed, without activating it | install_themes; ZIP sources also need upload_themes |
wp_delete_theme | Deletes an installed theme that is not active | delete_themes |
wp_update_core | Updates WordPress to the latest version, or to a version you name | update_core |
For example, plugin install hello-dolly needs wp_install_plugin switched on. Your AI client can also call these tools directly, without the WP-CLI tool. With Custom OAuth access, each group has its own permission on the approval screen: Plugin installs and deletions, Theme installs and deletions, and WordPress core update. If DISALLOW_FILE_MODS is set in wp-config.php, every install, delete, and update is refused.
Install from a ZIP or URL
The plugin install and theme install commands also accept package URLs. For example, send plugin install https://downloads.example.com/my-plugin.zip or theme install https://downloads.example.com/my-theme.zip to wp_cli_run, replacing the example URL with your package's real address. Use public HTTPS URLs; signed download links, WordPress.org plugin or theme pages, and https://github.com/<owner>/<repo>/releases/latest are also supported. Server-local ZIP paths remain refused.
For direct calls to wp_install_plugin or wp_install_theme, pass exactly one source:
slug: a WordPress.org plugin or theme slug.url: a public HTTPS package URL.file: a client-provided attachment handoff with bothdownload_urlandfile_id. A bare file ID or local path is not enough, and your AI client must support file handoff.content_base64: the ZIP encoded as Base64, up to 2 MB after decoding.
Downloaded ZIPs have a default 50 MB limit. Download hosts and redirects must use public HTTPS; private-network addresses and URLs containing a username or password are refused. For ZIP sources, the direct tools also accept folder to choose the destination folder. version applies only to WordPress.org slug installs, including WordPress.org plugin or theme page URLs.
ZIP installs additionally require the WordPress upload_plugins or upload_themes capability. Installing does not activate a new plugin or theme: use wp_activate_plugin with the returned plugin, or wp_switch_theme with the returned stylesheet. A wp_cli_run install command can request activation separately with --activate. If the destination is already occupied, installation is refused unless you set force: true in a direct tool call or pass --force in WP-CLI; replacement preserves the existing active state.
What the WP-CLI Tool Refuses
Some commands could expose secrets, run arbitrary code, or cut off the connection itself, so the tool refuses them and says why:
| Refused | Why |
|---|---|
eval, eval-file, shell | They run arbitrary PHP code |
config commands | They edit or print wp-config.php, which holds your database password and security keys |
db query, db export, db import, db reset, and other commands that run raw SQL or dump, restore, or drop tables | Database maintenance such as db size, db check, db optimize, and db repair is allowed |
| Shell syntax, such as pipes (` | ), redirects, $variables`, and wildcards |
| Commands added by other plugins | Only WP-CLI's own commands are available |
Developer and setup commands, such as scaffold, package, server, core download, and core install | They have no place on a running site |
| Arguments that read a file on your server, such as installing a plugin from a ZIP path | Use a WordPress.org slug or public HTTPS package URL with wp_cli_run; it refuses server-local ZIP paths. To install an attached or inline ZIP, call wp_install_plugin or wp_install_theme directly |
A few settings are never written by the WP-CLI tool, because changing them could break the connection or the site. For example, option update siteurl is refused. The refusal names the command that does the job safely, such as search-replace for a domain change or plugin activate instead of writing active_plugins. The tool also never reads or changes Easy MCP AI's own settings.
A command that asks for confirmation in a terminal ([y/n]) is refused unless it includes --yes. A command that names many items at once is limited, for example to 5 plugins per plugin delete; the message tells the AI client to run it in smaller groups.
Approvals, the Audit Log, and Change History
Approvals. When Require approval applies to wp_cli_run, a command that changes something pauses until you approve it. The AI client shows you a preview of the change, for example an option's old and new value, and a link to approve it. After you approve, ask the AI client to run the same command again. Commands that only read, such as option get or plugin list, never pause.
- A change the WP-CLI tool makes itself, such as
option updateortransient delete, pauses when Require approval applies towp_cli_run. - A command that runs through another tool follows that tool's approval rules. The plugin, theme, and core tools always pause.
Configure Require approval for wp_cli_run in Easy MCP AI > Tools and click Save changes. Deployment approval settings retain precedence. Read-only command and delegated-tool exceptions described above still apply; there is no Settings-screen global approval switch in this interface.
Audit log. Every command appears in Easy MCP AI > Activity as a wp_cli_run call, with passwords and keys in the command masked. One command counts as one call toward your rate limit, however many tools it uses. See Using the Easy MCP AI Audit Log.
Change history. What is recorded depends on how the command ran:
- A command that ran through another tool is recorded under that tool, and can be reviewed like that tool's other changes.
- A change the WP-CLI tool makes itself, such as
option update, is recorded underwp_cli_run. Most of these changes cannot be restored from Change History. - Transients, and any change to files (installing or deleting plugins and themes, or updating WordPress), are never recorded.
Each result tells the AI client which of its changes were not recorded. To restore a recorded change, see Restore AI Changes from Change History.
On a Multisite Network
On a multisite network, a command runs on the site the AI client is connected to. A --url or --blog argument must name that same site. Network-wide commands, such as site and super-admin commands or network plugin activation, need a super admin with the matching network capability. The six plugin, theme, and core tools also need a super admin on a network.
Try These Prompts
Once the tool is switched on, ask your AI client:
Flush the object cache and the rewrite rules.Delete expired transients and tell me how many were removed.List the scheduled cron events and flag any that are overdue.Show the size of the database.