# Claude Code + xSpeed: Manage WordPress Caching

> Claude Code is Anthropic's agentic coding tool for the terminal, and with xSpeed Hub connected it can read cache status, purge, change settings and run speed tests on every WordPress site in your workspace. You add one MCP server, sign in once, and ask in plain language.

Page: https://xspeedcache.com/agent/claude-code/
Last updated: October 2026

- One command, one URL, every site you connected to the Hub
- Each xSpeed tool shows up as mcp__xspeedhub__<tool>, so you can allow reads and keep writes on a prompt
- Works next to your code: purge after a deploy without opening wp-admin

## How do I connect Claude Code 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 Claude Code

Run this once. --scope user makes the server available in every project; leave it off and it applies to the current project only, which is Claude Code's default.

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

### 3. Sign in with /mcp

Start Claude Code, run /mcp, pick xspeedhub and finish the sign-in in your browser. You approve access on an xSpeed Hub page; there is no token to paste, and Claude Code keeps the credentials it receives and refreshes them.

```
/mcp
```

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

If you prefer a header to a browser sign-in, copy the connection token from Connect AI in the Hub (only the workspace owner sees it) and pass it with --header. A rejected header shows as a failed connection rather than falling back to sign-in.

```bash
claude mcp add --transport http --scope user xspeedhub https://app.xspeedcache.com/xspeed/mcp \
  --header "Authorization: Bearer <your connection token>"
```

**Authentication:** OAuth sign-in or connection token. Run /mcp and approve access in the browser; Claude Code stores the tokens and refreshes them. If you would rather not use a browser, add the connection token from the Hub's Connect AI page with --header instead.

**Check it worked:** ask "Use xSpeed Hub to list my sites and tell me which ones have page caching turned off."

## Does Claude Code ask before it changes my site?

Claude Code asks before it runs an MCP tool unless a permission rule already allows it, or you work in auto mode, where a classifier reviews actions instead of you, or in bypassPermissions mode, which skips prompts. A rule such as mcp__xspeedhub__get_cache_status allows one tool, and mcp__xspeedhub__get_* allows every read whose name starts with get_. Keep purge_cache, update_settings, toggle_cache and the other write tools on the prompt, because the Hub itself runs a write as soon as your connection allows it.

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: The shop site feels slow after this morning's deploy. Use xSpeed Hub to find out what is going on.
  → list_sites [read-only]: 6 sites; shop is shop.example.com
  → get_cache_status(site: shop) [read-only]: page cache on, 312 cached pages, hit ratio 38% in the last 24h
Agent: Caching is on but most requests miss, and nothing here shows why yet. The deploy may have changed asset URLs so the stored pages point at old files, but I have not confirmed that. A page-cache purge and a fresh warm-up rebuild the stored pages either way, and leave the object cache alone. Purge pages on shop and start the preloader?
You: Yes, go ahead.
  → purge_cache(site: shop, type: page) [changes site]: page cache purged (312 entries); assets and object cache untouched
  → start_preloader(site: shop) [changes site]: preloader started, 340 URLs queued
Agent: Done. The preloader is warming 340 URLs; ask me in a few minutes and I will check the hit ratio again. If it stays low, I will run get_health next.
```

## What is Claude Code?

Claude Code is Anthropic's agentic coding tool. It runs in your terminal and in IDE extensions, reads and edits code, runs commands, and calls tools on MCP servers you add to it.

MCP, the Model Context Protocol, is how Claude Code reaches services outside your machine. Adding 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 Claude Code with xSpeed?

- **Purge where you deploy**: You already ship from the terminal. Ask Claude Code to purge the site you just deployed and warm it again, in the same session that pushed the code.
- **Permission rules per tool**: Every xSpeed tool has its own name in Claude Code, so you can allow the reads once and keep each write behind a prompt.
- **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

- Without --scope user the server is added to the current project only, so it will look missing when you start Claude Code in another folder.
- If you add the same server name in two scopes with different URLs, Claude Code warns about the conflict and stores a separate sign-in per URL. Keep one entry.
- In claude -p and other non-interactive runs there is no /mcp panel, so sign in first with /mcp in an interactive session or with claude mcp login xspeedhub.

## Prompts to try

- Use xSpeed Hub to show the cache hit ratio for every site and flag anything under 70%.
- With xSpeed Hub, purge the blog site, then start the preloader and tell me how many URLs it queued.
- Use xSpeed Hub to run a mobile PageSpeed test on shop and compare it with the last one in the score history.
- Ask xSpeed Hub to preview what optimize_site would change on the docs site with a safe pass. Do not apply it.
- Using xSpeed Hub, check whether Redis is reachable on shop before you turn on the object cache.

## What can Claude Code do with xSpeed?

- [Purge the WordPress cache with Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/object-cache/): Connect a site to Redis or Memcached so database results survive between requests.
- [Manage Cloudflare caching with Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code](https://xspeedcache.com/agent/claude-code/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 Claude Code?

Run claude mcp add --transport http --scope user xspeedhub https://app.xspeedcache.com/xspeed/mcp, start Claude Code, run /mcp 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. Claude Code signs in to the Hub with OAuth through /mcp 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 pass it with --header.

### Will Claude Code change my site without asking?

Claude Code asks before each MCP tool call unless a permission rule allows that tool or you run in auto or bypassPermissions mode. The Hub has no confirmation step of its own, so if you allow a write tool with a rule, that write runs without a prompt. Allow reads, keep writes on the prompt, or connect with the connection token and Read-only everywhere on.

### Which tools does Claude Code 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.

### Can I use Claude Code with one site and no Hub?

Yes. The xSpeed Cache plugin has its own MCP server at your-site.com/xspeed/mcp, and its MCP panel in wp-admin generates a ready claude mcp add command for that site. The Hub is the better fit once you have more than one site.

### Can Claude Code use WP-CLI instead?

If Claude Code has a shell on the server, it can run wp xspeed commands directly, for example wp xspeed purge. That works without the Hub, but only for the site on that server.

### How do I disconnect Claude Code?

Run claude mcp remove xspeedhub, or choose Clear authentication for the server in /mcp. Rotating or disconnecting the connection token in the Hub cuts off clients that send that token; it does not end an OAuth sign-in, which you clear in the client.

## Also works with

[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/) · [Gemini CLI](https://xspeedcache.com/agent/gemini-cli/) · [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

- Claude Code: Connect Claude Code to tools via MCP: https://code.claude.com/docs/en/mcp
- Claude Code: Configure permissions: https://code.claude.com/docs/en/permissions
