xSpeed Cache is officially live! Get 50% OFF during Launch Week — Lifetime starts at just $79Lifetime from $79 — 50% OFF, Launch Week! See Plans →

See Plans →
Features
xSpeed Hub Pricing Docs Blog Scan
Appearance
Get Plugin

Run and track PageSpeed tests with OpenCode

Tracking PageSpeed scores with OpenCode means asking it, in the terminal, for stored PageSpeed history and a fresh test through xSpeed Hub, with permission rules deciding which calls run unprompted.

list_sitesget_score_historyrun_speed_testget_benchmark_historyrun_benchmark

Last updated: October 2026

Example session · OpenCode

You: Using xSpeed Hub, what are the latest scores on shop and how old are they?

get_score_history(site: shop) read-only
→ latest mobile 56, desktop 80, 14 days ago; LCP 4.3 s on mobile

OpenCode: Mobile 56 and desktop 80, both two weeks old. Mobile LCP at 4.3 s is the weak spot. That is old enough to retest if you changed anything. Start a mobile run?

You: Yes, mobile.

run_speed_test(site: shop, strategy: mobile) uses quota
→ mobile score 58, LCP 4.0 s, TBT 330 ms, saved to the Hub report history

OpenCode: Mobile is 58, two points up, with LCP 0.3 s lower than the stored run.

01

How OpenCode handles this

OpenCode lives in your terminal beside the repository, so the PageSpeed question usually comes up mid-task: did the last change help the live site? Ask it, and it calls get_score_history through the Hub. You get the stored runs back, with score, LCP, FCP, CLS, TBT, Speed Index and TTFB, mobile and desktop. If a metric moved between two runs, it can point to it and suggest which change is the likely cause, though that is a guess you should check.

run_speed_test is the call for a fresh measurement. It is a PageSpeed Insights run from the Hub, mobile or desktop, and can take up to about two minutes, so ask for one device at a time. The Hub saves the result in its own report history, which get_score_history, reading the plugin's stored runs, may not include. When you only need to know if cached pages are doing their job, run_benchmark times the home page cached and uncached and has no Lighthouse score. get_benchmark_history shows the earlier benchmark runs.

OpenCode has a permission setting with ask, allow and deny, but most permissions default to allow, so with no rule of yours a Hub tool runs without a prompt. Add an ask rule for the whole server first, then allow rules for the read tools, so reviews run without interruption and run_speed_test still asks, because it spends the shared speed-test allowance. If a tool must never run from the terminal, deny is available too, and it holds even under the auto flag.

02

Set up OpenCode once

Already connected? Skip to the prompts. Alternatives and troubleshooting are on the OpenCode 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 to your config

Put this block in your global config, or in opencode.json at a project root to scope it to that project. OpenCode reads both JSON and JSONC. No other field is needed: when the Hub answers 401, OpenCode starts the OAuth flow and registers itself through dynamic client registration.

~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "xspeedhub": {
      "type": "remote",
      "url": "https://app.xspeedcache.com/xspeed/mcp"
    }
  }
}

3Sign in with opencode mcp auth

Run this once. It opens a browser page on xSpeed Hub where you sign in and approve access. There is no token to paste; OpenCode stores the credentials it receives. Run opencode mcp list to see the server and its auth status, and opencode mcp debug xspeedhub if the connection fails.

Terminal
opencode mcp auth xspeedhub
1 / 3

Full OpenCode 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. OpenCode checks MCP tools against its permission rules under the prefixed name, such as xspeedhub_purge_cache, and most permissions default to allow. With no rule of yours in place, a Hub write tool runs without a prompt. Add rules to change that: "xspeedhub_*": "ask" first, then "xspeedhub_get_*": "allow" and "xspeedhub_list_*": "allow", because the last matching rule wins. A deny rule holds even under opencode --auto, which approves everything that is not denied. The Hub itself has no confirmation step, so these rules and read-only access are the gates. For read-only access, send the connection token with Read-only everywhere on, or sign in as a Viewer member.

03

What do I ask?

Three prompts written for OpenCode. More for this job are below.

Prompt for OpenCode
Using xSpeed Hub, what are the latest mobile and desktop scores on shop, and how old are they?
Prompt for OpenCode
Use xSpeed Hub to run one mobile test on blog and tell me what moved against the previous mobile run.
Prompt for OpenCode
With xSpeed Hub, check the benchmark history on shop and say if cached response time improved after the settings change I made on Monday.
04

What happens, step by step

PageSpeed Insights is Google's Lighthouse audit, and its score and Core Web Vitals are the numbers most people mean by "my speed". Through xSpeed Hub an agent can read the scores a site has already stored, run a new PageSpeed test on mobile or desktop, and read or run a separate benchmark of cached against uncached response time. The three answer different questions, and the Hub tells the agent which to use for each.

01

Read before you test

get_score_history returns the stored PageSpeed Insights and GTmetrix runs for a site: the score per run, with LCP, FCP, CLS, TBT, Speed Index and TTFB, mobile and desktop. It starts nothing. The Hub tells the agent to use it whenever you ask what your score is, or whether it improved, because a new test spends a shared allowance.

02

Run a new test when you need one

run_speed_test runs a real PageSpeed Insights audit on the site from the Hub and returns the score, the Core Web Vitals and the top opportunities. strategy is mobile (the default) or desktop, and one call tests one of them. It can take up to about 2 minutes, so the agent should say it is running before it calls.

03

Test the other device

Mobile and desktop scores differ, often by a lot. For both, the agent makes two calls, one per strategy. A failure is reported with its reason: PageSpeed not configured, quota reached, a timeout, or a site the audit cannot reach.

