: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-analytics): move tool calls and errors chart to a query runner (#74544)
Georgis Andonis5a43ab284874
diff --git a/bin/patch-schema-property-filter-discriminator.py b/bin/patch-schema-property-filter-discriminator.pyindex bc79d235d86c..deac8bccec9a 100644--- a/bin/patch-schema-property-filter-discriminator.py+++ b/bin/patch-schema-property-filter-discriminator.py@@ -72,7 +72,7 @@ EXPECTED_SITE_COUNTS = {# recursive site, discriminated including the group via its AND/OR -> property_group tag."recursive": 1,# Plain inlined runs: list[<members>], optionally `| PropertyGroupFilter` / `| None`.- "plain": 61,+ "plain": 62,}diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 9ca66e1aedf4..ae869554278d 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -1020,6 +1020,9 @@{"$ref": "#/definitions/EndpointsUsageTrendsQuery"},+ {+ "$ref": "#/definitions/MCPToolCallsAndErrorsQuery"+ },{"$ref": "#/definitions/MCPHarnessBreakdownQuery"},@@ -8519,6 +8522,106 @@],"type": "object"},+ "CachedMCPToolCallsAndErrorsQueryResponse": {+ "additionalProperties": false,+ "properties": {+ "cache_key": {+ "type": "string"+ },+ "cache_target_age": {+ "format": "date-time",+ "type": "string"+ },+ "calculation_trigger": {+ "description": "What triggered the calculation of the query, leave empty if user/immediate",+ "type": "string"+ },+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "is_cached": {+ "type": "boolean"+ },+ "last_refresh": {+ "format": "date-time",+ "type": "string"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "next_allowed_client_refresh": {+ "format": "date-time",+ "type": "string"+ },+ "query_metadata": {+ "type": "object"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_compare_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The resolved previous/comparison period date range, when comparing against another period"+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "$ref": "#/definitions/MCPToolCallsAndErrorsItem"+ },+ "type": "array"+ },+ "timezone": {+ "type": "string"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "used_data_warehouse_sources": {+ "description": "Connector-synced data warehouse sources referenced by this query, if any.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSourceUsage"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. Also carries access control warnings when a system-table query filters out objects the user can't access.",+ "items": {+ "anyOf": [+ {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ {+ "$ref": "#/definitions/AccessControlFilterWarning"+ }+ ]+ },+ "type": "array"+ }+ },+ "required": [+ "cache_key",+ "is_cached",+ "last_refresh",+ "next_allowed_client_refresh",+ "results",+ "timezone"+ ],+ "type": "object"+ },"CachedMCPToolCategoriesQueryResponse": {"additionalProperties": false,"properties": {@@ -29280,6 +29383,131 @@"required": ["results"],"type": "object"},+ "MCPToolCallsAndErrorsItem": {+ "additionalProperties": false,+ "description": "One interval bucket of MCP tool-call activity, split into successful and failed calls.",+ "properties": {+ "bucket": {+ "description": "Bucket start as a project-timezone wall clock (\"YYYY-MM-DD HH:mm:ss\"), never zone-stamped, so the client can join it against generated axis keys without reinterpreting it as an instant.",+ "type": "string"+ },+ "errors": {+ "$ref": "#/definitions/integer"+ },+ "successes": {+ "$ref": "#/definitions/integer"+ }+ },+ "required": ["bucket", "successes", "errors"],+ "type": "object"+ },+ "MCPToolCallsAndErrorsQuery": {+ "additionalProperties": false,+ "description": "Interval-bucketed success/error split powering the dashboard's \"Tool calls and errors\" chart.",+ "properties": {+ "dateRange": {+ "$ref": "#/definitions/DateRange"+ },+ "filterTestAccounts": {+ "type": "boolean"+ },+ "interval": {+ "$ref": "#/definitions/IntervalType",+ "description": "Bucket granularity; the frontend passes getDefaultInterval. Defaults to day."+ },+ "kind": {+ "const": "MCPToolCallsAndErrorsQuery",+ "type": "string"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "properties": {+ "items": {+ "$ref": "#/definitions/AnyPropertyFilter"+ },+ "type": "array"+ },+ "response": {+ "$ref": "#/definitions/MCPToolCallsAndErrorsQueryResponse"+ },+ "tags": {+ "$ref": "#/definitions/QueryLogTags"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["kind"],+ "type": "object"+ },+ "MCPToolCallsAndErrorsQueryResponse": {+ "additionalProperties": false,+ "properties": {+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_compare_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The resolved previous/comparison period date range, when comparing against another period"+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "$ref": "#/definitions/MCPToolCallsAndErrorsItem"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "used_data_warehouse_sources": {+ "description": "Connector-synced data warehouse sources referenced by this query, if any.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSourceUsage"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. Also carries access control warnings when a system-table query filters out objects the user can't access.",+ "items": {+ "anyOf": [+ {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ {+ "$ref": "#/definitions/AccessControlFilterWarning"+ }+ ]+ },+ "type": "array"+ }+ },+ "required": ["results"],+ "type": "object"+ },"MCPToolCategoriesQuery": {"additionalProperties": false,"description": "Distinct $mcp_tool_category values seen in the window, sorted — powers the scope selector.",@@ -34104,6 +34332,7 @@"EndpointsUsageOverviewQuery","EndpointsUsageTableQuery","EndpointsUsageTrendsQuery",+ "MCPToolCallsAndErrorsQuery","MCPHarnessBreakdownQuery","MCPToolTopUsersQuery","MCPToolFailuresQuery",@@ -42051,6 +42280,71 @@"required": ["results"],"type": "object"},+ {+ "additionalProperties": false,+ "properties": {+ "error": {+ "description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",+ "type": "string"+ },+ "hogql": {+ "description": "Generated HogQL query.",+ "type": "string"+ },+ "modifiers": {+ "$ref": "#/definitions/HogQLQueryModifiers",+ "description": "Modifiers used when performing the query"+ },+ "query_status": {+ "$ref": "#/definitions/QueryStatus",+ "description": "Query status indicates whether next to the provided data, a query is still running."+ },+ "resolved_compare_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The resolved previous/comparison period date range, when comparing against another period"+ },+ "resolved_date_range": {+ "$ref": "#/definitions/ResolvedDateRangeResponse",+ "description": "The date range used for the query"+ },+ "results": {+ "items": {+ "$ref": "#/definitions/MCPToolCallsAndErrorsItem"+ },+ "type": "array"+ },+ "timings": {+ "description": "Measured timings for different parts of the query generation process",+ "items": {+ "$ref": "#/definitions/QueryTiming"+ },+ "type": "array"+ },+ "used_data_warehouse_sources": {+ "description": "Connector-synced data warehouse sources referenced by this query, if any.",+ "items": {+ "$ref": "#/definitions/DataWarehouseSourceUsage"+ },+ "type": "array"+ },+ "warnings": {+ "description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. Also carries access control warnings when a system-table query filters out objects the user can't access.",+ "items": {+ "anyOf": [+ {+ "$ref": "#/definitions/DataWarehouseSyncWarning"+ },+ {+ "$ref": "#/definitions/AccessControlFilterWarning"+ }+ ]+ },+ "type": "array"+ }+ },+ "required": ["results"],+ "type": "object"+ },{"additionalProperties": false,"properties": {@@ -43194,6 +43488,9 @@{"$ref": "#/definitions/EndpointsUsageTrendsQuery"},+ {+ "$ref": "#/definitions/MCPToolCallsAndErrorsQuery"+ },{"$ref": "#/definitions/MCPHarnessBreakdownQuery"},diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex f286bceac0c0..05c4202c8159 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -187,6 +187,7 @@ export enum NodeKind {EndpointsUsageTrendsQuery = 'EndpointsUsageTrendsQuery',// MCP analytics+ MCPToolCallsAndErrorsQuery = 'MCPToolCallsAndErrorsQuery',MCPHarnessBreakdownQuery = 'MCPHarnessBreakdownQuery',MCPToolTopUsersQuery = 'MCPToolTopUsersQuery',MCPToolFailuresQuery = 'MCPToolFailuresQuery',@@ -263,6 +264,7 @@ export type AnyDataNode =| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -385,6 +387,7 @@ export type QuerySchema =| EndpointsUsageTrendsQuery// MCP analytics+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -2675,6 +2678,31 @@ export interface WebOverviewQueryResponse extends AnalyticsQueryResponseBase {export type CachedWebOverviewQueryResponse = CachedQueryResponse<WebOverviewQueryResponse>+/** One interval bucket of MCP tool-call activity, split into successful and failed calls. */+export interface MCPToolCallsAndErrorsItem {+ /** Bucket start as a project-timezone wall clock ("YYYY-MM-DD HH:mm:ss"), never zone-stamped, so+ * the client can join it against generated axis keys without reinterpreting it as an instant. */+ bucket: string+ successes: integer+ errors: integer+}++export interface MCPToolCallsAndErrorsQueryResponse extends AnalyticsQueryResponseBase {+ results: MCPToolCallsAndErrorsItem[]+}++/** Interval-bucketed success/error split powering the dashboard's "Tool calls and errors" chart. */+export interface MCPToolCallsAndErrorsQuery extends DataNode<MCPToolCallsAndErrorsQueryResponse> {+ kind: NodeKind.MCPToolCallsAndErrorsQuery+ dateRange?: DateRange+ properties?: AnyPropertyFilter[]+ filterTestAccounts?: boolean+ /** Bucket granularity; the frontend passes getDefaultInterval. Defaults to day. */+ interval?: IntervalType+}++export type CachedMCPToolCallsAndErrorsQueryResponse = CachedQueryResponse<MCPToolCallsAndErrorsQueryResponse>+/** One row of the MCP harness (client) breakdown: a resolved customer label and its activity. */export interface MCPHarnessBreakdownItem {/** Customer-facing harness label, e.g. "Claude Agent SDK", "OpenAI Codex", "Cursor", "Other". */diff --git a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsxindex a5d452a06dd6..418221430a12 100644--- a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx+++ b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx@@ -549,6 +549,12 @@ export const QUERY_TYPES_METADATA: Record<NodeKind, InsightTypeMetadata> = {icon: IconPieChart,inMenu: false,},+ [NodeKind.MCPToolCallsAndErrorsQuery]: {+ name: 'MCP tool calls and errors',+ description: 'MCP tool-call volume over time, split into successful and failed calls.',+ icon: IconPieChart,+ inMenu: false,+ },[NodeKind.MCPHarnessBreakdownQuery]: {name: 'MCP harness breakdown',description: 'MCP tool-call activity grouped by client harness.',diff --git a/posthog/api/query.py b/posthog/api/query.pyindex 1a49cb74721b..2c27de161f29 100644--- a/posthog/api/query.py+++ b/posthog/api/query.py@@ -166,6 +166,7 @@ _QUERY_KIND_SCOPES: dict[str, list[str]] = {# Both scopes listed: this result replaces the view's default query:read# rather than adding to it, and a token must hold every listed scope."MCPToolFailureOccurrencesQuery": ["query:read", "mcp_analytics:read"],+ "MCPToolCallsAndErrorsQuery": ["query:read", "mcp_analytics:read"],}diff --git a/posthog/clickhouse/query_tagging.py b/posthog/clickhouse/query_tagging.pyindex 0baa9cdd0203..ed8334279de6 100644--- a/posthog/clickhouse/query_tagging.py+++ b/posthog/clickhouse/query_tagging.py@@ -268,6 +268,7 @@ def kind_fallback_tags(kind: NodeKind) -> FallbackTags | None:return {"product": Product.MARKETING_ANALYTICS}case (NodeKind.MCP_HARNESS_BREAKDOWN_QUERY+ | NodeKind.MCP_TOOL_CALLS_AND_ERRORS_QUERY| NodeKind.MCP_TOOL_TOP_USERS_QUERY| NodeKind.MCP_TOOL_FAILURES_QUERY| NodeKind.MCP_TOOL_FAILURE_OCCURRENCES_QUERYdiff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.pyindex 5f9b11200b80..2e5fed811279 100644--- a/posthog/hogql_queries/query_runner.py+++ b/posthog/hogql_queries/query_runner.py@@ -45,6 +45,7 @@ from posthog.schema import (MarketingAnalyticsAggregatedQuery,MarketingAnalyticsTableQuery,MCPHarnessBreakdownQuery,+ MCPToolCallsAndErrorsQuery,MCPToolCategoriesQuery,MCPToolCategoryCountsQuery,MCPToolDailyStatsQuery,@@ -365,6 +366,7 @@ RunnableQueryNode = Union[EndpointsUsageTrendsQuery,MetricsQuery,MCPHarnessBreakdownQuery,+ MCPToolCallsAndErrorsQuery,MCPToolTopUsersQuery,MCPToolFailuresQuery,MCPToolFailureOccurrencesQuery,@@ -942,6 +944,17 @@ def get_query_runner(modifiers=modifiers,user=user,)+ if kind == "MCPToolCallsAndErrorsQuery":+ from products.mcp_analytics.backend.facade.queries import MCPToolCallsAndErrorsQueryRunner++ return MCPToolCallsAndErrorsQueryRunner(+ query=cast(MCPToolCallsAndErrorsQuery | dict[str, Any], query),+ team=team,+ timings=timings,+ limit_context=limit_context,+ modifiers=modifiers,+ user=user,+ )if kind == "MCPToolTopUsersQuery":from products.mcp_analytics.backend.facade.queries import MCPToolTopUsersQueryRunnerdiff --git a/posthog/schema.py b/posthog/schema.pyindex ceb113d6115b..94472702b60c 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -5317,6 +5317,22 @@ class MCPHarnessBreakdownItem(BaseModel):total_calls: int+class MCPToolCallsAndErrorsItem(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ bucket: str = Field(+ ...,+ description=(+ 'Bucket start as a project-timezone wall clock ("YYYY-MM-DD HH:mm:ss"),'+ " never zone-stamped, so the client can join it against generated axis keys"+ " without reinterpreting it as an instant."+ ),+ )+ errors: int+ successes: int++class MCPToolCategoryCountItem(BaseModel):model_config = ConfigDict(extra="forbid",@@ -10907,6 +10923,64 @@ class CachedMCPHarnessBreakdownQueryResponse(BaseModel):)+class CachedMCPToolCallsAndErrorsQueryResponse(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ cache_key: str+ cache_target_age: AwareDatetime | None = None+ calculation_trigger: str | None = Field(+ default=None,+ description=("What triggered the calculation of the query, leave empty if user/immediate"),+ )+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hogql: str | None = Field(default=None, description="Generated HogQL query.")+ is_cached: bool+ last_refresh: AwareDatetime+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ next_allowed_client_refresh: AwareDatetime+ query_metadata: dict[str, Any] | None = None+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_compare_date_range: ResolvedDateRangeResponse | None = Field(+ default=None,+ description=("The resolved previous/comparison period date range, when comparing against another period"),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[MCPToolCallsAndErrorsItem]+ timezone: str+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ used_data_warehouse_sources: list[DataWarehouseSourceUsage] | None = Field(+ default=None,+ description=("Connector-synced data warehouse sources referenced by this query, if any."),+ )+ warnings: list[DataWarehouseSyncWarning | AccessControlFilterWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose"+ " latest sync failed, is paused, hit a billing limit, or is otherwise"+ " stale. Results may not reflect current source data. Accumulated"+ " across every HogQL execution that contributes to this response — so"+ " insights backed by warehouse tables (Trends, Funnels, etc.) receive"+ " the same warnings as raw HogQL queries. Also carries access control"+ " warnings when a system-table query filters out objects the user can't"+ " access."+ ),+ )++class CachedMCPToolCategoriesQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",@@ -16617,6 +16691,53 @@ class MCPHarnessBreakdownQueryResponse(BaseModel):)+class MCPToolCallsAndErrorsQueryResponse(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hogql: str | None = Field(default=None, description="Generated HogQL query.")+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_compare_date_range: ResolvedDateRangeResponse | None = Field(+ default=None,+ description=("The resolved previous/comparison period date range, when comparing against another period"),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[MCPToolCallsAndErrorsItem]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ used_data_warehouse_sources: list[DataWarehouseSourceUsage] | None = Field(+ default=None,+ description=("Connector-synced data warehouse sources referenced by this query, if any."),+ )+ warnings: list[DataWarehouseSyncWarning | AccessControlFilterWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose"+ " latest sync failed, is paused, hit a billing limit, or is otherwise"+ " stale. Results may not reflect current source data. Accumulated"+ " across every HogQL execution that contributes to this response — so"+ " insights backed by warehouse tables (Trends, Funnels, etc.) receive"+ " the same warnings as raw HogQL queries. Also carries access control"+ " warnings when a system-table query filters out objects the user can't"+ " access."+ ),+ )++class MCPToolCategoriesQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",@@ -21074,7 +21195,7 @@ class QueryResponseAlternative87(BaseModel):resolved_date_range: ResolvedDateRangeResponse | None = Field(default=None, description="The date range used for the query")- results: list[MCPHarnessBreakdownItem]+ results: list[MCPToolCallsAndErrorsItem]timings: list[QueryTiming] | None = Field(default=None,description=("Measured timings for different parts of the query generation process"),@@ -21121,7 +21242,7 @@ class QueryResponseAlternative88(BaseModel):resolved_date_range: ResolvedDateRangeResponse | None = Field(default=None, description="The date range used for the query")- results: list[MCPToolTopUserItem]+ results: list[MCPHarnessBreakdownItem]timings: list[QueryTiming] | None = Field(default=None,description=("Measured timings for different parts of the query generation process"),@@ -21168,7 +21289,7 @@ class QueryResponseAlternative89(BaseModel):resolved_date_range: ResolvedDateRangeResponse | None = Field(default=None, description="The date range used for the query")- results: list[MCPToolFailureItem]+ results: list[MCPToolTopUserItem]timings: list[QueryTiming] | None = Field(default=None,description=("Measured timings for different parts of the query generation process"),@@ -21215,7 +21336,7 @@ class QueryResponseAlternative90(BaseModel):resolved_date_range: ResolvedDateRangeResponse | None = Field(default=None, description="The date range used for the query")- results: list[MCPToolFailureOccurrenceItem]+ results: list[MCPToolFailureItem]timings: list[QueryTiming] | None = Field(default=None,description=("Measured timings for different parts of the query generation process"),@@ -21240,6 +21361,53 @@ class QueryResponseAlternative90(BaseModel):class QueryResponseAlternative91(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ error: str | None = Field(+ default=None,+ description=(+ "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise."+ ),+ )+ hogql: str | None = Field(default=None, description="Generated HogQL query.")+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ query_status: QueryStatus | None = Field(+ default=None,+ description=("Query status indicates whether next to the provided data, a query is still running."),+ )+ resolved_compare_date_range: ResolvedDateRangeResponse | None = Field(+ default=None,+ description=("The resolved previous/comparison period date range, when comparing against another period"),+ )+ resolved_date_range: ResolvedDateRangeResponse | None = Field(+ default=None, description="The date range used for the query"+ )+ results: list[MCPToolFailureOccurrenceItem]+ timings: list[QueryTiming] | None = Field(+ default=None,+ description=("Measured timings for different parts of the query generation process"),+ )+ used_data_warehouse_sources: list[DataWarehouseSourceUsage] | None = Field(+ default=None,+ description=("Connector-synced data warehouse sources referenced by this query, if any."),+ )+ warnings: list[DataWarehouseSyncWarning | AccessControlFilterWarning] | None = Field(+ default=None,+ description=(+ "Warnings about data warehouse sources referenced by the query whose"+ " latest sync failed, is paused, hit a billing limit, or is otherwise"+ " stale. Results may not reflect current source data. Accumulated"+ " across every HogQL execution that contributes to this response — so"+ " insights backed by warehouse tables (Trends, Funnels, etc.) receive"+ " the same warnings as raw HogQL queries. Also carries access control"+ " warnings when a system-table query filters out objects the user can't"+ " access."+ ),+ )+++class QueryResponseAlternative92(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21289,7 +21457,7 @@ class QueryResponseAlternative91(BaseModel):)-class QueryResponseAlternative92(BaseModel):+class QueryResponseAlternative93(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21336,7 +21504,7 @@ class QueryResponseAlternative92(BaseModel):)-class QueryResponseAlternative93(BaseModel):+class QueryResponseAlternative94(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21383,7 +21551,7 @@ class QueryResponseAlternative93(BaseModel):)-class QueryResponseAlternative94(BaseModel):+class QueryResponseAlternative95(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21430,7 +21598,7 @@ class QueryResponseAlternative94(BaseModel):)-class QueryResponseAlternative95(BaseModel):+class QueryResponseAlternative96(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21477,7 +21645,7 @@ class QueryResponseAlternative95(BaseModel):)-class QueryResponseAlternative96(BaseModel):+class QueryResponseAlternative97(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21524,7 +21692,7 @@ class QueryResponseAlternative96(BaseModel):)-class QueryResponseAlternative97(BaseModel):+class QueryResponseAlternative98(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21571,7 +21739,7 @@ class QueryResponseAlternative97(BaseModel):)-class QueryResponseAlternative98(BaseModel):+class QueryResponseAlternative99(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21618,7 +21786,7 @@ class QueryResponseAlternative98(BaseModel):)-class QueryResponseAlternative99(BaseModel):+class QueryResponseAlternative100(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -21665,7 +21833,7 @@ class QueryResponseAlternative99(BaseModel):)-class QueryResponseAlternative100(BaseModel):+class QueryResponseAlternative101(BaseModel):model_config = ConfigDict(extra="forbid",)@@ -23855,6 +24023,24 @@ class MCPHarnessBreakdownQuery(BaseModel):version: float | None = Field(default=None, description="version of the node, used for schema migrations")+class MCPToolCallsAndErrorsQuery(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ dateRange: DateRange | None = None+ filterTestAccounts: bool | None = None+ interval: IntervalType | None = Field(+ default=None,+ description=("Bucket granularity; the frontend passes getDefaultInterval. Defaults to day."),+ )+ kind: Literal["MCPToolCallsAndErrorsQuery"] = "MCPToolCallsAndErrorsQuery"+ modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")+ properties: list[AnyPropertyFilterDiscriminated] | None = None+ response: MCPToolCallsAndErrorsQueryResponse | None = None+ tags: QueryLogTags | None = None+ version: float | None = Field(default=None, description="version of the node, used for schema migrations")++class MCPToolCategoriesQuery(BaseModel):model_config = ConfigDict(extra="forbid",@@ -26342,6 +26528,7 @@ class QueryResponseAlternative(| QueryResponseAlternative98| QueryResponseAlternative99| QueryResponseAlternative100+ | QueryResponseAlternative101]):root: (@@ -26442,6 +26629,7 @@ class QueryResponseAlternative(| QueryResponseAlternative98| QueryResponseAlternative99| QueryResponseAlternative100+ | QueryResponseAlternative101)@@ -27386,6 +27574,7 @@ class HogQLAutocomplete(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -27488,6 +27677,7 @@ class HogQLMetadata(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -27622,6 +27812,7 @@ class MaxInsightContext(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -27752,6 +27943,7 @@ class QueryRequest(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -27874,6 +28066,7 @@ class QuerySchemaRoot(| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -27966,6 +28159,7 @@ class QuerySchemaRoot(| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -28063,6 +28257,7 @@ class QueryUpgradeRequest(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -28160,6 +28355,7 @@ class QueryUpgradeResponse(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuery@@ -28439,6 +28635,7 @@ class VisualizationArtifactContent(BaseModel):| EndpointsUsageOverviewQuery| EndpointsUsageTableQuery| EndpointsUsageTrendsQuery+ | MCPToolCallsAndErrorsQuery| MCPHarnessBreakdownQuery| MCPToolTopUsersQuery| MCPToolFailuresQuerydiff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 6f183a990965..8548eafaf8b0 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -3233,6 +3233,7 @@ class NodeKind(StrEnum):ENDPOINTS_USAGE_OVERVIEW_QUERY = "EndpointsUsageOverviewQuery"ENDPOINTS_USAGE_TABLE_QUERY = "EndpointsUsageTableQuery"ENDPOINTS_USAGE_TRENDS_QUERY = "EndpointsUsageTrendsQuery"+ MCP_TOOL_CALLS_AND_ERRORS_QUERY = "MCPToolCallsAndErrorsQuery"MCP_HARNESS_BREAKDOWN_QUERY = "MCPHarnessBreakdownQuery"MCP_TOOL_TOP_USERS_QUERY = "MCPToolTopUsersQuery"MCP_TOOL_FAILURES_QUERY = "MCPToolFailuresQuery"diff --git a/products/mcp_analytics/backend/facade/queries.py b/products/mcp_analytics/backend/facade/queries.pyindex 1fdf5d61bca2..756861f2af5a 100644--- a/products/mcp_analytics/backend/facade/queries.py+++ b/products/mcp_analytics/backend/facade/queries.py@@ -5,6 +5,7 @@ mcp_analytics is tach-isolated to expose only `backend.facade.*`, so core's`backend.hogql_queries` directly."""+from products.mcp_analytics.backend.hogql_queries.dashboard_series import MCPToolCallsAndErrorsQueryRunnerfrom products.mcp_analytics.backend.hogql_queries.harness_breakdown import MCPHarnessBreakdownQueryRunnerfrom products.mcp_analytics.backend.hogql_queries.tool_quality_tables import (MCPToolCategoriesQueryRunner,@@ -25,6 +26,7 @@ from products.mcp_analytics.backend.hogql_queries.tool_tables import (__all__ = ["MCPHarnessBreakdownQueryRunner",+ "MCPToolCallsAndErrorsQueryRunner","MCPToolCategoriesQueryRunner","MCPToolCategoryCountsQueryRunner","MCPToolDailyStatsQueryRunner",diff --git a/products/mcp_analytics/backend/hogql_queries/base.py b/products/mcp_analytics/backend/hogql_queries/base.pyindex ea8ddeb77f8b..cd1485d50044 100644--- a/products/mcp_analytics/backend/hogql_queries/base.py+++ b/products/mcp_analytics/backend/hogql_queries/base.py@@ -17,7 +17,7 @@ from posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.rbac.user_access_control import UserAccessControl, UserAccessControlErrorif TYPE_CHECKING:- from posthog.schema import DateRange+ from posthog.schema import DateRange, IntervalTypefrom posthog.models.team import Teamfrom posthog.models.user import User@@ -66,10 +66,15 @@ def validate_mcp_analytics_access(team: "Team", user: "User") -> bool:return UserAccessControl(user=user, team=team).assert_access_level_for_resource("mcp_analytics", "viewer")-def mcp_query_date_range(team: "Team", date_range: "DateRange | None") -> QueryDateRange:+def mcp_query_date_range(+ team: "Team", date_range: "DateRange | None", interval: "IntervalType | None" = None+) -> QueryDateRange:+ # Runners that bucket should pass their interval: QueryDateRange only leaves a relative+ # date_from untruncated at minute and second granularity, so without it a "last hour" window+ # starts at the top of the hour and pulls up to an extra interval of calls.return QueryDateRange(date_range=date_range,team=team,- interval=None,+ interval=interval,now=datetime.now(team.timezone_info),)diff --git a/products/mcp_analytics/backend/hogql_queries/dashboard_series.py b/products/mcp_analytics/backend/hogql_queries/dashboard_series.pynew file mode 100644index 000000000000..995a16fe5562--- /dev/null+++ b/products/mcp_analytics/backend/hogql_queries/dashboard_series.py@@ -0,0 +1,126 @@+"""Query runners for the MCP analytics dashboard's interval-bucketed charts."""++from functools import cached_property+from typing import TYPE_CHECKING++from posthog.schema import (+ AnyPropertyFilterDiscriminated,+ CachedMCPToolCallsAndErrorsQueryResponse,+ MCPToolCallsAndErrorsItem,+ MCPToolCallsAndErrorsQuery,+ MCPToolCallsAndErrorsQueryResponse,+)++from posthog.hogql import ast+from posthog.hogql.parser import parse_expr, parse_select+from posthog.hogql.property import property_to_expr+from posthog.hogql.query import execute_hogql_query++from posthog.clickhouse.query_tagging import Feature, Product, tags_context+from posthog.hogql_queries.query_runner import AnalyticsQueryRunner+from posthog.hogql_queries.utils.query_date_range import QueryDateRange++from products.mcp_analytics.backend.constants import MCP_TOOL_CALL_EVENT+from products.mcp_analytics.backend.hogql_queries.base import mcp_query_date_range, validate_mcp_analytics_access++if TYPE_CHECKING:+ from posthog.models.team import Team+ from posthog.models.user import User++_IS_ERROR = "toBool(properties.$mcp_is_error)"+++def _dashboard_where(+ date_range: QueryDateRange,+ properties: list[AnyPropertyFilterDiscriminated] | None,+ filter_test_accounts: bool | None,+ team: "Team",+) -> ast.Expr:+ """WHERE for tool-name-bearing $mcp_tool_call events in the window, plus the dashboard's filters."""+ exprs: list[ast.Expr] = [+ parse_expr("event = {event}", placeholders={"event": ast.Constant(value=MCP_TOOL_CALL_EVENT)}),+ parse_expr("timestamp >= {date_from}", placeholders={"date_from": date_range.date_from_as_hogql()}),+ parse_expr("timestamp <= {date_to}", placeholders={"date_to": date_range.date_to_as_hogql()}),+ parse_expr("properties.$mcp_tool_name IS NOT NULL"),+ parse_expr("properties.$mcp_tool_name != ''"),+ ]+ all_properties = list(properties or [])+ if filter_test_accounts:+ all_properties += team.test_account_filters or []+ if all_properties:+ exprs.append(property_to_expr(all_properties, team))+ return ast.And(exprs=exprs)+++class MCPToolCallsAndErrorsQueryRunner(AnalyticsQueryRunner[MCPToolCallsAndErrorsQueryResponse]):+ """Interval-bucketed success/error split behind the dashboard's "Tool calls and errors" chart."""++ query: MCPToolCallsAndErrorsQuery+ cached_response: CachedMCPToolCallsAndErrorsQueryResponse++ def validate_query_runner_access(self, user: "User") -> bool:+ return validate_mcp_analytics_access(self.team, user)++ @cached_property+ def query_date_range(self) -> QueryDateRange:+ return mcp_query_date_range(self.team, self.query.dateRange, self.query.interval)++ def to_query(self) -> ast.SelectQuery | ast.SelectSetQuery:+ # toString keeps the bucket a plain project-timezone wall clock. A bare dateTrunc returns a+ # typed DateTime that the query API stamps with the project's UTC offset, which the client+ # reads back as an instant and converts, shifting every bucket off the axis keys it joins+ # against. The explicit generous LIMIT stops a fine interval over a wide window from being+ # cut to the default 100 rows, which with ORDER BY bucket ASC would drop the newest buckets.+ interval = self.query.interval.value if self.query.interval else "day"+ return parse_select(+ """+ SELECT+ toString(dateTrunc({interval}, timestamp)) AS bucket,+ countIf(NOT {_IS_ERROR}) AS successes,+ countIf({_IS_ERROR}) AS errors+ FROM events+ WHERE {where}+ GROUP BY bucket+ ORDER BY bucket+ LIMIT 10000+ """,+ placeholders={+ "interval": ast.Constant(value=interval),+ "_IS_ERROR": parse_expr(_IS_ERROR),+ "where": _dashboard_where(+ self.query_date_range,+ self.query.properties,+ self.query.filterTestAccounts,+ self.team,+ ),+ },+ )++ def _calculate(self) -> MCPToolCallsAndErrorsQueryResponse:+ with tags_context(+ product=Product.MCP_ANALYTICS,+ feature=Feature.QUERY,+ team_id=self.team.id,+ name="mcp_tool_calls_and_errors_query",+ ):+ response = execute_hogql_query(+ query=self.to_query(),+ team=self.team,+ user=self.user,+ query_type="mcp_tool_calls_and_errors_query",+ timings=self.timings,+ modifiers=self.modifiers,+ limit_context=self.limit_context,+ )++ results = [+ MCPToolCallsAndErrorsItem(+ bucket=str(row[0] or ""),+ successes=int(row[1] or 0),+ errors=int(row[2] or 0),+ )+ for row in (response.results or [])+ ]+ return MCPToolCallsAndErrorsQueryResponse(+ results=results, timings=response.timings, hogql=response.hogql, modifiers=self.modifiers+ )diff --git a/products/mcp_analytics/backend/tests/test_dashboard_series.py b/products/mcp_analytics/backend/tests/test_dashboard_series.pynew file mode 100644index 000000000000..950bfec65858--- /dev/null+++ b/products/mcp_analytics/backend/tests/test_dashboard_series.py@@ -0,0 +1,193 @@+from datetime import UTC, datetime+from typing import Any++from freezegun import freeze_time+from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events+from unittest.mock import patch++from parameterized import parameterized++from posthog.schema import (+ DateRange,+ EventPropertyFilter,+ IntervalType,+ MCPToolCallsAndErrorsItem,+ MCPToolCallsAndErrorsQuery,+ PropertyOperator,+)++from posthog.models.personal_api_key import PersonalAPIKey+from posthog.models.utils import generate_random_token_personal, hash_key_value+from posthog.rbac.user_access_control import UserAccessControlError++from products.mcp_analytics.backend.hogql_queries.dashboard_series import MCPToolCallsAndErrorsQueryRunner+from products.mcp_analytics.backend.tests import _MCPAnalyticsTeamScopedTestMixin+++class TestMCPToolCallsAndErrorsQueryRunner(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixin, APIBaseTest):+ def setUp(self) -> None:+ super().setUp()+ self.team.timezone = "US/Pacific"+ self.team.save()++ def _emit(+ self,+ *,+ timestamp: datetime,+ is_error: bool = False,+ tool_name: str = "query_run",+ extra: dict[str, Any] | None = None,+ ) -> None:+ _create_event(+ team=self.team,+ event="$mcp_tool_call",+ distinct_id="d1",+ timestamp=timestamp,+ properties={+ "$session_id": "s1",+ "$mcp_tool_name": tool_name,+ "$mcp_is_error": is_error,+ **(extra or {}),+ },+ )++ def _run(self, query: MCPToolCallsAndErrorsQuery) -> list[MCPToolCallsAndErrorsItem]:+ flush_persons_and_events()+ return MCPToolCallsAndErrorsQueryRunner(query=query, team=self.team).calculate().results++ def test_buckets_in_team_timezone_as_naive_strings(self) -> None:+ # 19:00 Pacific on the 20th, which is the 21st in UTC. Bucketing in UTC would file it a day+ # late, and a zone-stamped bucket would not join the wall-clock keys the client generates.+ self._emit(timestamp=datetime(2026, 7, 21, 2, 0, tzinfo=UTC))+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), is_error=True)+ self._emit(timestamp=datetime(2026, 7, 21, 19, 0, tzinfo=UTC))++ results = self._run(+ MCPToolCallsAndErrorsQuery(dateRange=DateRange(date_from="2026-07-19", date_to="2026-07-23"))+ )++ assert [(r.bucket, r.successes, r.errors) for r in results] == [+ ("2026-07-20 00:00:00", 1, 0),+ ("2026-07-21 00:00:00", 1, 1),+ ]++ def test_buckets_by_hour_when_the_interval_asks_for_it(self) -> None:+ self._emit(timestamp=datetime(2026, 7, 21, 18, 15, tzinfo=UTC))+ self._emit(timestamp=datetime(2026, 7, 21, 19, 45, tzinfo=UTC))++ results = self._run(+ MCPToolCallsAndErrorsQuery(+ dateRange=DateRange(date_from="2026-07-21", date_to="2026-07-22"),+ interval=IntervalType.HOUR,+ )+ )++ assert [r.bucket for r in results] == ["2026-07-21 11:00:00", "2026-07-21 12:00:00"]++ @parameterized.expand(+ [+ ("minute", IntervalType.MINUTE, "-1h", [("2026-07-21 11:10:00", 1)]),+ ("day", IntervalType.DAY, "-1d", [("2026-07-20 00:00:00", 1), ("2026-07-21 00:00:00", 2)]),+ ]+ )+ def test_relative_windows_follow_the_interval_granularity(+ self, _name: str, interval: IntervalType, date_from: str, expected: list[tuple[str, int]]+ ) -> None:+ # QueryDateRange only leaves a relative date_from untruncated at minute/second granularity.+ # Both directions matter here: "last hour" has to stay exact or it pulls in an extra chunk+ # of calls, while day and up has to cover whole days or the first bucket undercounts against+ # the wall-clock keys the client zero-fills with.+ with freeze_time("2026-07-21 18:30:00"):+ # 08:00 Pacific on the 20th: inside the truncated day window, outside an exact one.+ self._emit(timestamp=datetime(2026, 7, 20, 15, 0, tzinfo=UTC))+ # 10:15 Pacific: inside the truncated hour window (10:00), outside the exact one (10:30).+ self._emit(timestamp=datetime(2026, 7, 21, 17, 15, tzinfo=UTC))+ self._emit(timestamp=datetime(2026, 7, 21, 18, 10, tzinfo=UTC))++ results = self._run(+ MCPToolCallsAndErrorsQuery(+ dateRange=DateRange(date_from=date_from),+ interval=interval,+ )+ )++ assert [(r.bucket, r.successes) for r in results] == expected++ def test_property_filters_scope_the_series(self) -> None:+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), tool_name="query_run")+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), tool_name="other_tool")++ results = self._run(+ MCPToolCallsAndErrorsQuery(+ dateRange=DateRange(date_from="2026-07-19", date_to="2026-07-23"),+ properties=[+ EventPropertyFilter(key="$mcp_tool_name", value=["query_run"], operator=PropertyOperator.EXACT)+ ],+ )+ )++ assert [(r.bucket, r.successes) for r in results] == [("2026-07-21 00:00:00", 1)]++ def test_filter_test_accounts_applies_the_team_filters(self) -> None:+ self.team.test_account_filters = [+ {+ "key": "$mcp_tool_name",+ "value": ["internal_tool"],+ "operator": "is_not",+ "type": "event",+ }+ ]+ self.team.save()+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), tool_name="query_run")+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), tool_name="internal_tool")++ date_range = DateRange(date_from="2026-07-19", date_to="2026-07-23")+ unfiltered = self._run(MCPToolCallsAndErrorsQuery(dateRange=date_range))+ filtered = self._run(MCPToolCallsAndErrorsQuery(dateRange=date_range, filterTestAccounts=True))++ assert [r.successes for r in unfiltered] == [2]+ assert [r.successes for r in filtered] == [1]++ @parameterized.expand(+ [+ (["query:read"], 403),+ (["mcp_analytics:read"], 403),+ (["query:read", "mcp_analytics:read"], 200),+ ]+ )+ def test_query_endpoint_scope_parity_for_api_keys(self, scopes: list[str], expected_status: int) -> None:+ # The runner's access check reads the token owner's RBAC, not the token's granted scopes, so+ # without an entry in _QUERY_KIND_SCOPES the generic /query/ endpoint would serve this kind+ # to any token holding only query:read.+ value = generate_random_token_personal()+ PersonalAPIKey.objects.create(label="test", user=self.user, secure_value=hash_key_value(value), scopes=scopes)++ response = self.client.post(+ f"/api/projects/{self.team.pk}/query/",+ {"query": {"kind": "MCPToolCallsAndErrorsQuery"}},+ HTTP_AUTHORIZATION=f"Bearer {value}",+ )++ assert response.status_code == expected_status, response.json()++ def test_gates_on_the_mcp_analytics_flag(self) -> None:+ # Every other test calls calculate() with the flag already on, so a runner that lost its+ # validate_query_runner_access override would stay green while the generic /query/ endpoint+ # reached it ungated (the base implementation returns True).+ runner = MCPToolCallsAndErrorsQueryRunner(query=MCPToolCallsAndErrorsQuery(), team=self.team, user=self.user)++ assert runner.validate_query_runner_access(self.user) is True++ with patch("posthoganalytics.feature_enabled", return_value=False):+ with self.assertRaises(UserAccessControlError):+ runner.validate_query_runner_access(self.user)++ def test_excludes_calls_without_a_tool_name(self) -> None:+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC))+ self._emit(timestamp=datetime(2026, 7, 21, 18, 0, tzinfo=UTC), tool_name="")++ results = self._run(+ MCPToolCallsAndErrorsQuery(dateRange=DateRange(date_from="2026-07-19", date_to="2026-07-23"))+ )++ assert [(r.bucket, r.successes) for r in results] == [("2026-07-21 00:00:00", 1)]diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsxindex 60713aae5eb8..2ac05ddc600f 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx@@ -518,6 +518,18 @@ const meta: Meta = {},]}+ if (body?.query?.kind === 'MCPToolCallsAndErrorsQuery') {+ return [+ 200,+ {+ results: ACTIVITY_RESULTS.map(([bucket, successes, errors]) => ({+ bucket,+ successes,+ errors,+ })),+ },+ ]+ }if (body?.query?.kind === 'MCPToolCategoriesQuery') {return [200, { results: CATEGORY_LIST.map((r) => ({ category: r[0] })) }]}@@ -532,9 +544,6 @@ const meta: Meta = {if (query.includes('AS session_id')) {return [200, { results: SESSION_RESULTS }]}- if (query.includes('AS successes')) {- return [200, { results: ACTIVITY_RESULTS }]- }if (query.includes('GROUP BY day, tool')) {return [200, { results: TOOL_DAILY_RESULTS }]}diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.tsindex 60de24c1f14a..0b8a78206b30 100644--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts@@ -465,7 +465,7 @@ describe('mcpDashboardOverviewLogic', () => {const bucketed = mockApi.query.mock.calls.map((call) => (call[0] as any).query).filter((query: string | undefined): query is string => !!query?.includes('dateTrunc('))- expect(bucketed).toHaveLength(3)+ expect(bucketed).toHaveLength(2)expect(bucketed.filter((query) => !query.includes('toString(dateTrunc('))).toEqual([])})diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.tsindex e08408226429..2c2eda07dd67 100644--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts@@ -9,7 +9,13 @@ import { getDefaultInterval } from 'lib/utils/dateFilters'import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'-import { HogQLFilters, HogQLQueryResponse, MCPHarnessBreakdownItem, NodeKind } from '~/queries/schema/schema-general'+import {+ HogQLFilters,+ HogQLQueryResponse,+ MCPHarnessBreakdownItem,+ MCPToolCallsAndErrorsItem,+ NodeKind,+} from '~/queries/schema/schema-general'import { AnyPropertyFilter, IntervalType, TeamType } from '~/types'import type { TeamPublicType } from '../../../frontend/src/types'@@ -110,21 +116,6 @@ LIMIT 50// single source of truth for client → harness labelling — so the tile reads typed,// already-bucketed rows rather than re-deriving the labels in the browser.-// Daily success/error split powering the activity time-series bar chart.-const ACTIVITY_QUERY = `-SELECT- __BUCKET__ AS day,- countIf(NOT toBool(properties.$mcp_is_error)) AS successes,- countIf(toBool(properties.$mcp_is_error)) AS errors-FROM events-WHERE event = '$mcp_tool_call'- AND properties.$mcp_tool_name IS NOT NULL- AND properties.$mcp_tool_name != ''- AND {filters}-GROUP BY day-ORDER BY day-`-// Daily call counts per tool, powering the tool-usage stacked bar (one segment per tool).const TOOL_DAILY_QUERY = `SELECT@@ -141,7 +132,8 @@ ORDER BY dayLIMIT 10000`-// The `__BUCKET__` expression every bucketed query above is built with. toString() is load-bearing:+// The `__BUCKET__` expression the remaining inline bucketed queries are built with. toString() is+// load-bearing:// a bare dateTrunc returns a typed DateTime that the query API serializes with the project's UTC// offset attached (2026-07-21T00:00:00-07:00), which the client then reads back as an instant and// converts, shifting every bucket away from the wall-clock keys it joins and compares against.@@ -818,17 +810,19 @@ export const mcpDashboardOverviewLogic = kea<mcpDashboardOverviewLogicType>([[] as ActivityRow[],{loadActivityRows: async (_: void, breakpoint): Promise<ActivityRow[]> => {+ const { dateRange, properties, filterTestAccounts } = values.queryFiltersconst response = (await api.query({- kind: NodeKind.HogQLQuery,- query: ACTIVITY_QUERY.replace('__BUCKET__', bucketExpr(values.interval)),- filters: values.queryFilters,- })) as HogQLQueryResponse+ kind: NodeKind.MCPToolCallsAndErrorsQuery,+ dateRange,+ properties,+ filterTestAccounts,+ interval: values.interval,+ })) as { results?: MCPToolCallsAndErrorsItem[] }breakpoint()- const raw = (response?.results as unknown[][]) ?? []- return raw.map((r) => ({- day: normalizeBucket(r[0]),- successes: Number(r[1] ?? 0),- errors: Number(r[2] ?? 0),+ return (response?.results ?? []).map((r) => ({+ day: normalizeBucket(r.bucket),+ successes: r.successes,+ errors: r.errors,}))},},diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 123efe6f4f8f..3e8bd063f2c4 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -35766,6 +35766,50 @@ export namespace Schemas {version?: number | null;}+ export interface MCPToolCallsAndErrorsItem {+ /** Bucket start as a project-timezone wall clock ("YYYY-MM-DD HH:mm:ss"), never zone-stamped, so the client can join it against generated axis keys without reinterpreting it as an instant. */+ bucket: string;+ errors: number;+ successes: number;+ }++ export interface MCPToolCallsAndErrorsQueryResponse {+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ /** Generated HogQL query. */+ hogql?: string | null;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The resolved previous/comparison period date range, when comparing against another period */+ resolved_compare_date_range?: ResolvedDateRangeResponse | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: MCPToolCallsAndErrorsItem[];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ /** Connector-synced data warehouse sources referenced by this query, if any. */+ used_data_warehouse_sources?: DataWarehouseSourceUsage[] | null;+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. Also carries access control warnings when a system-table query filters out objects the user can't access. */+ warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;+ }++ export interface MCPToolCallsAndErrorsQuery {+ dateRange?: DateRange | null;+ filterTestAccounts?: boolean | null;+ /** Bucket granularity; the frontend passes getDefaultInterval. Defaults to day. */+ interval?: IntervalType | null;+ kind?: 'MCPToolCallsAndErrorsQuery';+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ properties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;+ response?: MCPToolCallsAndErrorsQueryResponse | null;+ tags?: QueryLogTags | null;+ /** version of the node, used for schema migrations */+ version?: number | null;+ }+export interface MCPHarnessBreakdownItem {error_rate_pct: number;errors: number;@@ -36389,7 +36433,7 @@ export namespace Schemas {query: string;response?: HogQLMetadataResponse | null;/** Query within which "expr" and "template" are validated. Defaults to "select * from events" */- sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | null;+ sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPToolCallsAndErrorsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | null;tags?: QueryLogTags | null;/** Variables to be subsituted into the query */variables?: HogQLMetadataVariables;@@ -36415,7 +36459,7 @@ export namespace Schemas {query: string;response?: HogQLAutocompleteResponse | null;/** Query in whose context to validate. */- sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | null;+ sourceQuery?: EventsNode | ActionsNode | PersonsNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | CalendarHeatmapQuery | RecordingsQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPToolCallsAndErrorsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | null;/** Start position of the editor word */startPosition: number;tags?: QueryLogTags | null;@@ -58246,7 +58290,7 @@ export namespace Schemas {* ```** For more details on HogQL queries, see the [PostHog HogQL documentation](/docs/hogql#api-access). */- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPToolCallsAndErrorsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;/** Whether results should be calculated sync or async, and how much to rely on the cache:* - `'blocking'` - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache* - `'async'` - kick off background calculation (returning immediately with a query status), UNLESS there are very fresh results in the cache@@ -60240,7 +60284,7 @@ export namespace Schemas {resolved_compare_date_range?: ResolvedDateRangeResponse | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: MCPHarnessBreakdownItem[];+ results: MCPToolCallsAndErrorsItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Connector-synced data warehouse sources referenced by this query, if any. */@@ -60262,7 +60306,7 @@ export namespace Schemas {resolved_compare_date_range?: ResolvedDateRangeResponse | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: MCPToolTopUserItem[];+ results: MCPHarnessBreakdownItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Connector-synced data warehouse sources referenced by this query, if any. */@@ -60284,7 +60328,7 @@ export namespace Schemas {resolved_compare_date_range?: ResolvedDateRangeResponse | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: MCPToolFailureItem[];+ results: MCPToolTopUserItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Connector-synced data warehouse sources referenced by this query, if any. */@@ -60306,7 +60350,7 @@ export namespace Schemas {resolved_compare_date_range?: ResolvedDateRangeResponse | null;/** The date range used for the query */resolved_date_range?: ResolvedDateRangeResponse | null;- results: MCPToolFailureOccurrenceItem[];+ results: MCPToolFailureItem[];/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;/** Connector-synced data warehouse sources referenced by this query, if any. */@@ -60316,6 +60360,28 @@ export namespace Schemas {}export interface QueryResponseAlternative91 {+ /** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */+ error?: string | null;+ /** Generated HogQL query. */+ hogql?: string | null;+ /** Modifiers used when performing the query */+ modifiers?: HogQLQueryModifiers | null;+ /** Query status indicates whether next to the provided data, a query is still running. */+ query_status?: QueryStatus | null;+ /** The resolved previous/comparison period date range, when comparing against another period */+ resolved_compare_date_range?: ResolvedDateRangeResponse | null;+ /** The date range used for the query */+ resolved_date_range?: ResolvedDateRangeResponse | null;+ results: MCPToolFailureOccurrenceItem[];+ /** Measured timings for different parts of the query generation process */+ timings?: QueryTiming[] | null;+ /** Connector-synced data warehouse sources referenced by this query, if any. */+ used_data_warehouse_sources?: DataWarehouseSourceUsage[] | null;+ /** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. Also carries access control warnings when a system-table query filters out objects the user can't access. */+ warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;+ }++ export interface QueryResponseAlternative92 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60338,7 +60404,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative92 {+ export interface QueryResponseAlternative93 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60360,7 +60426,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative93 {+ export interface QueryResponseAlternative94 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60382,7 +60448,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative94 {+ export interface QueryResponseAlternative95 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60404,7 +60470,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative95 {+ export interface QueryResponseAlternative96 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60426,7 +60492,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative96 {+ export interface QueryResponseAlternative97 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60448,7 +60514,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative97 {+ export interface QueryResponseAlternative98 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60470,7 +60536,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative98 {+ export interface QueryResponseAlternative99 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60492,7 +60558,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative99 {+ export interface QueryResponseAlternative100 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60514,7 +60580,7 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export interface QueryResponseAlternative100 {+ export interface QueryResponseAlternative101 {/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -60536,18 +60602,18 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}- export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative12 | QueryResponseAlternative13 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | unknown | QueryResponseAlternative33 | QueryResponseAlternative34 | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative50 | QueryResponseAlternative51 | QueryResponseAlternative52 | QueryResponseAlternative54 | QueryResponseAlternative55 | QueryResponseAlternative56 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative64 | QueryResponseAlternative65 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative71 | QueryResponseAlternative72 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative80 | QueryResponseAlternative81 | QueryResponseAlternative82 | QueryResponseAlternative83 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative86 | QueryResponseAlternative87 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93 | QueryResponseAlternative94 | QueryResponseAlternative95 | QueryResponseAlternative96 | QueryResponseAlternative97 | QueryResponseAlternative98 | QueryResponseAlternative99 | QueryResponseAlternative100;+ export type QueryResponseAlternative = { [key: string]: unknown } | QueryResponseAlternative1 | QueryResponseAlternative2 | QueryResponseAlternative3 | QueryResponseAlternative4 | QueryResponseAlternative5 | QueryResponseAlternative6 | QueryResponseAlternative7 | QueryResponseAlternative8 | QueryResponseAlternative9 | QueryResponseAlternative10 | QueryResponseAlternative11 | QueryResponseAlternative12 | QueryResponseAlternative13 | QueryResponseAlternative14 | QueryResponseAlternative15 | QueryResponseAlternative16 | QueryResponseAlternative17 | QueryResponseAlternative18 | QueryResponseAlternative19 | QueryResponseAlternative20 | QueryResponseAlternative21 | QueryResponseAlternative22 | QueryResponseAlternative23 | QueryResponseAlternative24 | QueryResponseAlternative25 | QueryResponseAlternative26 | QueryResponseAlternative27 | QueryResponseAlternative28 | QueryResponseAlternative29 | QueryResponseAlternative30 | QueryResponseAlternative31 | QueryResponseAlternative32 | unknown | QueryResponseAlternative33 | QueryResponseAlternative34 | QueryResponseAlternative35 | QueryResponseAlternative36 | QueryResponseAlternative37 | QueryResponseAlternative38 | QueryResponseAlternative39 | QueryResponseAlternative40 | QueryResponseAlternative41 | QueryResponseAlternative42 | QueryResponseAlternative43 | QueryResponseAlternative44 | QueryResponseAlternative45 | QueryResponseAlternative46 | QueryResponseAlternative47 | QueryResponseAlternative48 | QueryResponseAlternative50 | QueryResponseAlternative51 | QueryResponseAlternative52 | QueryResponseAlternative54 | QueryResponseAlternative55 | QueryResponseAlternative56 | QueryResponseAlternative57 | QueryResponseAlternative58 | QueryResponseAlternative59 | QueryResponseAlternative60 | QueryResponseAlternative62 | QueryResponseAlternative63 | QueryResponseAlternative64 | QueryResponseAlternative65 | QueryResponseAlternative66 | QueryResponseAlternative67 | QueryResponseAlternative68 | QueryResponseAlternative69 | QueryResponseAlternative70 | QueryResponseAlternative71 | QueryResponseAlternative72 | QueryResponseAlternative73 | QueryResponseAlternative74 | QueryResponseAlternative75 | QueryResponseAlternative76 | QueryResponseAlternative77 | QueryResponseAlternative80 | QueryResponseAlternative81 | QueryResponseAlternative82 | QueryResponseAlternative83 | QueryResponseAlternative84 | QueryResponseAlternative85 | QueryResponseAlternative86 | QueryResponseAlternative87 | QueryResponseAlternative88 | QueryResponseAlternative89 | QueryResponseAlternative90 | QueryResponseAlternative91 | QueryResponseAlternative92 | QueryResponseAlternative93 | QueryResponseAlternative94 | QueryResponseAlternative95 | QueryResponseAlternative96 | QueryResponseAlternative97 | QueryResponseAlternative98 | QueryResponseAlternative99 | QueryResponseAlternative100 | QueryResponseAlternative101;export interface QueryStatusResponse {query_status: QueryStatus;}export interface QueryUpgradeRequest {- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPToolCallsAndErrorsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;}export interface QueryUpgradeResponse {- query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;+ query: EventsNode | ActionsNode | PersonsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | EventsQuery | SessionsQuery | ActorsQuery | GroupsQuery | InsightActorsQuery | InsightActorsQueryOptions | SessionsTimelineQuery | HogQuery | HogQLQuery | HogQLMetadata | HogQLAutocomplete | SessionAttributionExplorerQuery | ErrorTrackingQuery | ErrorTrackingSimilarIssuesQuery | ErrorTrackingBreakdownsQuery | ErrorTrackingIssueCorrelationQuery | ExperimentFunnelsQuery | ExperimentTrendsQuery | ExperimentQuery | ExperimentExposureQuery | DocumentSimilarityQuery | WebOverviewQuery | WebStatsTableQuery | WebExternalClicksTableQuery | WebBotsTableQuery | WebGoalsQuery | WebVitalsQuery | WebVitalsPathBreakdownQuery | WebPageURLSearchQuery | WebAnalyticsExternalSummaryQuery | WebNotableChangesQuery | MarketingAnalyticsTableQuery | MarketingAnalyticsAggregatedQuery | NonIntegratedConversionsTableQuery | DataVisualizationNode | DataTableNode | SavedInsightNode | InsightVizNode | TrendsQuery | FunnelsQuery | RetentionQuery | PathsQuery | StickinessQuery | LifecycleQuery | FunnelCorrelationQuery | DatabaseSchemaQuery | RecordingsQuery | LogsQuery | LogAttributesQuery | LogValuesQuery | MetricsQuery | TraceSpansQuery | TraceSpansAggregationQuery | TraceSpansTreeQuery | TraceSpansAttributeBreakdownQuery | SuggestedQuestionsQuery | TeamTaxonomyQuery | EventTaxonomyQuery | ActorsPropertyTaxonomyQuery | TracesQuery | TraceQuery | SessionQuery | TraceNeighborsQuery | VectorSearchQuery | UsageMetricsQuery | AccountsQuery | EndpointsUsageOverviewQuery | EndpointsUsageTableQuery | EndpointsUsageTrendsQuery | MCPToolCallsAndErrorsQuery | MCPHarnessBreakdownQuery | MCPToolTopUsersQuery | MCPToolFailuresQuery | MCPToolFailureOccurrencesQuery | MCPToolStatsQuery | MCPToolDailyStatsQuery | MCPToolQualityRowsQuery | MCPToolQualityDailyStatsQuery | MCPToolCategoryCountsQuery | MCPToolCategoriesQuery | MCPToolDescriptionsQuery | MCPToolSampleIntentsQuery | MCPToolNeighborsQuery | PropertyValuesQuery;}export interface QuotaResourceLimit {