# Gemini CLI + xSpeed: Manage WordPress Caching

> Gemini CLI is Google's AI agent for the terminal, and with xSpeed Hub added as an MCP server it can read cache status, purge, change settings and run speed tests on every WordPress site in your workspace. You register one server, authenticate once, and ask in plain language.

Page: https://xspeedcache.com/agent/gemini-cli/
Last updated: October 2026

- One command, one URL; every site you connected to the Hub appears behind it
- Tools show up as mcp_xspeedhub_ followed by the tool name, so policy rules can target them
- Fits a shell session: purge after a deploy or check hit ratios without opening wp-admin

## How do I connect Gemini CLI to xSpeed?

### 1. Put 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.

### 2. Add xSpeed Hub to Gemini CLI

Run this once. --scope user writes the server to ~/.gemini/settings.json so it works in every project; without it Gemini CLI saves to the project's .gemini/settings.json, which is the default.

```bash
gemini mcp add --scope user --transport http xspeedhub https://app.xspeedcache.com/xspeed/mcp
```

### 3. Authenticate with /mcp auth

Start gemini and run /mcp auth xspeedhub. A browser page opens where you sign in to xSpeed Hub and approve access, and Gemini CLI receives the redirect on a local port. There is no token to paste, and the client keeps the credentials it receives. Run /mcp afterwards to check that xspeedhub shows as connected and lists its tools.

```
/mcp auth xspeedhub
```

### 4. Or use a connection token (alternative)

If you cannot open a browser, for example over SSH, edit the settings file and send the connection token as a header. Copy it from Connect AI in the Hub; only the workspace owner sees it. The httpUrl field is the one Gemini CLI documents for streamable HTTP servers, and the same entry can be created with the --header flag on gemini mcp add.

File: `~/.gemini/settings.json`

```json
{
  "mcpServers": {
    "xspeedhub": {
      "httpUrl": "https://app.xspeedcache.com/xspeed/mcp",
      "headers": {
        "Authorization": "Bearer <your connection token>"
      }
    }
  }
}
```

**Authentication:** OAuth sign-in or connection token. Run /mcp auth xspeedhub and approve access in the browser; Gemini CLI registers itself, stores the tokens and refreshes them. If you prefer a header, pass the connection token from the Hub's Connect AI page with --header when you add the server.

**Check it worked:** ask "Use xSpeed Hub to list my sites and tell me which of them have the preloader stopped."

## Does Gemini CLI ask before it changes my site?

Gemini CLI shows a confirmation for an MCP tool call unless the server entry sets trust to true or you start Gemini CLI with --approval-mode=yolo (or --yolo), which approves every tool call. You can proceed once, always allow that tool, always allow the whole xspeedhub server, or cancel; the last two choices stop later prompts for those tools. Policy rules in ~/.gemini/policies can allow, deny or ask for a named tool by server and tool name. The Hub has no confirmation step of its own, so a trusted server, YOLO mode or an allow rule lets a write run as soon as your connection allows writes.

xSpeed Hub has no confirmation step of its own. Read tools change nothing on your sites, with one exception to know about: contact_support sends an email to xSpeed support, and a read-only connection can still call it. A write tool (a purge, a settings change, a cache toggle, or a speed test that spends the shared allowance) runs as soon as your connection allows writes. Three things stand between a prompt and a change: your connection's scope, because a read-only connection refuses every write tool (the connection token has a Read-only everywhere switch, and a Viewer member only ever gets read access); your AI client's own tool-approval prompt; and the Hub's instructions to the agent, which tell it to confirm the target site and to ask once before a write that touches every site.

## Example session

```
You: Use xSpeed Hub to warm the cache on all my sites after tonight's plugin update.
  → list_sites [read-only]: 4 sites: shop, blog, docs, landing
Agent: Starting the preloader writes to all 4 sites, one after another. Start it on every site in this workspace?
You: Yes, all four.
  → start_preloader(site: all) [changes site]: 4 of 4 started: shop, blog, docs, landing
Agent: The preloader is running on all four sites. Ask me for status later and I will read each one.
```

## What is Gemini CLI?

Gemini CLI is an AI agent from Google that runs in your terminal. It reads and edits files, runs commands, and calls tools on MCP servers that you register in its settings.