04

Measure the cache on its own

run_benchmark times the home page with the cache bypassed and again served from cache, and returns the response times. It is a read tool, and it accepts site: "all" for every site. It does not return a Lighthouse score, so the agent must not use it to answer a PageSpeed question.

05

Compare over time

get_benchmark_history returns past benchmark runs, uncached against cached, together with the settings changes on the same timeline, which is how you answer "did that change help?". For PageSpeed scores over time, use get_score_history.

05

Reference

Read stored scoresget_score_history (read): PageSpeed Insights and GTmetrix runs, starts nothing
Metrics per runScore, LCP, FCP, CLS, TBT, Speed Index, TTFB, for mobile and desktop
Run a new testrun_speed_test (write, uses the shared allowance): one PageSpeed Insights run per call
strategymobile (default) or desktop
DurationUp to about 2 minutes per run
Why a test is a writeIt spends a shared PageSpeed allowance and stores a report; it changes nothing on the site
Read-only accessA connection token with Read-only everywhere on, or a Viewer member's sign-in: run_speed_test is refused; get_score_history, run_benchmark and get_benchmark_history still work. An OAuth sign-in gets the scopes the client asks for
Benchmarkrun_benchmark (read): cached against uncached response time for the home page, no Lighthouse score
Benchmark historyget_benchmark_history (read): past runs plus settings changes on the same timeline
SchedulingThe Hub does not schedule PageSpeed tests itself; its daily pass only reads reports the plugin already stored
Where a new test is storedIn the Hub's own report history, the one the Hub dashboard shows
06

Rules worth keeping

  • Check the history first. Ask for stored scores before starting a test, and run a new one only when you want a fresh measurement or something changed.
  • Never answer a PageSpeed or Lighthouse question with run_benchmark. It times your own cache and carries no score.
  • run_speed_test changes nothing on your site, but the Hub classes it a write because it spends a shared allowance. A connection token with Read-only everywhere on, or a Viewer sign-in, refuses it. An OAuth sign-in gets the scopes the client asks for, so there your client's approval prompt is the gate.
  • Lab scores move a few points between runs of the same page. The agent should compare like with like, same site, same strategy, and not report one run's difference as a trend.
  • A new test does not run on a timer. If you want a regular test, the agent has to be started by something else, such as a scheduled job in your client, and a scheduled run that spends the allowance should be one you are comfortable leaving unattended.

Good to know with OpenCode

OpenCode checks MCP tools under the prefixed name, such as xspeedhub_run_speed_test, and the last matching rule wins. Write the catch-all first, xspeedhub_* set to ask, then xspeedhub_get_* set to allow. Reverse the order and the catch-all overrides your allow rule. run_benchmark does not start with get_, so it stays on ask unless you give it its own allow rule. With no rule at all, run_speed_test runs without asking.

07

More prompts for this job

They work in any client connected to xSpeed Hub.

Prompt
Using xSpeed Hub, what is the mobile PageSpeed score for shop? Check the stored history before you run anything.
Prompt
Use xSpeed Hub to run a new mobile PageSpeed test on blog and tell me the score, LCP and the top opportunities.
Prompt
With xSpeed Hub, test shop on desktop and mobile and tell me which one is worse.
Prompt
Using xSpeed Hub, has the PageSpeed score on docs improved over the last few runs?
Prompt
Use xSpeed Hub to benchmark the cache on every site and tell me which one saves the least time.
Prompt
Did turning on minification on shop help? Use xSpeed Hub to compare the benchmark history around that change.
Prompt
My PageSpeed test failed on staging. Use xSpeed Hub to tell me why.
08

Frequently asked questions

Most OpenCode permissions default to allow, so add a rule that sets the xspeedhub tools to ask, then allow rules for the read tools after it, because the last matching rule wins. Use deny to block run_speed_test outright. The Hub has no confirmation step of its own, so these rules are the check. A read-only Hub connection (the connection token with Read-only everywhere on, or a Viewer sign-in) refuses the tool entirely.

Yes. It reads get_score_history for each site in turn and lays the two side by side, or it can run run_speed_test on each, one after another. Each test takes up to about two minutes and spends the shared allowance, so ask for the stored history first.

run_speed_test runs a real PageSpeed Insights audit and returns a Lighthouse score with Core Web Vitals. run_benchmark measures how fast your own cache answers compared with an uncached request for the home page, and returns no Lighthouse score. Use the first for "what is my PageSpeed score" and the second for "is my caching working".

A single run can take up to about 2 minutes, so the agent should tell you it has started before it calls. One call tests one device, mobile or desktop, so checking both takes two calls.

Yes. get_score_history reads the stored PageSpeed Insights and GTmetrix runs for the site and starts nothing. The Hub tells the agent to read it first whenever you ask what your score is, because a new test spends a shared allowance.

No. The Hub does not schedule PageSpeed tests itself. Its daily pass re-verifies sites, snapshots cache status and pulls the PageSpeed and GTmetrix reports the plugin has already stored, and it can alert on a score regression. If you want regular new tests, they have to be started by a client that can run scheduled jobs.

It does not change your site. The Hub classes run_speed_test as a write because it spends a shared PageSpeed allowance and stores a report, and a read-only connection (the connection token with Read-only everywhere on, or a Viewer sign-in) should not be able to cost the owner anything. Such a connection can still read stored scores with get_score_history.

09

Keep going

Track PageSpeed scores with other agents

More with OpenCode

Documentation

From the blog

Track PageSpeed scores, from OpenCode.

xSpeed Hub is free and has no site cap. Connect your sites once and ask from the agent you already use.