Skip to content

Commit 3b3001c

Browse files
committed
tighten up
Change-Id: Ie2bd50af8f24f3bf1b74168b1f5db5a4b593c8ad
1 parent cee7b13 commit 3b3001c

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

docs/tool-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@
235235

236236
### `performance_query_chrome_ux_report`
237237

238-
**Description:** Queries the Chrome UX Report (CrUX) API to get real-user experience metrics (like Core Web Vitals) for a given URL or origin. You must provide EITHER "origin" OR "url", but not both. You can optionally filter by "formFactor".
238+
**Description:** Queries the Chrome UX Report (aka CrUX) to get aggregated real-user experience metrics (like Core Web Vitals) for a given URL or origin.
239239

240240
**Parameters:**
241241

242+
- **origin** (string) _(optional)_: The origin to query, e.g., "https://web.dev". Do not provide this if "url" is specified.
243+
- **url** (string) _(optional)_: The specific page URL to query, e.g., "https://web.dev/s/results?q=puppies". Do not provide this if "origin" is specified.
242244
- **formFactor** (enum: "DESKTOP", "PHONE", "TABLET") _(optional)_: The form factor to filter by. If omitted, data for all form factors is aggregated.
243-
- **origin** (string) _(optional)_: The origin to query, e.g., "https://www.google.com". Do not provide this if "url" is specified.
244-
- **url** (string) _(optional)_: The specific page URL to query, e.g., "https://www.google.com/search?q=puppies". Do not provide this if "origin" is specified.
245245

246246
---
247247

src/tools/performance.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const CRUX_ENDPOINT = `https://chromeuxreport.googleapis.com/v1/records:queryRec
193193
export const queryChromeUXReport = defineTool({
194194
name: 'performance_query_chrome_ux_report',
195195
description:
196-
'Queries the Chrome UX Report (aka CrUX) to get aggregated real-user experience metrics (like Core Web Vitals) for a given URL or origin. You must provide EITHER "origin" OR "url", but not both. You can optionally filter by "formFactor".',
196+
'Queries the Chrome UX Report (aka CrUX) to get aggregated real-user experience metrics (like Core Web Vitals) for a given URL or origin.',
197197
annotations: {
198198
category: ToolCategory.PERFORMANCE,
199199
readOnlyHint: true,
@@ -202,13 +202,13 @@ export const queryChromeUXReport = defineTool({
202202
origin: zod
203203
.string()
204204
.describe(
205-
'The origin to query, e.g., "https://www.google.com". Do not provide this if "url" is specified.',
205+
'The origin to query, e.g., "https://web.dev". Do not provide this if "url" is specified.',
206206
)
207207
.optional(),
208208
url: zod
209209
.string()
210210
.describe(
211-
'The specific page URL to query, e.g., "https://www.google.com/search?q=puppies". Do not provide this if "origin" is specified.',
211+
'The specific page URL to query, e.g., "https://web.dev/s/results?q=puppies". Do not provide this if "origin" is specified.',
212212
)
213213
.optional(),
214214
formFactor: zod
@@ -219,13 +219,14 @@ export const queryChromeUXReport = defineTool({
219219
.optional(),
220220
},
221221
handler: async (request, response) => {
222-
const {origin, url, formFactor} = request.params;
222+
const {origin: origin_, url, formFactor} = request.params;
223+
// Ensure probably formatted origin (no trailing slash);
224+
const origin = URL.parse(origin_ ?? '')?.origin;
223225

224226
if ((!origin && !url) || (origin && url)) {
225-
response.appendResponseLine(
227+
return response.appendResponseLine(
226228
'Error: you must provide either "origin" or "url", but not both.',
227229
);
228-
return;
229230
}
230231

231232
try {

0 commit comments

Comments
 (0)