MCP, the Model Context Protocol, is how Gemini CLI reaches services outside your machine. Registering xSpeed Hub as a remote HTTP server gives it the Hub's caching tools: status, purge, settings, preloader, object cache, Cloudflare and speed tests, for every site in your workspace.

## Why use Gemini CLI with xSpeed?

- **Scriptable setup**: gemini mcp add, list, remove, enable and disable cover the whole lifecycle from the shell, so the setup fits a dotfiles repo or a team onboarding script.
- **Rules by server and tool**: Because tools carry the xspeedhub server name, a policy rule can allow the reads and leave every write on a prompt, or deny a tool outright.
- **One server for the whole fleet**: The Hub fronts every site you connected. "Purge all my sites" is one tool call that returns a result per site.

## Good to know

- OAuth needs a browser on the same machine and a localhost redirect. In a headless shell, an SSH session or a container without a browser, use the connection token header instead.
- The default scope of gemini mcp add is project. Add --scope user, or the server will look missing when you start Gemini CLI in another folder.
- Keep underscores out of the server name. Gemini CLI documents that its policy parser splits tool names at the first underscore, so a name like xspeed_hub could make allow and deny rules fail silently. The name xspeedhub is safe.
- Do not add --trust to this server, and do not start Gemini CLI with --approval-mode=yolo (or --yolo) while the Hub is connected. Each bypasses tool confirmations, including the ones for purges and settings changes.

## Prompts to try

- With xSpeed Hub, show the page cache hit ratio for every site and flag any below 70%.
- Use xSpeed Hub to purge the docs site, start the preloader and tell me how many URLs it queued.
- Use xSpeed Hub to run a desktop PageSpeed test on landing and compare it with the stored history.
- Ask xSpeed Hub to preview what a safe optimize_site pass would change on shop. Do not apply it.
- Using xSpeed Hub, check whether Cloudflare is connected on blog before purging anything there.

## What can Gemini CLI do with xSpeed?

