:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(mcp): add query-web-vitals path breakdown wrapper (#69555)
Lucas Ricoy5aa48fffecbd
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex c47e6de7cadf..841cafb0bc6f 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -4957,6 +4957,64 @@"required": ["kind", "breakdownBy"],"type": "object"},+ "AssistantWebVitalsPathBreakdownQuery": {+ "additionalProperties": false,+ "description": "Per-page Core Web Vitals breakdown for one metric at one percentile. Returns the pages bucketed into `good` / `needs_improvements` / `poor` bands, with each page's value — mirrors the in-product **Web vitals** tab.\n\nUse this when the user asks \"which pages are slow?\", \"where is our LCP/INP/ CLS/FCP bad?\", or wants a page-level performance audit. Run it once per metric. For a site-wide trend of a vitals metric over time, use `query-trends` on the `$web_vitals` event instead.",+ "properties": {+ "dateRange": {+ "$ref": "#/definitions/AssistantDateRangeFilter",+ "description": "Date range for the query. Defaults to the last 7 days when omitted — a good window for a stable percentile."+ },+ "doPathCleaning": {+ "default": false,+ "description": "Apply the team's path-cleaning rules to the returned paths.",+ "type": "boolean"+ },+ "filterTestAccounts": {+ "default": false,+ "description": "Exclude internal and test users by applying the team's test-account filter.",+ "type": "boolean"+ },+ "kind": {+ "const": "WebVitalsPathBreakdownQuery",+ "type": "string"+ },+ "metric": {+ "$ref": "#/definitions/WebVitalsMetric",+ "description": "Required. Which Core Web Vital to break down by: `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless score), or `FCP` (first paint, ms)."+ },+ "percentile": {+ "$ref": "#/definitions/WebVitalsPercentile",+ "description": "Required. Percentile to aggregate each page's samples at. Use `p75` unless the user asks otherwise — the Google bands are defined at p75."+ },+ "properties": {+ "default": [],+ "description": "Property filters applied to the query. Accepts event and person filters only (the query runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope to one domain, or on `$device_type` to isolate mobile.",+ "items": {+ "anyOf": [+ {+ "$ref": "#/definitions/EventPropertyFilter"+ },+ {+ "$ref": "#/definitions/PersonPropertyFilter"+ }+ ]+ },+ "type": "array"+ },+ "thresholds": {+ "description": "Required. `[good, poor]` band boundaries for the chosen metric. Values below `good` are good, above `poor` are poor, in between need improvement. Use the standard Google thresholds unless the user supplies their own: LCP `[2500, 4000]`, INP `[200, 500]`, CLS `[0.1, 0.25]`, FCP `[1800, 3000]`.",+ "items": {+ "type": "number"+ },+ "maxItems": 2,+ "minItems": 2,+ "type": "array"+ }+ },+ "required": ["kind", "metric", "percentile", "thresholds"],+ "type": "object"+ },"AttributeBreakdownRow": {"additionalProperties": false,"description": "One row of a span attribute breakdown: the spans matching the filters, grouped by one attribute's value. Spans without the attribute group under `value = ''`.",diff --git a/frontend/src/queries/schema/schema-assistant-web-analytics.ts b/frontend/src/queries/schema/schema-assistant-web-analytics.tsindex a6c4af128f76..afd7fb01906b 100644--- a/frontend/src/queries/schema/schema-assistant-web-analytics.ts+++ b/frontend/src/queries/schema/schema-assistant-web-analytics.ts@@ -1,3 +1,5 @@+import type { EventPropertyFilter, PersonPropertyFilter } from '~/types'+import { AssistantDateRangeFilter } from './schema-assistant-queries'import {CompareFilter,@@ -5,6 +7,8 @@ import {WebAnalyticsConversionGoal,WebAnalyticsPropertyFilters,WebStatsBreakdown,+ WebVitalsMetric,+ WebVitalsPercentile,} from './schema-general'import { non_negative_integer, positive_integer } from './type-utils'@@ -137,3 +141,67 @@ export interface AssistantWebStatsTableQuery extends AssistantWebAnalyticsQueryB*/offset?: non_negative_integer}++/**+ * Per-page Core Web Vitals breakdown for one metric at one percentile. Returns+ * the pages bucketed into `good` / `needs_improvements` / `poor` bands, with+ * each page's value — mirrors the in-product **Web vitals** tab.+ *+ * Use this when the user asks "which pages are slow?", "where is our LCP/INP/+ * CLS/FCP bad?", or wants a page-level performance audit. Run it once per+ * metric. For a site-wide trend of a vitals metric over time, use+ * `query-trends` on the `$web_vitals` event instead.+ */+export interface AssistantWebVitalsPathBreakdownQuery {+ kind: NodeKind.WebVitalsPathBreakdownQuery++ /**+ * Date range for the query. Defaults to the last 7 days when omitted —+ * a good window for a stable percentile.+ */+ dateRange?: AssistantDateRangeFilter++ /**+ * Property filters applied to the query. Accepts event and person filters+ * only (the query runner ignores session and cohort filters) — e.g. an+ * event filter on `$host` to scope to one domain, or on `$device_type` to+ * isolate mobile.+ *+ * @default []+ */+ properties?: (EventPropertyFilter | PersonPropertyFilter)[]++ /**+ * Apply the team's path-cleaning rules to the returned paths.+ * @default false+ */+ doPathCleaning?: boolean++ /**+ * Exclude internal and test users by applying the team's test-account filter.+ * @default false+ */+ filterTestAccounts?: boolean++ /**+ * Required. Which Core Web Vital to break down by: `LCP` (load, ms),+ * `INP` (interactivity, ms), `CLS` (layout stability, unitless score),+ * or `FCP` (first paint, ms).+ */+ metric: WebVitalsMetric++ /**+ * Required. Percentile to aggregate each page's samples at. Use `p75`+ * unless the user asks otherwise — the Google bands are defined at p75.+ */+ percentile: WebVitalsPercentile++ /**+ * Required. `[good, poor]` band boundaries for the chosen metric. Values+ * below `good` are good, above `poor` are poor, in between need+ * improvement. Use the standard Google thresholds unless the user supplies+ * their own: LCP `[2500, 4000]`, INP `[200, 500]`, CLS `[0.1, 0.25]`,+ * FCP `[1800, 3000]`.+ */+ thresholds: [number, number]+}diff --git a/posthog/schema.py b/posthog/schema.pyindex d2b274d39666..dac39c14ea5d 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -9903,6 +9903,64 @@ class AssistantWebStatsTableQuery(BaseModel):)+class AssistantWebVitalsPathBreakdownQuery(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ dateRange: AssistantDateRange | AssistantDurationRange | None = Field(+ default=None,+ description=(+ "Date range for the query. Defaults to the last 7 days when omitted — a"+ " good window for a stable percentile."+ ),+ )+ doPathCleaning: bool | None = Field(+ default=False,+ description="Apply the team's path-cleaning rules to the returned paths.",+ )+ filterTestAccounts: bool | None = Field(+ default=False,+ description=("Exclude internal and test users by applying the team's test-account filter."),+ )+ kind: Literal["WebVitalsPathBreakdownQuery"] = "WebVitalsPathBreakdownQuery"+ metric: WebVitalsMetric = Field(+ ...,+ description=(+ "Required. Which Core Web Vital to break down by: `LCP` (load, ms), `INP`"+ " (interactivity, ms), `CLS` (layout stability, unitless score), or `FCP`"+ " (first paint, ms)."+ ),+ )+ percentile: WebVitalsPercentile = Field(+ ...,+ description=(+ "Required. Percentile to aggregate each page's samples at. Use `p75` unless"+ " the user asks otherwise — the Google bands are defined at p75."+ ),+ )+ properties: list[EventPropertyFilter | PersonPropertyFilter] | None = Field(+ default=[],+ description=(+ "Property filters applied to the query. Accepts event and person filters"+ " only (the query runner ignores session and cohort filters) — e.g. an"+ " event filter on `$host` to scope to one domain, or on `$device_type` to"+ " isolate mobile."+ ),+ )+ thresholds: list[float] = Field(+ ...,+ description=(+ "Required. `[good, poor]` band boundaries for the chosen metric. Values"+ " below `good` are good, above `poor` are poor, in between need"+ " improvement. Use the standard Google thresholds unless the user supplies"+ " their own: LCP `[2500, 4000]`, INP `[200, 500]`, CLS `[0.1, 0.25]`, FCP"+ " `[1800, 3000]`."+ ),+ max_length=2,+ min_length=2,+ )++class BreakdownItem(BaseModel):model_config = ConfigDict(extra="forbid",diff --git a/services/mcp/definitions/prompts/query-web-vitals.md b/services/mcp/definitions/prompts/query-web-vitals.mdnew file mode 100644index 000000000000..73b9bf23100f--- /dev/null+++ b/services/mcp/definitions/prompts/query-web-vitals.md@@ -0,0 +1,45 @@+Per-page Core Web Vitals breakdown — one metric at one percentile, with pages bucketed into `good` / `needs_improvements` / `poor` bands. Mirrors the in-product **Web analytics → Web vitals** tab.++# When to use this vs `query-trends` / `execute-sql`++Use `query-web-vitals` for **page-level** vitals questions: "which pages are slow?", "where is LCP bad?", "audit our Core Web Vitals". One call replaces a hand-written percentile query over `$web_vitals` and classifies each page against the band thresholds for you.++Use `query-trends` on the `$web_vitals` event (property math on `$web_vitals_LCP_value` etc.) for a **site-wide trend over time** — this tool has no time axis; it aggregates the whole window.++Reach for `execute-sql` only for shapes neither covers (e.g. per-page sample counts, device splits per page, or custom baselines).++Requires the project to capture the `$web_vitals` event (`capture_performance` in posthog-js). If results come back empty, check capture with `read-data-schema` before concluding pages are fine.++# Inputs++- `metric` (required): `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless), or `FCP` (first paint, ms). One metric per call — run up to four calls for a full audit.+- `percentile` (required): use `p75` unless the user asks otherwise — the Google bands are defined at p75. `p90`/`p99` show the slow tail.+- `thresholds` (required): `[good, poor]` boundaries for the chosen metric. Standard Google values:++| Metric | thresholds |+| ------ | -------------- |+| LCP | `[2500, 4000]` |+| INP | `[200, 500]` |+| CLS | `[0.1, 0.25]` |+| FCP | `[1800, 3000]` |++- `dateRange`: defaults to the last 7 days — a good window for a stable percentile; shorter windows get noisy on low-traffic pages.+- `properties`: event and person filters only (the runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope one domain of a multi-domain project, or on `$device_type` (`Mobile`/`Desktop`) to isolate a population.+- `filterTestAccounts`, `doPathCleaning`: same semantics as the other web analytics tools.++# Reading the result++Each band lists `{path, value}` pairs. A page in `poor` at p75 on a high-traffic route is a real, citable problem even if it never changed. Percentiles on low-traffic pages wobble — corroborate a surprising result with a sample count via `execute-sql` before making strong claims. Mobile values run 2–3× desktop, so a pooled percentile can hide a mobile-only problem: when a page looks borderline, re-run with a `$device_type` filter.++# Example++Worst LCP pages at p75, last 7 days, marketing site only:++```json+{+ "metric": "LCP",+ "percentile": "p75",+ "thresholds": [2500, 4000],+ "properties": [{ "type": "event", "key": "$host", "operator": "exact", "value": ["example.com"] }]+}+```diff --git a/services/mcp/definitions/query-wrappers.yaml b/services/mcp/definitions/query-wrappers.yamlindex 6b1a9644a106..d6348e9ee21b 100644--- a/services/mcp/definitions/query-wrappers.yaml+++ b/services/mcp/definitions/query-wrappers.yaml@@ -158,6 +158,24 @@ wrappers:- modifiers- samplingFactor+ query-web-vitals:+ schema_ref: AssistantWebVitalsPathBreakdownQuery+ enabled: true+ scopes:+ - query:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ title: Run a web vitals path breakdown query+ description_file: ./prompts/query-web-vitals.md+ system_prompt_hint: Core Web Vitals per page — LCP, INP, CLS, FCP bucketed into good / needs-improvement / poor+ ui_resource_uri: ui://posthog/query-results.html+ exclude_properties:+ - response+ - modifiers+ - samplingFactor+query-llm-traces-list:schema_ref: AssistantTracesQueryenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex cce7da469f90..ad0583316e2c 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -7349,6 +7349,21 @@},"system_prompt_hint": "Web analytics breakdowns — top pages, UTMs, devices, countries, with bounce rate"},+ "query-web-vitals": {+ "description": "Per-page Core Web Vitals breakdown — one metric at one percentile, with pages bucketed into `good` / `needs_improvements` / `poor` bands. Mirrors the in-product **Web analytics → Web vitals** tab.\n\n# When to use this vs `query-trends` / `execute-sql`\n\nUse `query-web-vitals` for **page-level** vitals questions: \"which pages are slow?\", \"where is LCP bad?\", \"audit our Core Web Vitals\". One call replaces a hand-written percentile query over `$web_vitals` and classifies each page against the band thresholds for you.\n\nUse `query-trends` on the `$web_vitals` event (property math on `$web_vitals_LCP_value` etc.) for a **site-wide trend over time** — this tool has no time axis; it aggregates the whole window.\n\nReach for `execute-sql` only for shapes neither covers (e.g. per-page sample counts, device splits per page, or custom baselines).\n\nRequires the project to capture the `$web_vitals` event (`capture_performance` in posthog-js). If results come back empty, check capture with `read-data-schema` before concluding pages are fine.\n\n# Inputs\n\n- `metric` (required): `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless), or `FCP` (first paint, ms). One metric per call — run up to four calls for a full audit.\n- `percentile` (required): use `p75` unless the user asks otherwise — the Google bands are defined at p75. `p90`/`p99` show the slow tail.\n- `thresholds` (required): `[good, poor]` boundaries for the chosen metric. Standard Google values:\n\n| Metric | thresholds |\n| ------ | -------------- |\n| LCP | `[2500, 4000]` |\n| INP | `[200, 500]` |\n| CLS | `[0.1, 0.25]` |\n| FCP | `[1800, 3000]` |\n\n- `dateRange`: defaults to the last 7 days — a good window for a stable percentile; shorter windows get noisy on low-traffic pages.\n- `properties`: event and person filters only (the runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope one domain of a multi-domain project, or on `$device_type` (`Mobile`/`Desktop`) to isolate a population.\n- `filterTestAccounts`, `doPathCleaning`: same semantics as the other web analytics tools.\n\n# Reading the result\n\nEach band lists `{path, value}` pairs. A page in `poor` at p75 on a high-traffic route is a real, citable problem even if it never changed. Percentiles on low-traffic pages wobble — corroborate a surprising result with a sample count via `execute-sql` before making strong claims. Mobile values run 2–3× desktop, so a pooled percentile can hide a mobile-only problem: when a page looks borderline, re-run with a `$device_type` filter.\n\n# Example\n\nWorst LCP pages at p75, last 7 days, marketing site only:\n\n```json\n{\n \"metric\": \"LCP\",\n \"percentile\": \"p75\",\n \"thresholds\": [2500, 4000],\n \"properties\": [{ \"type\": \"event\", \"key\": \"$host\", \"operator\": \"exact\", \"value\": [\"example.com\"] }]\n}\n```",+ "category": "Query wrappers",+ "feature": "insights",+ "summary": "Run a web vitals path breakdown query",+ "title": "Run a web vitals path breakdown query",+ "required_scopes": ["query:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "system_prompt_hint": "Core Web Vitals per page — LCP, INP, CLS, FCP bucketed into good / needs-improvement / poor"+ },"reminder-create": {"description": "Create a reminder for yourself. Set organization (required) and optionally team to scope it to a project. Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how they get recurring in-app notifications without manual polling.","category": "Reminders",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 6577d12a97ac..1daec37b235a 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -7870,6 +7870,21 @@},"system_prompt_hint": "Web analytics breakdowns — top pages, UTMs, devices, countries, with bounce rate"},+ "query-web-vitals": {+ "description": "Per-page Core Web Vitals breakdown — one metric at one percentile, with pages bucketed into `good` / `needs_improvements` / `poor` bands. Mirrors the in-product **Web analytics → Web vitals** tab.\n\n# When to use this vs `query-trends` / `execute-sql`\n\nUse `query-web-vitals` for **page-level** vitals questions: \"which pages are slow?\", \"where is LCP bad?\", \"audit our Core Web Vitals\". One call replaces a hand-written percentile query over `$web_vitals` and classifies each page against the band thresholds for you.\n\nUse `query-trends` on the `$web_vitals` event (property math on `$web_vitals_LCP_value` etc.) for a **site-wide trend over time** — this tool has no time axis; it aggregates the whole window.\n\nReach for `execute-sql` only for shapes neither covers (e.g. per-page sample counts, device splits per page, or custom baselines).\n\nRequires the project to capture the `$web_vitals` event (`capture_performance` in posthog-js). If results come back empty, check capture with `read-data-schema` before concluding pages are fine.\n\n# Inputs\n\n- `metric` (required): `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless), or `FCP` (first paint, ms). One metric per call — run up to four calls for a full audit.\n- `percentile` (required): use `p75` unless the user asks otherwise — the Google bands are defined at p75. `p90`/`p99` show the slow tail.\n- `thresholds` (required): `[good, poor]` boundaries for the chosen metric. Standard Google values:\n\n| Metric | thresholds |\n| ------ | -------------- |\n| LCP | `[2500, 4000]` |\n| INP | `[200, 500]` |\n| CLS | `[0.1, 0.25]` |\n| FCP | `[1800, 3000]` |\n\n- `dateRange`: defaults to the last 7 days — a good window for a stable percentile; shorter windows get noisy on low-traffic pages.\n- `properties`: event and person filters only (the runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope one domain of a multi-domain project, or on `$device_type` (`Mobile`/`Desktop`) to isolate a population.\n- `filterTestAccounts`, `doPathCleaning`: same semantics as the other web analytics tools.\n\n# Reading the result\n\nEach band lists `{path, value}` pairs. A page in `poor` at p75 on a high-traffic route is a real, citable problem even if it never changed. Percentiles on low-traffic pages wobble — corroborate a surprising result with a sample count via `execute-sql` before making strong claims. Mobile values run 2–3× desktop, so a pooled percentile can hide a mobile-only problem: when a page looks borderline, re-run with a `$device_type` filter.\n\n# Example\n\nWorst LCP pages at p75, last 7 days, marketing site only:\n\n```json\n{\n \"metric\": \"LCP\",\n \"percentile\": \"p75\",\n \"thresholds\": [2500, 4000],\n \"properties\": [{ \"type\": \"event\", \"key\": \"$host\", \"operator\": \"exact\", \"value\": [\"example.com\"] }]\n}\n```",+ "category": "Query wrappers",+ "feature": "insights",+ "summary": "Run a web vitals path breakdown query",+ "title": "Run a web vitals path breakdown query",+ "required_scopes": ["query:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "system_prompt_hint": "Core Web Vitals per page — LCP, INP, CLS, FCP bucketed into good / needs-improvement / poor"+ },"read-data-schema": {"description": "Use this tool to explore the user's data schema. The user implements PostHog SDKs to collect events, properties, and property values. They are used by users to create insights with visualizations, SQL queries, watch session recordings, filter data, target particular users or groups by traits or behavior, etc. Each event, action, and entity has its own data schema. You must verify that specific combinations exist before using it anywhere else. Events or properties starting from \"$\" are system properties automatically captured by SDKs. Do not rely on your training data or PostHog defaults for events or properties. Always use this tool to confirm what actually exists in the user's project before referencing any event, property, or property value.","category": "Data schema",diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex 9fc893dde4a8..c03dbc9b39c4 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -1418,6 +1418,47 @@ const AssistantWebStatsTableQuery = z.object({.optional(),})+const WebVitalsMetric = z.enum(['INP', 'LCP', 'CLS', 'FCP'])++const WebVitalsPercentile = z.enum(['p75', 'p90', 'p99'])++const AssistantWebVitalsPathBreakdownQuery = z.object({+ dateRange: AssistantDateRangeFilter.describe(+ 'Date range for the query. Defaults to the last 7 days when omitted — a good window for a stable percentile.'+ ).optional(),+ doPathCleaning: z.coerce+ .boolean()+ .describe("Apply the team's path-cleaning rules to the returned paths.")+ .default(false)+ .optional(),+ filterTestAccounts: z.coerce+ .boolean()+ .describe("Exclude internal and test users by applying the team's test-account filter.")+ .default(false)+ .optional(),+ kind: z.literal('WebVitalsPathBreakdownQuery').default('WebVitalsPathBreakdownQuery'),+ metric: WebVitalsMetric.describe(+ 'Required. Which Core Web Vital to break down by: `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless score), or `FCP` (first paint, ms).'+ ),+ percentile: WebVitalsPercentile.describe(+ "Required. Percentile to aggregate each page's samples at. Use `p75` unless the user asks otherwise — the Google bands are defined at p75."+ ),+ properties: z+ .array(z.union([EventPropertyFilter, PersonPropertyFilter]))+ .describe(+ 'Property filters applied to the query. Accepts event and person filters only (the query runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope to one domain, or on `$device_type` to isolate mobile.'+ )+ .default([])+ .optional(),+ thresholds: z+ .array(z.coerce.number())+ .min(2)+ .max(2)+ .describe(+ 'Required. `[good, poor]` band boundaries for the chosen metric. Values below `good` are good, above `poor` are poor, in between need improvement. Use the standard Google thresholds unless the user supplies their own: LCP `[2500, 4000]`, INP `[200, 500]`, CLS `[0.1, 0.25]`, FCP `[1800, 3000]`.'+ ),+})+const AssistantTracesQuery = z.object({dateRange: AssistantDateRangeFilter.describe('Date range for the query.').optional(),filterSupportTraces: z.coerce.boolean().describe('Exclude support impersonation traces.').default(false).optional(),@@ -1747,6 +1788,13 @@ export const GENERATED_TOOLS: Record<string, ReturnType<typeof createQueryWrappeuiResourceUri: 'ui://posthog/query-results.html',outputFormat: 'json',}),+ 'query-web-vitals': createQueryWrapper({+ name: 'query-web-vitals',+ schema: AssistantWebVitalsPathBreakdownQuery,+ kind: 'WebVitalsPathBreakdownQuery',+ uiResourceUri: 'ui://posthog/query-results.html',+ outputFormat: 'json',+ }),'query-llm-traces-list': createQueryWrapper({name: 'query-llm-traces-list',schema: AssistantTracesQuery,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-vitals.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-vitals.jsonnew file mode 100644index 000000000000..5a452b2033d2--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-vitals.json@@ -0,0 +1,272 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "dateRange": {+ "anyOf": [+ {+ "properties": {+ "date_from": {+ "description": "ISO8601 date string.",+ "type": "string"+ },+ "date_to": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "ISO8601 date string."+ }+ },+ "required": ["date_from"],+ "type": "object"+ },+ {+ "properties": {+ "date_from": {+ "description": "Duration in the past. Supported units are: `h` (hour), `d` (day), `w` (week), `m` (month), `y` (year), `all` (all time). Use the `Start` suffix to define the exact left date boundary. Examples: `-1d` last day from now, `-180d` last 180 days from now, `mStart` this month start, `-1dStart` yesterday's start.",+ "type": "string"+ }+ },+ "required": ["date_from"],+ "type": "object"+ }+ ],+ "description": "Date range for the query. Defaults to the last 7 days when omitted — a good window for a stable percentile."+ },+ "doPathCleaning": {+ "default": false,+ "description": "Apply the team's path-cleaning rules to the returned paths.",+ "type": "boolean"+ },+ "filterTestAccounts": {+ "description": "Exclude internal and test users by applying the respective filters. When omitted, follows the project's \"Filter out internal and test users\" default setting.",+ "type": "boolean"+ },+ "kind": {+ "const": "WebVitalsPathBreakdownQuery",+ "default": "WebVitalsPathBreakdownQuery",+ "type": "string"+ },+ "metric": {+ "description": "Required. Which Core Web Vital to break down by: `LCP` (load, ms), `INP` (interactivity, ms), `CLS` (layout stability, unitless score), or `FCP` (first paint, ms).",+ "enum": ["INP", "LCP", "CLS", "FCP"],+ "type": "string"+ },+ "percentile": {+ "description": "Required. Percentile to aggregate each page's samples at. Use `p75` unless the user asks otherwise — the Google bands are defined at p75.",+ "enum": ["p75", "p90", "p99"],+ "type": "string"+ },+ "properties": {+ "default": [],+ "description": "Property filters applied to the query. Accepts event and person filters only (the query runner ignores session and cohort filters) — e.g. an event filter on `$host` to scope to one domain, or on `$device_type` to isolate mobile.",+ "items": {+ "anyOf": [+ {+ "properties": {+ "key": {+ "type": "string"+ },+ "label": {+ "type": "string"+ },+ "operator": {+ "default": "exact",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex",+ "gt",+ "gte",+ "lt",+ "lte",+ "is_set",+ "is_not_set",+ "is_date_exact",+ "is_date_before",+ "is_date_after",+ "between",+ "not_between",+ "min",+ "max",+ "in",+ "not_in",+ "is_cleaned_path_exact",+ "flag_evaluates_to",+ "semver_eq",+ "semver_neq",+ "semver_gt",+ "semver_gte",+ "semver_lt",+ "semver_lte",+ "semver_tilde",+ "semver_caret",+ "semver_wildcard",+ "icontains_multi",+ "not_icontains_multi"+ ],+ "type": "string"+ },+ "type": {+ "const": "event",+ "default": "event",+ "description": "Event properties",+ "type": "string"+ },+ "value": {+ "anyOf": [+ {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "boolean"+ }+ ]+ },+ {+ "items": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "boolean"+ }+ ]+ },+ "type": "array"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["key"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "type": "string"+ },+ "label": {+ "type": "string"+ },+ "operator": {+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex",+ "gt",+ "gte",+ "lt",+ "lte",+ "is_set",+ "is_not_set",+ "is_date_exact",+ "is_date_before",+ "is_date_after",+ "between",+ "not_between",+ "min",+ "max",+ "in",+ "not_in",+ "is_cleaned_path_exact",+ "flag_evaluates_to",+ "semver_eq",+ "semver_neq",+ "semver_gt",+ "semver_gte",+ "semver_lt",+ "semver_lte",+ "semver_tilde",+ "semver_caret",+ "semver_wildcard",+ "icontains_multi",+ "not_icontains_multi"+ ],+ "type": "string"+ },+ "type": {+ "const": "person",+ "default": "person",+ "description": "Person properties",+ "type": "string"+ },+ "value": {+ "anyOf": [+ {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "boolean"+ }+ ]+ },+ {+ "items": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "number"+ },+ {+ "type": "boolean"+ }+ ]+ },+ "type": "array"+ },+ {+ "type": "null"+ }+ ]+ }+ },+ "required": ["key", "operator"],+ "type": "object"+ }+ ]+ },+ "type": "array"+ },+ "thresholds": {+ "description": "Required. `[good, poor]` band boundaries for the chosen metric. Values below `good` are good, above `poor` are poor, in between need improvement. Use the standard Google thresholds unless the user supplies their own: LCP `[2500, 4000]`, INP `[200, 500]`, CLS `[0.1, 0.25]`, FCP `[1800, 3000]`.",+ "items": {+ "type": "number"+ },+ "maxItems": 2,+ "minItems": 2,+ "type": "array"+ }+ },+ "required": ["metric", "percentile", "thresholds"],+ "type": "object"+}