Skip to content

: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.

feat(mcp): automatically show harness marks in HogQL results (#115064)

Paul D'Ambra0715d075cdb5
diff --git a/docs/published/docs/mcp-analytics/harness-share.mdx b/docs/published/docs/mcp-analytics/harness-share.mdx
index 94811992c25d..a216df7658cd 100644
--- a/docs/published/docs/mcp-analytics/harness-share.mdx
+++ b/docs/published/docs/mcp-analytics/harness-share.mdx
@@ -42,4 +42,5 @@ ORDER BY calls DESC
```
The activity feed and recent calls table explicitly request logos for their Client and Model columns with `withIcon(label, mark)`.
-Other queries keep plain string values unless they request rich formatting.
+SQL results also add a harness logo automatically when you select `properties.$virt_mcp_harness` directly, including with an `AS` alias.
+The value stays a string for grouping and filtering. Nested queries do not yet carry the display hint.
diff --git a/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--dark.png b/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--dark.png
new file mode 100644
index 000000000000..e1f5f220fa52
Binary files /dev/null and b/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--dark.png differ
diff --git a/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--light.png b/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--light.png
new file mode 100644
index 000000000000..07e9460cc85e
Binary files /dev/null and b/frontend/__snapshots__/queries-datatable-harnesscolumn--arbitrary-query-result--light.png differ
diff --git a/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--dark.png b/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--dark.png
new file mode 100644
index 000000000000..ad1284462986
Binary files /dev/null and b/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--dark.png differ
diff --git a/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--light.png b/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--light.png
new file mode 100644
index 000000000000..2993a2c11b0b
Binary files /dev/null and b/frontend/__snapshots__/scenes-app-data-warehouse-sql-editor--harness-logo-in-results--light.png differ
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 8a4a0ba6daeb..754e099a73a4 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8346,6 +8346,10 @@ snapshots:
hash: v1.k794b7964.cc3f4b4df15bd7680a9b679ca3a94ee2f2b5b8280b54804b2d660a1d51f53dca.0OslRLTIOrEEAmg3MSk_Xp4XRYkH8Y73Svwhz78Wje4
queries-datatable-expliciticon--query-result--light:
hash: v1.k794b7964.df833adef5b5670cedd05e7cc282cdb04e65401492d9fc030a6437201561ec82.f8E44DPoHhYMUvejnRmIcNnheMKdiSRMa_5GdLCupY8
+ queries-datatable-harnesscolumn--arbitrary-query-result--dark:
+ hash: v1.k794b7964.b16b4ed1913fbe3942aa6282cbd4e3a166fbbdf32fc4e53cef7adf97f00d2336.P9x17WzBdvzIy3lZSVhWTY6Kz2lNjMWlvMWiJ-Qx9d0
+ queries-datatable-harnesscolumn--arbitrary-query-result--light:
+ hash: v1.k794b7964.3875aa4d2826a34a035d8da68aa05734d412af03ac6f14fd1bd2a7807985167d.a5nSly5FdcZENmGcfyFRPvOZcAc79U1Ha5KZhIGU8fE
queries-webvitals--web-vitals--dark:
hash: v1.k794b7964.2ae778a0c5fdba3c69dfcbd3e9589c3c3d9cc2f0fef2eefd304c565be7e9a7c9.hH71byl33sIAdRCgaPk1lDOev0qooW1xhv0AL_yrIvg
queries-webvitals--web-vitals--light:
@@ -10274,6 +10278,10 @@ snapshots:
hash: v1.k794b7964.57136a6dbeab9ac511a2a5e0c7401b23a4cb0ac00d82a2be177b84f74a60ebb0.QicPm3hXLpA9re3ShhfrqX6bKcWmuAvRBCtbRpHrSFQ
scenes-app-data-warehouse-sql-editor--edited-view--light:
hash: v1.k794b7964.1bada9403e11b62a50423adde53ce13fcd10a5bd6c33a210f5dd58a10a956cf8.2N9MES9JfDzATg0m-6cJnj7FWTzNt6ZlLxGqqoAI54A
+ scenes-app-data-warehouse-sql-editor--harness-logo-in-results--dark:
+ hash: v1.k794b7964.83437273f5119c5f292fad5fe8a6c389444776d534a134111b0b9049430ffffd.cz4bKXqalkafd6knGBg3gj7x0-8T5p7NLuix9rG6GPw
+ scenes-app-data-warehouse-sql-editor--harness-logo-in-results--light:
+ hash: v1.k794b7964.261adb2063efa109811c70908e6d117f1efa1229135bcd341ec2da3507b5975b.tvMMteHD7B5av-EjfaSoJx8R3FPAPozw8oL3Ur4_lM4
scenes-app-data-warehouse-sql-editor--hosted-trino--dark:
hash: v1.k794b7964.9c5c2408b68039d1989e4b7d52a787ba6739326a0207118bed07db27c6385eda.slBWrouzz0S3bARV3vpB-WyUyyu4o7c3oCcvLPi-8kw
scenes-app-data-warehouse-sql-editor--hosted-trino--light:
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index 75d42620d217..d6188d537f4c 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -2,7 +2,7 @@ import './DataTable.scss'
import clsx from 'clsx'
import { BindLogic, BuiltLogic, LogicWrapper, useActions, useValues } from 'kea'
-import { useCallback, useMemo, useState } from 'react'
+import { useCallback, useMemo, useRef, useState } from 'react'
import { PreAggregatedBadge } from 'lib/components/PreAggregatedBadge'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
@@ -273,6 +273,11 @@ export function DataTable({
[sourceFeatures, columnsInResponse, columnsInQuery]
)
const contextColumns = context?.columns
+ const columnFormatsRef = useRef<(string | null)[] | undefined>(undefined)
+ columnFormatsRef.current =
+ isHogQLQuery(query.source) && response && 'column_formats' in response
+ ? (response.column_formats as (string | null)[] | undefined)
+ : undefined
const columnsInLemonTable = useMemo(
() =>
allColumns.filter((colName) => {
@@ -356,7 +361,17 @@ export function DataTable({
const value = sourceFeatures.has(QueryFeature.resultIsArrayOfArrays)
? (result as any[])[index]
: (result as Record<string, any>)[key]
- return renderColumn(key, value, result, recordIndex, rowCount, query, setQuery, context)
+ return renderColumn(
+ key,
+ value,
+ result,
+ recordIndex,
+ rowCount,
+ query,
+ setQuery,
+ context,
+ columnFormatsRef.current?.[index]
+ )
}
},
sorter: undefined, // using custom sorting code
diff --git a/frontend/src/queries/nodes/DataTable/HarnessColumn.stories.tsx b/frontend/src/queries/nodes/DataTable/HarnessColumn.stories.tsx
new file mode 100644
index 000000000000..69e9328ce5fe
--- /dev/null
+++ b/frontend/src/queries/nodes/DataTable/HarnessColumn.stories.tsx
@@ -0,0 +1,42 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { DataTable } from '~/queries/nodes/DataTable/DataTable'
+import { DataTableNode, HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
+
+const query: DataTableNode = {
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.HogQLQuery,
+ query: 'SELECT properties.$virt_mcp_harness AS client, count() AS calls FROM events GROUP BY client',
+ },
+}
+
+const cachedResults: HogQLQueryResponse = {
+ columns: ['client', 'calls'],
+ column_formats: ['mcp_harness', null],
+ types: ['String', 'UInt64'],
+ results: [
+ ['Claude Code', 12],
+ ['OpenAI Codex', 7],
+ ['Other', 2],
+ ],
+}
+
+const meta: Meta<typeof DataTable> = {
+ title: 'Queries/DataTable/HarnessColumn',
+ component: DataTable,
+ parameters: {
+ testOptions: { waitForSelector: '.DataTable [data-attr="hogqlx-brand-mark-label"]' },
+ },
+}
+
+export default meta
+
+export const ArbitraryQueryResult: StoryObj<typeof DataTable> = {
+ tags: ['harness-result-visual'],
+ render: () => (
+ <div className="p-4">
+ <DataTable query={query} setQuery={() => {}} cachedResults={cachedResults} readOnly />
+ </div>
+ ),
+}
diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx
index c9055549f8d1..df8165c8e63f 100644
--- a/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx
+++ b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx
@@ -69,6 +69,24 @@ describe('renderColumn', () => {
beforeEach(() => initKeaTests())
afterEach(() => cleanup())
+ it.each<[string, string | undefined, boolean]>([
+ ['Claude Code', 'mcp_harness', true],
+ ['Other', 'mcp_harness', true],
+ ['Claude Code', undefined, false],
+ ])('renders %s with format %s and icon %s', (label, format, hasIcon) => {
+ const query = setLatestVersionsOnQuery({
+ kind: NodeKind.DataTableNode,
+ source: { kind: NodeKind.HogQLQuery, query: 'SELECT properties.$virt_mcp_harness AS client FROM events' },
+ }) as DataTableNode
+
+ const { container } = render(
+ <Provider>{renderColumn('client', label, [label], 0, 1, query, undefined, undefined, format)}</Provider>
+ )
+
+ expect(screen.getByText(label)).toBeInTheDocument()
+ expect(container.querySelector('svg') !== null).toBe(hasIcon)
+ })
+
it.each([
['a person profile supplied the name', '[email protected]', 1],
['the name fell back to the distinct ID', 'the-distinct-id', 0],
diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.tsx
index d714c4eebbe0..fda6bc4ee78f 100644
--- a/frontend/src/queries/nodes/DataTable/renderColumn.tsx
+++ b/frontend/src/queries/nodes/DataTable/renderColumn.tsx
@@ -43,6 +43,7 @@ import {
import { AnyPropertyFilter, EventType, PersonType, PropertyFilterType, PropertyOperator } from '~/types'
import { aiObservabilityGlobalColumnRenderers } from 'products/ai_observability/frontend/aiObservabilityGlobalColumns'
+import { HarnessLabel } from 'products/mcp_analytics/frontend/dashboard/HarnessLabel'
import { GroupActorDisplay } from 'products/persons/frontend/components/GroupActorDisplay'
import { PersonDisplay, PersonDisplayProps } from 'products/persons/frontend/components/PersonDisplay'
import { pickBestPersonDistinctId } from 'products/persons/frontend/person-utils'
@@ -95,7 +96,8 @@ export function renderColumn(
rowCount: number,
query: DataTableNode,
setQuery?: (query: DataTableNode) => void,
- context?: QueryContext<DataTableNode>
+ context?: QueryContext<DataTableNode>,
+ columnFormat?: string | null
): JSX.Element | string {
const { queryContextColumnName, queryContextColumn } = getContextColumn(key, context?.columns)
const originalKey = key
@@ -111,6 +113,8 @@ export function renderColumn(
return <Spinner />
} else if (value === errorColumn) {
return <LemonTag className="text-danger">Error</LemonTag>
+ } else if (columnFormat === 'mcp_harness' && typeof value === 'string') {
+ return <HarnessLabel category={value} />
} else if (queryContextColumnName && queryContextColumn?.render) {
const Component = queryContextColumn?.render
return (
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 511f961eb4bc..7ad3e99f4924 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -9904,6 +9904,13 @@
"description": "Executed ClickHouse query",
"type": "string"
},
+ "column_formats": {
+ "description": "Display formats for directly selected virtual properties, aligned with columns.",
+ "items": {
+ "type": ["string", "null"]
+ },
+ "type": "array"
+ },
"columns": {
"description": "Returned columns",
"items": {},
@@ -19139,6 +19146,13 @@
"description": "Executed ClickHouse query",
"type": "string"
},
+ "column_formats": {
+ "description": "Display formats for directly selected virtual properties, aligned with columns.",
+ "items": {
+ "type": ["string", "null"]
+ },
+ "type": "array"
+ },
"columns": {
"description": "Returned columns",
"items": {},
@@ -29863,6 +29877,13 @@
"description": "Executed ClickHouse query",
"type": "string"
},
+ "column_formats": {
+ "description": "Display formats for directly selected virtual properties, aligned with columns.",
+ "items": {
+ "type": ["string", "null"]
+ },
+ "type": "array"
+ },
"columns": {
"description": "Returned columns",
"items": {},
@@ -42522,6 +42543,13 @@
"description": "Executed ClickHouse query",
"type": "string"
},
+ "column_formats": {
+ "description": "Display formats for directly selected virtual properties, aligned with columns.",
+ "items": {
+ "type": ["string", "null"]
+ },
+ "type": "array"
+ },
"columns": {
"description": "Returned columns",
"items": {},
@@ -45122,6 +45150,13 @@
"description": "Executed ClickHouse query",
"type": "string"
},
+ "column_formats": {
+ "description": "Display formats for directly selected virtual properties, aligned with columns.",
+ "items": {
+ "type": ["string", "null"]
+ },
+ "type": "array"
+ },
"columns": {
"description": "Returned columns",
"items": {},
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 8ecbb36d2d6c..81acca0f8c4f 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -682,6 +682,8 @@ export interface HogQLQueryResponse<T = any[]> extends AnalyticsQueryResponseBas
clickhouse?: string
/** Returned columns */
columns?: any[]
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[]
/** Types of returned columns */
types?: any[]
/** Query explanation output */
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
index 185a0ca5e34c..877ae4a8aa61 100644
--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
@@ -87,6 +87,7 @@ import {
import { WarehouseWizardHint } from 'products/data_warehouse/frontend/shared/components/WarehouseWizardHint'
import { aiChartRecommendationLogic } from 'products/data_warehouse/frontend/sql_editor/aiChartRecommendationLogic'
+import { HarnessLabel } from 'products/mcp_analytics/frontend/dashboard/HarnessLabel'
import { HogQLBoldNumber } from 'products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber'
import {
@@ -779,6 +780,9 @@ export function OutputPane({ tabId, showToolbar = true, biMode = false, onShareT
renderCell: (props: any) => {
const columnKey = `${column}_${index}`
const value = props.row[columnKey]
+ if (response.column_formats?.[index] === 'mcp_harness' && typeof value === 'string') {
+ return <HarnessLabel category={value} />
+ }
if (typeof value === 'string' && value.startsWith('["__hx_tag",') && value.endsWith(']')) {
try {
const parsedHogQLX = JSON.parse(value)
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
index cbe6eb2023ca..c96febc04047 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
@@ -6,6 +6,7 @@ import { BindLogic } from 'kea'
import { delay } from 'msw'
import { useEffect, useRef } from 'react'
+import { mcpHintLogic } from 'lib/components/MCPHint/mcpHintLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { App } from 'scenes/App'
import { organizationLogic } from 'scenes/organizationLogic'
@@ -94,6 +95,26 @@ const SQL_RESULTS = {
],
}
+const HARNESS_SQL = `SELECT properties.$virt_mcp_harness AS harness, count() AS calls
+FROM events
+WHERE event = '$mcp_tool_call'
+GROUP BY harness
+ORDER BY calls DESC`
+
+const HARNESS_RESULTS = {
+ columns: ['harness', 'calls'],
+ column_formats: ['mcp_harness', null],
+ types: [
+ ['harness', 'String'],
+ ['calls', 'UInt64'],
+ ],
+ results: [
+ ['Claude Code', 12],
+ ['OpenAI Codex', 7],
+ ['Other', 2],
+ ],
+}
+
// The empty-warehouse notice in the sidebar renders a SourceIcon per provider, each of which shows a
// LemonSkeleton until availableSourcesLogic resolves. Without this mock the skeletons never settle and
// the visual-regression runner times out waiting for loaders to disappear.
@@ -170,6 +191,7 @@ const meta: Meta = {
'/api/environments/:team_id/external_data_sources/wizard': () => [200, AVAILABLE_SOURCES],
'/api/:scope/:team_id/external_data_sources/connections/': [],
'/api/:scope/:team_id/external_data_sources/direct_connection_options/': [],
+ '/api/projects/:team_id/query_tab_state/user': [200, { tabs: [] }],
},
post: {
'/api/environments/:team_id/query/:kind': async ({ request }) => {
@@ -184,6 +206,9 @@ const meta: Meta = {
if (body?.query?.query === 'SELECT category, revenue FROM example_sales') {
return [200, CHART_EXPERIMENT_RESULTS]
}
+ if (JSON.stringify(body?.query ?? {}).includes('$virt_mcp_harness')) {
+ return [200, HARNESS_RESULTS]
+ }
return [200, SQL_RESULTS]
},
},
@@ -257,6 +282,36 @@ export const HostedTrino: Story = {
},
}
+export const HarnessLogoInResults: Story = {
+ tags: ['harness-result-visual'],
+ parameters: {
+ pageUrl: urls.sqlEditor({ query: HARNESS_SQL }),
+ testOptions: {
+ waitForSelector: '.rdg [data-attr="hogqlx-brand-mark-label"]',
+ viewport: { width: 1600, height: 900 },
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ await waitFor(
+ () => {
+ const logic = sqlEditorLogic({ tabId: 'default' })
+ expect(logic.values.queryInput).toBe(HARNESS_SQL)
+ expect(dataNodeLogic.findMounted({ key: logic.values.dataLogicKey })).toBeTruthy()
+ },
+ { timeout: 15000 }
+ )
+ const runButton = await canvas.findByRole('button', { name: 'Run' }, { timeout: 15000 })
+ await waitFor(() => expect(runButton).toHaveAttribute('aria-disabled', 'false'), { timeout: 15000 })
+ mcpHintLogic.actions.recordShown(Date.now())
+ await userEvent.click(runButton)
+ await expect(
+ await canvas.findByText('Claude Code', { selector: '.rdg span' }, { timeout: 15000 })
+ ).toBeVisible()
+ await expect(canvas.getByText('OpenAI Codex')).toBeVisible()
+ },
+}
+
export const LoadingInsight: Story = {
parameters: {
pageUrl: `${urls.sqlEditor()}?open_insight=loading1`,
diff --git a/posthog/hogql/query.py b/posthog/hogql/query.py
index fc720999ecc2..569cfa1babba 100644
--- a/posthog/hogql/query.py
+++ b/posthog/hogql/query.py
@@ -605,6 +605,28 @@ class HogQLQueryExecutor:
return {}
return types
+ def _column_formats(self) -> list[str | None] | None:
+ if self.send_raw_query and self.connection_id is not None:
+ return None
+ select = next(extract_select_queries(self.select_query), None)
+ if select is None:
+ return None
+ formats: list[str | None] = [None] * len(self.print_columns)
+ column_positions = {name: index for index, name in enumerate(self.print_columns)}
+ for index, expression in enumerate(select.select):
+ alias = expression.alias if isinstance(expression, ast.Alias) else None
+ if isinstance(expression, ast.Alias):
+ expression = expression.expr
+ if isinstance(expression, ast.Field) and expression.chain[-1] == "$virt_mcp_harness":
+ if len(select.select) == len(self.print_columns):
+ formats[index] = "mcp_harness"
+ else:
+ column_name = alias or str(expression.chain[-1])
+ column_position = column_positions.get(column_name)
+ if column_position is not None:
+ formats[column_position] = "mcp_harness"
+ return formats if any(formats) else None
+
def _detect_warehouse_sources(self) -> list[WarehouseSourceUsage]:
"""Detect connector-synced data warehouse sources referenced by the (resolved) query and
store them for the query response. Never raises — telemetry must not break query execution."""
@@ -1091,6 +1113,7 @@ class HogQLQueryExecutor:
timings=self.timings.to_list(),
results=self.results,
columns=self.print_columns,
+ column_formats=self._column_formats(),
types=self.types,
modifiers=self.query_modifiers,
explain=self.explain,
diff --git a/posthog/hogql/test/test_direct_motherduck_query.py b/posthog/hogql/test/test_direct_motherduck_query.py
index 11fc3759c1b9..5faa79c1ed93 100644
--- a/posthog/hogql/test/test_direct_motherduck_query.py
+++ b/posthog/hogql/test/test_direct_motherduck_query.py
@@ -115,6 +115,7 @@ class TestDirectMotherDuckQuery(APIBaseTest):
self.assertEqual(response.results, [(3, "ny")])
self.assertEqual(response.types, [("n", "Int64"), ("c", "String")])
+ self.assertIsNone(response.column_formats)
@parameterized.expand(
[
diff --git a/posthog/hogql_queries/test/test_hogql_query_runner.py b/posthog/hogql_queries/test/test_hogql_query_runner.py
index 9155d64088c7..54071e1f634d 100644
--- a/posthog/hogql_queries/test/test_hogql_query_runner.py
+++ b/posthog/hogql_queries/test/test_hogql_query_runner.py
@@ -195,6 +195,7 @@ class TestHogQLQueryRunner(ClickhouseTestMixin, APIBaseTest):
response = cast(CachedHogQLQueryResponse, runner.run())
self.assertIsNotNone(response.cache_target_age)
+ self.assertIsNone(response.column_formats)
self.assertEqual(response.cache_target_age, expected_target_age)
@parameterized.expand(
diff --git a/posthog/schema.py b/posthog/schema.py
index 518142dbab81..b1130c85171f 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -28477,6 +28477,10 @@ class HogQLQueryResponse(BaseModel):
extra="forbid",
)
clickhouse: str | None = Field(default=None, description="Executed ClickHouse query")
+ column_formats: list[str | None] | None = Field(
+ default=None,
+ description=("Display formats for directly selected virtual properties, aligned with columns."),
+ )
columns: list | None = Field(default=None, description="Returned columns")
error: str | None = Field(
default=None,
@@ -29605,6 +29609,10 @@ class QueryResponseAlternative8(BaseModel):
extra="forbid",
)
clickhouse: str | None = Field(default=None, description="Executed ClickHouse query")
+ column_formats: list[str | None] | None = Field(
+ default=None,
+ description=("Display formats for directly selected virtual properties, aligned with columns."),
+ )
columns: list | None = Field(default=None, description="Returned columns")
error: str | None = Field(
default=None,
@@ -29709,6 +29717,10 @@ class QueryResponseAlternative40(BaseModel):
extra="forbid",
)
clickhouse: str | None = Field(default=None, description="Executed ClickHouse query")
+ column_formats: list[str | None] | None = Field(
+ default=None,
+ description=("Display formats for directly selected virtual properties, aligned with columns."),
+ )
columns: list | None = Field(default=None, description="Returned columns")
error: str | None = Field(
default=None,
@@ -30475,6 +30487,10 @@ class CachedHogQLQueryResponse(BaseModel):
description=("What triggered the calculation of the query, leave empty if user/immediate"),
)
clickhouse: str | None = Field(default=None, description="Executed ClickHouse query")
+ column_formats: list[str | None] | None = Field(
+ default=None,
+ description=("Display formats for directly selected virtual properties, aligned with columns."),
+ )
columns: list | None = Field(default=None, description="Returned columns")
error: str | None = Field(
default=None,
@@ -30569,6 +30585,10 @@ class Response3(BaseModel):
extra="forbid",
)
clickhouse: str | None = Field(default=None, description="Executed ClickHouse query")
+ column_formats: list[str | None] | None = Field(
+ default=None,
+ description=("Display formats for directly selected virtual properties, aligned with columns."),
+ )
columns: list | None = Field(default=None, description="Returned columns")
error: str | None = Field(
default=None,
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index e31fb8deced4..f7f8420a91aa 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -5106,6 +5106,8 @@ export interface HogQLMetadataResponseApi {
export interface Response3Api {
/** Executed ClickHouse query */
clickhouse?: string | null
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null
/** Returned columns */
columns?: unknown[] | null
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -7005,6 +7007,8 @@ export interface HogQLFiltersApi {
export interface HogQLQueryResponseApi {
/** Executed ClickHouse query */
clickhouse?: string | null
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null
/** Returned columns */
columns?: unknown[] | null
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.ts
index c1d3c2842079..f98598528f66 100644
--- a/products/desktop/packages/api-client/src/generated.ts
+++ b/products/desktop/packages/api-client/src/generated.ts
@@ -4354,6 +4354,7 @@ export namespace Schemas {
};
export type HogQLQueryResponse = {
clickhouse?: (string | null) | undefined;
+ column_formats?: (Array<string | null> | null) | undefined;
columns?: (Array<unknown> | null) | undefined;
error?: (string | null) | undefined;
explain?: (Array<string> | null) | undefined;
@@ -6886,6 +6887,7 @@ export namespace Schemas {
};
export type Response3 = {
clickhouse?: (string | null) | undefined;
+ column_formats?: (Array<string | null> | null) | undefined;
columns?: (Array<unknown> | null) | undefined;
error?: (string | null) | undefined;
explain?: (Array<string> | null) | undefined;
diff --git a/products/mcp_analytics/backend/tests/test_harness_breakdown.py b/products/mcp_analytics/backend/tests/test_harness_breakdown.py
index 5c56cd1bbf2d..94cf37ce8b1f 100644
--- a/products/mcp_analytics/backend/tests/test_harness_breakdown.py
+++ b/products/mcp_analytics/backend/tests/test_harness_breakdown.py
@@ -101,6 +101,7 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
)
self.assertEqual(response.columns, ["client", "calls"])
+ self.assertEqual(response.column_formats, ["mcp_harness", None])
self.assertEqual(response.results, [("OpenAI Codex", 2), ("Claude Code", 1)])
def test_virtual_harness_property_is_empty_on_other_events(self) -> None:
@@ -133,6 +134,27 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
self.assertEqual(response.results, [[("__hx_tag", "BrandMarkLabel", "label", label, "mark", mark)]])
+ @parameterized.expand(
+ [
+ ("aliased", " AS harness", "harness"),
+ ("unaliased", "", "$virt_mcp_harness"),
+ ]
+ )
+ def test_virtual_harness_property_keeps_format_after_wildcard(
+ self, _name: str, alias: str, column_name: str
+ ) -> None:
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client"})
+
+ response = execute_hogql_query(
+ f"SELECT *, properties.$virt_mcp_harness{alias} FROM events WHERE event = '$mcp_tool_call' LIMIT 1",
+ team=self.team,
+ )
+
+ assert response.columns is not None
+ assert response.column_formats is not None
+ self.assertEqual(response.columns[-1], column_name)
+ self.assertEqual(response.column_formats[-1], "mcp_harness")
+
def test_tool_name_scopes_to_effective_tool_and_new_sdk(self) -> None:
new_sdk = {"$mcp_source": "posthog_mcp_analytics"}
self._emit(distinct_id="d1", properties={"$mcp_client_name": "claude-ai", **new_sdk})
diff --git a/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx b/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx
new file mode 100644
index 000000000000..f8de5a505af2
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/HarnessLabel.tsx
@@ -0,0 +1,6 @@
+import { BrandMarkLabel } from '../components/BrandMarkLabel'
+import { harnessMark } from './harnessRegistry'
+
+export function HarnessLabel({ category }: { category: string }): JSX.Element {
+ return <BrandMarkLabel label={category} mark={harnessMark(category)} />
+}
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 24d980277c3a..8a64d278d4ec 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -3973,6 +3973,8 @@ export interface HogQLMetadataResponseApi {
export interface Response3Api {
/** Executed ClickHouse query */
clickhouse?: string | null
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null
/** Returned columns */
columns?: unknown[] | null
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -5872,6 +5874,8 @@ export interface HogQLFiltersApi {
export interface HogQLQueryResponseApi {
/** Executed ClickHouse query */
clickhouse?: string | null
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null
/** Returned columns */
columns?: unknown[] | null
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index adbcb12ebeaa..471720f87f93 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -7584,6 +7584,8 @@ export namespace Schemas {
export interface HogQLQueryResponse {
/** Executed ClickHouse query */
clickhouse?: string | null;
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null;
/** Returned columns */
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -8417,6 +8419,8 @@ export namespace Schemas {
export interface Response3 {
/** Executed ClickHouse query */
clickhouse?: string | null;
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null;
/** Returned columns */
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -93449,6 +93453,8 @@ export namespace Schemas {
export interface QueryResponseAlternative8 {
/** Executed ClickHouse query */
clickhouse?: string | null;
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null;
/** Returned columns */
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
@@ -94279,6 +94285,8 @@ export namespace Schemas {
export interface QueryResponseAlternative40 {
/** Executed ClickHouse query */
clickhouse?: string | null;
+ /** Display formats for directly selected virtual properties, aligned with columns. */
+ column_formats?: (string | null)[] | null;
/** Returned columns */
columns?: unknown[] | null;
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */