How Codex handles this
You are probably a developer who runs many WordPress sites from a repository or a set of scripts, and Codex is already open next to the code. After a release that touches every site, you ask it to clear and re-warm all of them. Codex calls purge_cache with site set to "all", then start_preloader the same way, through the xspeedhub server you added to Codex. Neither call needs a loop in your own code.
The Hub processes the sites sequentially with a one-second pause, so a fifteen-site run takes about fifteen seconds. Codex receives a result for each site, with ok true or false and data or an error, and it can print that as a plain list in the terminal. For example, 14 sites cleared and 1 site returned an error, with the error text. Tools outside the seven fan-out tools take a single site, so a health sweep is a series of calls rather than one.
Codex has a sandbox mode and an approval policy for shell work, and MCP tools have their own settings: each server takes an approval mode of auto, prompt, writes or approve, and each tool can override it. Codex prompts by default for MCP calls that advertise side effects or a destructive annotation, and the Hub's tools declare neither, so set the xspeedhub server to prompt or the default will not stop a write. For a purge, toggle, settings change or preloader call across every site, the Hub also tells the agent to confirm once, but that is an instruction to the model, and it does not name optimize_site. The scope on your connection is the one control the Hub enforces: with the connection token and Read-only everywhere on, or a Viewer sign-in, every write is refused.
Set up Codex once
Already connected? Skip to the prompts. Alternatives and troubleshooting are on the Codex guide.
1Put your sites in xSpeed Hub
Sign in at app.xspeedcache.com with Google or email; the Hub is free and has no site cap. Then connect each WordPress site from its own dashboard: click Connect Hub in the xSpeed Cache top bar, then Connect via xSpeed Hub. Each site needs the free xSpeed Cache plugin.
2Add xSpeed Hub and sign in
Add the server with its URL, then log in. The login opens an xSpeed Hub page in your browser; approve access there. There is no token to paste, and Codex keeps the credentials it receives. Start Codex and type /mcp to see the server.
codex mcp add xspeedhub --url https://app.xspeedcache.com/xspeed/mcp codex mcp login xspeedhub
3Keep the Hub's tools on a prompt
Open ~/.codex/config.toml. Set the server to prompt for every tool, then let one read tool run without a question. The tool timeout defaults to 60 seconds, and a PageSpeed test can take up to about two minutes, so raise it.
[mcp_servers.xspeedhub] url = "https://app.xspeedcache.com/xspeed/mcp" default_tools_approval_mode = "prompt" tool_timeout_sec = 150 [mcp_servers.xspeedhub.tools.get_cache_status] approval_mode = "approve"
Full Codex setup, sign-in options and FAQ
Before you send a prompt that changes something
Reads change nothing on your sites, though contact_support emails xSpeed support. Writes run once your connection allows them, so your client's approval prompt and a read-only connection (the token's Read-only everywhere switch, or a Viewer sign-in) are the gates that matter. Codex has two layers for shell work: the sandbox mode limits what commands can touch, and the approval policy sets when Codex stops to ask. MCP tools have their own settings. Each server takes default_tools_approval_mode (auto, prompt, writes or approve) and each tool can override it with approval_mode. Codex also asks about MCP calls that advertise side effects or a destructive annotation, but xSpeed Hub's tool definitions do not declare either, so do not rely on that default for the Hub; set the server to prompt. approval_policy never, --yolo and an auto_review reviewer take the human out of the loop. xSpeed Hub has no confirmation step of its own, so an approved or auto-approved write runs as soon as your connection allows writes.
What do I ask?
Three prompts written for Codex. More for this job are below.
Use xSpeed Hub to purge every site in the workspace, start the preloader on all of them, and print one line per site.
With xSpeed Hub, run the benchmark on all sites and save the cached and uncached times to a CSV in this directory.
Using xSpeed Hub, which of my sites refused the last preloader run? Re-run it for just those.
What happens, step by step
If you run many WordPress sites, repeating one action on each is the slow part. Through xSpeed Hub, seven tools accept every site in a workspace, or a list of handles, in a single call. The Hub runs the sites one after another and returns a result for each, so a site that fails is named instead of hidden. Everything else in the Hub works on one site per call.
01
See what you can reach
list_sites returns each site's handle, URL, status and scopes. When you have more than one workspace, list_workspaces returns each one's handle, id, your role, its site count, which one is the default, and whether this connection can reach it.
02
Choose the scope of the call
The agent passes site: "all" for every site in one workspace, or an array of handles for exactly those sites. For a workspace other than the default it also passes the workspace argument. Omit workspace and the call acts on the default workspace.
03
Confirm once
Before a purge, toggle, settings change or preloader call that touches every site, the Hub tells the agent to say "this will touch all N sites" and wait for you, then make one call. That instruction does not name optimize_site, so for it your client's prompt is the gate. It is guidance to the agent, not a lock. It is one tool call, so one approval in your client covers every site in it.
04
Run it as one call
The Hub runs the sites one after another with a one-second pause between live calls, so a fleet purge is not a burst of traffic at your servers. Revoked sites are skipped from "all". Each site's action lands in the activity log as its own row.
05
Read the result per site
The reply is a summary of targets, succeeded and failed, plus one row per site with ok and either its data or its error. Some sites failing is a partial success. Only a run where every site failed comes back as an error.
06
Follow up on the failures
The agent reports which sites failed and why, then retries just those handles with an array. Tools that read one site, such as get_cache_status and get_health, do not fan out, so a fleet-wide check means one call per site.
Reference
| Fan-out tools | purge_cache, toggle_cache, update_settings, start_preloader, stop_preloader, optimize_site, run_benchmark |
|---|---|
| Selector | site: "all", or an array of handles |
| What all covers | Every site this connection can see in one workspace, minus revoked ones |
| Pacing | One after another, with a 1 second pause between live calls |
| Result | summary (targets, succeeded, failed) and a row per site: ok, then data or error |
| Partial failure | Reported per site; the call counts as an error only when every site failed |
| Workspace argument | Optional. Omit it for the default workspace; name one by its handle or id from list_workspaces |
| Reach | Fixed when you approve the connection; list_workspaces shows reachable: false for the rest |
| Not fan-out | get_health, get_cache_status and every other tool take one site per call |
| Slow tools | optimize_site takes up to 2 minutes per site; a target_score run is capped at 12 rounds per call |
| Read-only | The connection token with Read-only everywhere on, or a Viewer sign-in, refuses every fan-out write; run_benchmark works. An OAuth sign-in gets the scopes the client asks for |
| Hub daily pass | Re-verifies sites, snapshots cache status and hit ratio, reads stored reports, alerts by Slack webhook or email |
Rules worth keeping
- Confirm once, then call once. The Hub has no confirmation step of its own, so your client's approval prompt and a read-only connection (the connection token with Read-only everywhere on, or a Viewer sign-in) are the gates that matter. The Hub's "this will touch all N sites" is an instruction to the agent for purge, toggle, settings and preloader calls, and it does not name optimize_site.
- "all" is one workspace, never every workspace. To act in another workspace, name it. A write to a non-default workspace must name it, and an array of handles is looked up only in the workspace the call names.
- Read every result per site. Treat some sites failing as a partial result, and never accept a blanket "done" from the agent.
- Try a behaviour change on one site before you send it to the fleet. toggle_cache and update_settings on every site are one call, and each site checks values against its own settings, so a Pro setting can fail on a Free site.
- optimize_site on many sites is slow, because each site can take up to two minutes inside one call. Use dry_run first, or name a short list of handles.
- The Hub has no scheduler for agent prompts. Its own daily pass and alerts run without an agent, and an agent can only act when you send a prompt or your AI client runs one on a timer.
Good to know with Codex
An approval policy of never, the yolo flag or an auto-approving reviewer takes the prompt away for MCP calls too, and a per-tool approve setting does the same for that tool, site: "all" included. Then the Hub's confirm-once instruction is the only check, and it does not cover optimize_site, so use the connection token with Read-only everywhere on, or a Viewer sign-in, for any run you start that way. Mind the tool timeout as well. It defaults to 60 seconds, the Hub works about one second per site, and optimize_site can take up to two minutes on each site, so raise it before a long fleet run. Remember also that the number you see in the transcript is the number of sites in one workspace. If you hold client workspaces, tell Codex which one, because a write to a non-default workspace must name it.
More prompts for this job
They work in any client connected to xSpeed Hub.
Use xSpeed Hub to list every site I can reach, and every workspace, and say which workspace you act in by default.
With xSpeed Hub, purge the cache on every site in my workspace and tell me which ones failed.
Use xSpeed Hub to run a benchmark on all my sites and rank them by cached response time.
Use xSpeed Hub to start the preloader on blog, shop and docs only.
With xSpeed Hub, turn page caching on for every site where it is off. Check each site first.
Use xSpeed Hub to stop the preloader everywhere. The servers are busy.
Ask xSpeed Hub to preview a safe optimize_site pass on every site with dry_run and summarize what it would change.
Use xSpeed Hub to purge every site in the client-acme workspace, not my default one.
Frequently asked questions
Keep going
Manage every site at once with other agents
More with Codex
Documentation
- Managing your fleet with xSpeed Hub
- Teams, roles and workspaces in xSpeed Hub
- Scoped AI connections in xSpeed Hub
- Connecting to xSpeed Hub
- How to write prompts for xSpeed Hub
- Codex + xSpeed
- Every AI agent that works with xSpeed
From the blog