chrome-devtools-mcp icon indicating copy to clipboard operation
chrome-devtools-mcp copied to clipboard

The Crux data returned is not accurate

Open amoralesph opened this issue 8 months ago • 3 comments

Description of the bug

There are several points to note regarding the CruX data using performance_start_trace:

  • It is not accurate: there are noticeable differences compared to the CruX data returned by the PageSpeed website. Using the PageSpeed Insights API and a Google Console API key, we can retrieve the exact data reflected in the CruX.
  • The FCP value is not being returned
  • Errors are not being reported when access to CrUX fails: for example, I ran a performance_start_trace on a website that does have CrUX data on the PageSpeed Insights website, but performance_start_trace returned: Metrics (field / real users): n/a – no data for this page in CrUX\ nAvailable insights:\n. When I tried a second time from another AI agent, it did return the data. There must have been a connection or memory error, etc., that wasn’t reported; it simply returns “no CrUX data”

Is there a solution for this? We need to be able to automate performance audits, but whoever performs them must also cross-check the data with PageSpeed Insights... if these data differ significantly, it’s difficult to know whether the results returned by the MCP + automated performance agent are accurate or not.

Thank you

Reproduction

  1. Use Claude + MCP Devtools
  2. Tell them to visit a website, run a performance_start_trace, and send you the CruX data.
  3. Copy that URL and submit it to PageSpeed Insights
  4. Compare the results from the CruX and you'll see that they're inaccurate
  5. The FCP metric is not available

Expectation

We need the CruX data to be almost as accurate as the data returned by PageSpeed Insights so that we can ensure the reports generated by the AI are accurate.

MCP configuration

No response

Chrome DevTools MCP version

latest

Chrome version

No response

Coding agent version

No response

Model version

No response

Chat log

No response

Node version

No response

Operating system

None

Extra checklist

  • [ ] I want to provide a PR to fix this bug

amoralesph avatar Apr 04 '26 16:04 amoralesph

Hello! Thank you for submitting the bug. I did some investigation and looks like the result returned from the MCP is the url-ALL data from the API call, while the data in the PageSpeed website is using the url-DESKTOP and url-MOBILE based on the tab you selected. @paulirish @tunetheweb what do you guys think about this? Should we consider a different approach?

About the FCP, this is not included in the response from the AI because is not part of the Core Web Vitals.

nroscino avatar Apr 07 '26 12:04 nroscino

Hello! Thank you for submitting the bug. I did some investigation and looks like the result returned from the MCP is the url-ALL data from the API call, while the data in the PageSpeed website is using the url-DESKTOP and url-MOBILE based on the tab you selected. @paulirish @tunetheweb what do you guys think about this? Should we consider a different approach?

About the FCP, this is not included in the response from the AI because is not part of the Core Web Vitals.

Thank you for considering my report. As a developer working on automating performance audits, I think it would be great to receive the desktop CruX and mobile CruX (separately, each with its own metrics).

amoralesph avatar Apr 07 '26 20:04 amoralesph

@nroscino thx! super helpful; thanks for taking first pass.

So.. We deliberately return crux data contextualized by the trace. We don't intend this to be a general utility lookup. The CrUX API is there for that. So.. in fixing this behavior.. it makes sense to use the current context of the inspected session.

We report crux data for the urls we see in the trace.


I'd propose this: we get desktop/mobile data depending on the emulated state of the page at the time of the trace.

If mobile was set to true in the emulate() call, then we're gonna return mobile data.

Tactically..

  • Using the state of dtcmp emulate viewport should be the right signal.
  • cruxmgr's getSelectedScope defaults to pageScope: url (good!) and deviceScope: auto (not great!). 😢 it's updated appropriately back in dt frontend but not here. so..
  • it'd probably make sense to pass in a deviceScope to the DevToolsTraceFormatter constructor.
    • the constructor will have to be updated to handle that. (a separate setDeviceScope method is fine too. whatever)
    • and this will use the passed value if present.

subtlety: even with this set.. getPageResult will fall back to url-ALL and origin-ALL if the more specific scope doesn have data. (you need have lots of traffic to have data for the more specific scopes)

tldr: the cruxmgr pageScope stuff was designed to gets its source-of-truth on device-type from the emulationModel and.. that's not reliable data in dtmcp land.

paulirish avatar Apr 07 '26 21:04 paulirish