# Run WP-CLI commands

> Run allowlisted WP-CLI commands on an environment from the dashboard, API, or MCP, and learn why a command is refused.

Source: https://docs.wpwaterfall.com/tools-wp-cli

WP-CLI is the command line for WordPress. You run allowlisted commands on one environment from the Tools tab, the API, or MCP. Each command is a job, and the output shows when it finishes.

Needs WordPress on the environment. See [Run a site without WordPress](https://docs.wpwaterfall.com/run-a-site-without-wordpress).

## How do I run a command?

1. Open the site, pick the environment in the top bar, and choose **Tools**, then **WP-CLI**.
2. Type the command without the `wp` prefix, for example `cache flush`.
3. Click **Run command**.

The page shows the output, the exit code, and the run time. **Recent commands** lists past runs so you can run them again.

## Why was my command refused?

WP Waterfall checks each command twice: once in your browser as advice, and again on the server, which decides. The agent that runs the command applies the allowlist a third time. A refused command shows the reason and a link to the docs. The API answers 422 with the same link.

## Which commands change code?

On a live environment, commands that change code are refused, such as `plugin install`, `eval`, `plugin activate`, and `plugin toggle`. Nothing may write code on live. Deploy from Git instead. See [How Git deploys work](https://docs.wpwaterfall.com/code/git-workflow).

On staging and preview environments in Git mode, code writes are refused too, but `plugin activate` and `plugin toggle` run because they change only the database. If a plugin needs writable code, switch staging to SFTP mode with the **SFTP | Git** switch on the **Code** card on Info.

## What changes on a WordPress network?

On a [WordPress Multisite](https://docs.wpwaterfall.com/wordpress-multisite) network, WP Waterfall adds `--url` with the network address to every command. A `--url` you add wins, so `option get home --url=address/blog` reads one site.

These network commands are allowed: `site list`, `site create --slug=blog`, `site archive`, `site unarchive`, `site activate`, `site deactivate`, `super-admin list`, `super-admin add`, `super-admin remove`, `plugin activate --network`, `theme enable --network`, and `theme disable --network`.

## Quick answers

**The browser warned me, but the command ran.**
The browser check is advice. The server made the final call.

**Can I run a command on staging?**
Yes. Pick staging in the top bar.

**Why does `db export` or `db query` ask for my password?**
Both can read every table, password hashes included. They follow the rule of your own SQL on the [Database tab](https://docs.wpwaterfall.com/database-access): a role with the credentials permission, a sign in confirmed in the last 10 minutes, and not a WP Waterfall staff member acting as you. An API key or MCP connection works when the person who made it holds that permission. `db export` writes a `.sql` file inside the site folder.

**Why can I not change WordPress users as a Site Developer?**
Commands that create, change, or delete a WordPress user (`user create`, `user update`, `user delete`, `user set-role`, `user add-role`, `user remove-role`, `user reset-password`), `super-admin add` and `remove`, and changes to `users_can_register`, `default_role`, or `admin_email` follow the rule of the [WordPress users](https://docs.wpwaterfall.com/wordpress-users) page: they need a role that manages WordPress users. A Site Developer can still read users with `user list` and `user get`.

**Why can I not print a password hash?**
The runner refuses `user_pass` and `user_activation_key` in `--fields` or `--field`, and it refuses the session tokens and application passwords in user meta. `user get` needs `--fields` or `--field`, because without them WP-CLI can print every field. Browse the users table on the Database tab instead, where the credentials permission decides who sees the real values.

## API and MCP

- `POST /v1/environments/{id}/tools/wp-cli` takes `command`.
- MCP tool: `run_wp_cli`.

## Related

- [How Git deploys work](https://docs.wpwaterfall.com/code/git-workflow)
- [Cron jobs](https://docs.wpwaterfall.com/cron-jobs)
- [Tool settings](https://docs.wpwaterfall.com/tools-settings)