- [Purge the WordPress cache with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/purge-cache/): Clear stale pages after a deploy, an edit or a plugin update, on one site or all of them.
- [Find out why WordPress pages are not cached with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/troubleshoot-cache/): Work out why a site misses the cache, serves slow pages or shows a low hit ratio, using read-only checks first.
- [Scan a website for speed problems with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/speed-scan/): Get a graded speed report with the fix for every failing check and a link you can share, for your own site or any public URL.
- [Run and track PageSpeed tests with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/pagespeed-tests/): Read the PageSpeed scores a site already has, run a new test when something changed, and tell a Lighthouse score from a cache benchmark.
- [Raise a WordPress site's PageSpeed score with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/optimize-site/): Preview and apply xSpeed's recommended settings to a site, check the pages still work, and be told plainly what caching cannot fix.
- [Tune WordPress cache settings with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/cache-settings/): See which modules a site has, read their current settings, change them, and turn page caching on or off.
- [Warm the WordPress cache with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/preload-cache/): Fill the page cache before visitors arrive, for example right after a purge or a deploy.
- [Set up the Redis object cache with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/object-cache/): Connect a site to Redis or Memcached so database results survive between requests.
- [Manage Cloudflare caching with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/cloudflare/): Check the Cloudflare connection, clear the edge cache and switch development mode on or off for a site.
- [Manage every WordPress site at once with Gemini CLI](https://xspeedcache.com/agent/gemini-cli/fleet/): Run one action across all of your sites, or a chosen few, and read the result site by site.

## Which way should I connect?

| Surface | Endpoint | Reaches | Auth | Tools |
| --- | --- | --- | --- | --- |
| [xSpeed Hub MCP](https://xspeedcache.com/docs/hub-mcp/) | `https://app.xspeedcache.com/xspeed/mcp` | Every site in your workspace, one connection | OAuth sign-in in the browser, or a connection token in an Authorization header | 29 tools (16 read, 13 write), seven of them can act on every site at once |
| [xSpeed Cache Site MCP](https://xspeedcache.com/docs/mcp-server/) | `https://your-site.com/xspeed/mcp` | One WordPress site | OAuth sign-in by a site admin, or the site's own token in an Authorization header | The full per-site tool set plus run_command for the WP-CLI surface |
| [xSpeed Scan MCP](https://xspeedcache.com/docs/scan-mcp/) | `https://xspeedcache.com/scan/mcp` | Any public URL, read-only | None. No account. | 5 tools: run_speed_scan, get_speed_scan and three product-info tools |
| [WP-CLI](https://xspeedcache.com/docs/wp-cli-commands/) | `wp xspeed …` | The site whose server the agent has a shell on | Your server login | Every xSpeed command: cache, purge, preloader, objcache, cf, score, settings and more |

## Frequently asked questions

### How do I add xSpeed Hub to Gemini CLI?

Run gemini mcp add --scope user --transport http xspeedhub https://app.xspeedcache.com/xspeed/mcp, start gemini, then run /mcp auth xspeedhub and finish the sign-in in your browser. The sites you connected to the Hub are then available in every project.

### Do I need an API key?

No. Gemini CLI signs in to the Hub with OAuth, registers itself and keeps the credentials it receives. If you prefer a header, the workspace owner can copy the connection token from the Hub's Connect AI page and you pass it with --header.

### Will Gemini CLI change my site without asking?

Gemini CLI shows a confirmation for MCP tool calls unless the server is marked trusted, you started it with --approval-mode=yolo (or --yolo), or an allow rule covers the tool. The Hub has no confirmation step of its own, so if you choose always allow for a write tool, trust the server or use yolo mode, that write runs without a prompt. Allow reads and keep writes on a prompt. For read-only access, send the connection token with Read-only everywhere on, or sign in as a Viewer member.

### Which tools does Gemini CLI get?

The 29 tools of the xSpeed Hub MCP server, named mcp_xspeedhub_ followed by the tool, for example mcp_xspeedhub_purge_cache. Sixteen only read. Thirteen change a site or spend the shared speed-test allowance. Use includeTools or excludeTools on the server entry to trim the list.

### Why does the sign-in fail over SSH?

Gemini CLI needs to open a browser and receive a redirect on a local port, so OAuth does not work in a headless shell or a remote session without a browser. Use the connection token as an Authorization header in the server entry instead.

### Can I use Gemini CLI with one site and no Hub?

Yes. The xSpeed Cache plugin has its own MCP server at your-site.com/xspeed/mcp, and you add it with the same command under a different name. The Hub is the better fit once you have more than one site.

### How do I disconnect Gemini CLI?

Run gemini mcp remove xspeedhub, with --scope user if you added it that way. To keep the entry but stop using it, run gemini mcp disable xspeedhub. Rotating or disconnecting the connection token in the Hub revokes only clients that send that token, so it does not end an OAuth sign-in; that is removed in Gemini CLI.

## Also works with

[Claude Code](https://xspeedcache.com/agent/claude-code/) · [Claude](https://xspeedcache.com/agent/claude/) · [Claude Cowork](https://xspeedcache.com/agent/claude-cowork/) · [ChatGPT](https://xspeedcache.com/agent/chatgpt/) · [Codex](https://xspeedcache.com/agent/codex/) · [Cursor](https://xspeedcache.com/agent/cursor/) · [GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/) · [Windsurf](https://xspeedcache.com/agent/windsurf/) · [Antigravity](https://xspeedcache.com/agent/antigravity/) · [Zed](https://xspeedcache.com/agent/zed/) · [Kiro](https://xspeedcache.com/agent/kiro/) · [OpenCode](https://xspeedcache.com/agent/opencode/) · [OpenClaw](https://xspeedcache.com/agent/openclaw/) · [Hermes Agent](https://xspeedcache.com/agent/hermes-agent/) · [Grok Build](https://xspeedcache.com/agent/grok-build/) · [ChatGPT dots](https://xspeedcache.com/agent/chatgpt-dots/) · [Grok](https://xspeedcache.com/agent/grok/) · [Grok Bot](https://xspeedcache.com/agent/grok-bot/) · [Muse](https://xspeedcache.com/agent/muse/) · [Manus](https://xspeedcache.com/agent/manus/) · [Kimi Code](https://xspeedcache.com/agent/kimi/) · [Paperclip](https://xspeedcache.com/agent/paperclip/) · [NanoClaw](https://xspeedcache.com/agent/nanoclaw/)

## Sources

- Gemini CLI: MCP servers: https://geminicli.com/docs/tools/mcp-server/
- Gemini CLI: Policy engine: https://geminicli.com/docs/reference/policy-engine/
- Gemini CLI: Configuration reference: https://geminicli.com/docs/reference/configuration/
