: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): gate intent clustering (#91074)
Lucas Fariab164992b4cb7
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex ab450b426f18..d31b63e7eebc 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7353,17 +7353,17 @@ snapshots:scenes-app-max-ai-replay-vision-scan-widget--with-skipped--light:hash: v1.k794b7964.c543228b0f31abb2aae3b274819abdee4ba6a89fb3324fc6aaa2b18aefee5815.S9etTEY8oT2JhOgLO5hdc6VqvbvYhD-nU4P1WKh24ygscenes-app-mcp-analytics--activity--dark:- hash: v1.k794b7964.fee5b0d29723a6bd9b57e4156e9e5e6e08eeab2f8fd7f5a9f11e3755417695d5.zLaglPs_UUTHRFCjpGKyFgXfdVSbgqFwJNGxJCD49ao+ hash: v1.k794b7964.8260dddad89625bb262d04be928f4e417d5b82195adcd475563dea59ae8f380e.CtzjnY-sch0rG7R9hkAD6Ai5SDP40LNsBsW5hQhJJysscenes-app-mcp-analytics--activity--light:hash: v1.k794b7964.473eea859bb71b592d4192301ff6b6f80d0b31bc60d992537d1f4c72ef5a54fa.TYyn1fQMICc0v0oJjArYuI8WHq9LrVDDeu8ECeEAFacscenes-app-mcp-analytics--dashboard--dark:- hash: v1.k794b7964.98d14c1adf3b8713a5a04d0e6ffa8db92191ff2f8b53ed9bec741a7cba5853ba.OGLbWNab5BvMifNsvxFEeiQkKYDJC53-B9_whXUSXis+ hash: v1.k794b7964.28e8830f28c77c1815afd94747a5f8633a0ff6dff72e7e8a104a84e3d131730c.-r295uHlJ_mpxJzjEHlMP9iM4FsOwaWVrRcfaW-Q4zMscenes-app-mcp-analytics--dashboard--light:- hash: v1.k794b7964.8085bf3b0d7cf70cfcdbc11a9ca9ae2823f07271a03230fa7e22b343ebbdf4c1.hG5BDPQ_aqdiioaYbf5Z1SjuAJSM2nzbJWupyc1VtUk+ hash: v1.k794b7964.6589aff34fd8f919ee7ba778e08bbe014e6ce6879bcf9685f6767326019d5864.r8Hqmi8hT0hyU7UYQ6cbEqrTl684LwA_EGIcis8ua_kscenes-app-mcp-analytics--dashboard-with-menu-bar--dark:- hash: v1.k794b7964.dc3eef1f6c65e7ff933fdcf3c9090f60f23a5f45f1320a6d861d30e694dd2fd3.iEUj4a-vYM-niKMu2OCIR6BawDk5cunSqRnMG1u00fk+ hash: v1.k794b7964.29be085c9a74e345db1e01d2f6b00215a00cf0fecf0f103c12ac889120ba496c.Q9PSjP5NmIpX3_-JisenZc6BcEx-71p1k7cSZSBfwOsscenes-app-mcp-analytics--dashboard-with-menu-bar--light:- hash: v1.k794b7964.0ac0bf1b02890312bdc239db7a4842f1a377468aa9c5ad67c926aecaccf510ce.V7Onp6uOX4j46-gDndut-qkT9N6LwIUCq5z4hVn-VZg+ hash: v1.k794b7964.fed2fab63229808ff080f6fbaba0ac2b62a142115aef7cabf7cf76e9b76df4c1.3RjkxSUK0AH36KxmtfENWCEu7H3bwvKzz0kyYQYcjGEscenes-app-mcp-analytics--intent-clustering--dark:hash: v1.k794b7964.e56c2b8b08a970df9e0fe9d6d618092c631d23d7c72a22b32bf571a663fcf9e9.84fphIJJ3z1hojod_YDTvqtsP_PexYwYUmbFcqCw-xQscenes-app-mcp-analytics--intent-clustering--light:diff --git a/products/mcp_analytics/backend/facade/contracts.py b/products/mcp_analytics/backend/facade/contracts.pyindex 27fac2506f0c..ce5aaae6af30 100644--- a/products/mcp_analytics/backend/facade/contracts.py+++ b/products/mcp_analytics/backend/facade/contracts.py@@ -4,6 +4,8 @@ from uuid import UUIDfrom .enums import SubmissionKind+MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAG = "mcp-analytics-intent-routing"+class IntentGenerationUnavailable(RuntimeError):"""Raised when session-intent generation can't complete (LLM unconfigured or request failed).diff --git a/products/mcp_analytics/backend/presentation/views.py b/products/mcp_analytics/backend/presentation/views.pyindex ceba9ff7f11d..2740a82e1250 100644--- a/products/mcp_analytics/backend/presentation/views.py+++ b/products/mcp_analytics/backend/presentation/views.py@@ -303,7 +303,7 @@ class MCPIntentClusterViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):# the write scope; the snapshot read stays on the read scope.scope_object_read_actions = ["list", "retrieve"]scope_object_write_actions = ["recompute"]- posthog_feature_flag = "mcp-analytics"+ posthog_feature_flag = contracts.MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAGpermission_classes = [PostHogFeatureFlagPermission]pagination_class = Nonediff --git a/products/mcp_analytics/backend/tests/__init__.py b/products/mcp_analytics/backend/tests/__init__.pyindex bdbea53c2a88..50132e8c13ec 100644--- a/products/mcp_analytics/backend/tests/__init__.py+++ b/products/mcp_analytics/backend/tests/__init__.py@@ -4,11 +4,13 @@ from unittest.mock import patchfrom posthog.models.scoping import team_scope+from products.mcp_analytics.backend.facade.contracts import MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAG+def _only_mcp_analytics_flag(flag_key: str, *args: object, **kwargs: object) -> bool:- # Enable just the mcp-analytics alpha flag; leave every other flag at its default (off)+ # Enable just the MCP analytics product and intent-routing flags; leave every other flag off# so tests don't silently mask unrelated flag-gated behavior.- return flag_key == "mcp-analytics"+ return flag_key in {"mcp-analytics", MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAG}class _MCPAnalyticsTeamScopedTestMixin:@@ -16,8 +18,8 @@ class _MCPAnalyticsTeamScopedTestMixin:- wraps the test in ``team_scope`` so direct queries against the fail-closedMCPSession / MCPIntentClusterSnapshot managers find a scope, and- - enables the ``mcp-analytics`` feature flag (and only that flag) for the test,- since the endpoints are gated behind it.+ - enables the MCP analytics product and intent-routing feature flags (and only those flags),+ since the endpoints are gated behind them.Place this BEFORE the TestCase base in the MRO so its setUp creates self.team first."""diff --git a/products/mcp_analytics/backend/tests/test_presentation.py b/products/mcp_analytics/backend/tests/test_presentation.pyindex 86defd6646f7..d7d150d93125 100644--- a/products/mcp_analytics/backend/tests/test_presentation.py+++ b/products/mcp_analytics/backend/tests/test_presentation.py@@ -19,6 +19,7 @@ from posthog.temporal.mcp_analytics.intent_clustering.constants import ()from products.mcp_analytics.backend import intent_generation+from products.mcp_analytics.backend.facade.contracts import MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAGfrom products.mcp_analytics.backend.models import MCPAnalyticsSubmission, MCPIntentClusterSnapshot, MCPSessionfrom products.mcp_analytics.backend.presentation.serializers import (MCP_SESSION_LIST_DEFAULT_LIMIT,@@ -209,6 +210,23 @@ class TestMCPAnalyticsPresentation(_MCPAnalyticsTeamScopedTestMixin, APIBaseTestassert data["last_computed_at"] is Noneassert data["computed_with"] is None+ @parameterized.expand(+ [+ ("snapshot", "get", "intent_clusters/"),+ ("recompute", "post", "intent_clusters/recompute/"),+ ]+ )+ def test_intent_clusters_require_intent_routing_feature_flag(self, _name: str, method: str, path: str) -> None:+ def only_product_flag_enabled(flag_key: str, *args: object, **kwargs: object) -> bool:+ assert flag_key in {"mcp-analytics", MCP_ANALYTICS_INTENT_ROUTING_FEATURE_FLAG}+ return flag_key == "mcp-analytics"++ with patch("posthoganalytics.feature_enabled", side_effect=only_product_flag_enabled):+ request = getattr(self.client, method)+ response = request(f"/api/environments/{self.team.id}/mcp_analytics/{path}", {}, format="json")++ assert response.status_code == status.HTTP_403_FORBIDDEN+def test_intent_clusters_returns_stored_snapshot(self) -> None:MCPIntentClusterSnapshot.objects.create(team=self.team,diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsxindex b496ca4cad42..f3d649709832 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx@@ -770,5 +770,6 @@ export const ToolQuality: Story = {export const IntentClustering: Story = {parameters: {pageUrl: urls.mcpAnalyticsIntentClustering(),+ featureFlags: [FEATURE_FLAGS.MCP_ANALYTICS, FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING],},}diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsxindex 1b785abdc807..0a236e4b3e7a 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx@@ -5,6 +5,8 @@ import { FilterBar } from 'lib/components/FilterBar'import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { teamLogic } from 'scenes/teamLogic'import { McpDateFilter } from './components/McpDateFilter'@@ -43,6 +45,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {} = useValues(mcpDashboardOverviewLogic)const { setDateFilter, setFilterTestAccounts, setPropertyFilters } = useActions(mcpDashboardOverviewLogic)const { timezone } = useValues(teamLogic)+ const { featureFlags } = useValues(featureFlagLogic)const theme = useChartTheme()@@ -90,6 +93,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {intentClusterCount={intentClusterCount}kpisLoading={kpisLoading}usersLoading={usersLoading}+ showIntentClusters={!!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]}theme={theme}incompleteTail={kpiIncompleteTail}/>diff --git a/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx b/products/mcp_analytics/frontend/MCPAnalyticsScene.tsxindex 8db723f21804..881ed6293bdb 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx@@ -4,6 +4,9 @@ import { router, combineUrl } from 'kea-router'import { IconSparkles } from '@posthog/icons'import { LemonButton, LemonTab, LemonTabs, LemonTag } from '@posthog/lemon-ui'+import { NotFound } from 'lib/components/NotFound'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { urls } from 'scenes/urls'import { FeaturePreviewSceneGate } from '~/layout/scenes/components/FeaturePreviewSceneGate'@@ -48,6 +51,12 @@ function MCPAnalyticsSceneContent(): JSX.Element {const { activeTab } = useValues(mcpAnalyticsSceneLogic)const { onboardingState } = useValues(mcpAnalyticsOnboardingLogic)const { notificationCount } = useValues(mcpAnalyticsNotificationsLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const intentRoutingEnabled = !!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]++ if (activeTab === 'intent-clustering' && !intentRoutingEnabled) {+ return <NotFound object="page" />+ }// landing is a one-shot redirect marker, while search is Sessions-only.// The date range stays shared across every tab.@@ -86,13 +95,17 @@ function MCPAnalyticsSceneContent(): JSX.Element {link: combineUrl(urls.mcpAnalyticsToolQuality(), sharedParams).url,'data-attr': 'mcp-analytics-tool-quality-tab',},- {- key: 'intent-clustering',- label: 'Intent clustering',- content: <MCPAnalyticsClustering />,- link: combineUrl(urls.mcpAnalyticsIntentClustering(), sharedParams).url,- 'data-attr': 'mcp-analytics-intent-clustering-tab',- },+ ...(intentRoutingEnabled+ ? [+ {+ key: 'intent-clustering' as const,+ label: 'Intent clustering',+ content: <MCPAnalyticsClustering />,+ link: combineUrl(urls.mcpAnalyticsIntentClustering(), sharedParams).url,+ 'data-attr': 'mcp-analytics-intent-clustering-tab',+ },+ ]+ : []),{key: 'notifications',label: (diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsxindex 6dbbc86bb1ee..e1a6489ed3ed 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx@@ -27,7 +27,9 @@ import {import { useChartConfig, useChartTheme } from 'lib/charts/hooks'import { TZLabel } from 'lib/components/TZLabel'+import { FEATURE_FLAGS } from 'lib/constants'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { copyToClipboard } from 'lib/utils/copyToClipboard'import { PersonDisplay } from 'scenes/persons/PersonDisplay'import { teamLogic } from 'scenes/teamLogic'@@ -507,6 +509,8 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.} = useValues(mcpAnalyticsToolDetailLogic({ toolName }))const { selectFailure } = useActions(mcpAnalyticsToolDetailLogic({ toolName }))const { timezone } = useValues(teamLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const intentRoutingEnabled = !!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]const theme = useChartTheme()const callsSeries = useMemo<Series[]>(@@ -622,12 +626,16 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.</div></div>- <LemonDivider />+ {intentRoutingEnabled && (+ <>+ <LemonDivider />- <div className="flex flex-col gap-3 px-4 pb-4">- <SectionHeader title="Intents served" subtitle="From the latest intent cluster snapshot" />- <ToolDetailIntentsSection toolName={toolName} />- </div>+ <div className="flex flex-col gap-3 px-4 pb-4">+ <SectionHeader title="Intents served" subtitle="From the latest intent cluster snapshot" />+ <ToolDetailIntentsSection toolName={toolName} />+ </div>+ </>+ )}<LemonDivider />diff --git a/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.test.ts b/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.test.tsindex 54b6647b2c7e..1e92b8c49512 100644--- a/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.test.ts+++ b/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.test.ts@@ -2,6 +2,8 @@ import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import api from 'lib/api'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { urls } from '~/scenes/urls'import { initKeaTests } from '~/test/init'@@ -146,6 +148,9 @@ describe('mcpClusteringLogic', () => {beforeEach(async () => {jest.clearAllMocks()initKeaTests()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING], {+ [FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]: true,+ })mockRetrieve.mockResolvedValue(SNAPSHOT)logic = mcpClusteringLogic()logic.mount()@@ -156,6 +161,25 @@ describe('mcpClusteringLogic', () => {logic.unmount()})+ it('loads the snapshot only after the intent routing flag resolves enabled', async () => {+ logic.unmount()+ initKeaTests()+ mockRetrieve.mockClear()+ featureFlagLogic.actions.setFeatureFlags([], {})+ logic = mcpClusteringLogic()+ logic.mount()++ await expectLogic(logic).toFinishAllListeners()+ expect(mockRetrieve).not.toHaveBeenCalled()++ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING], {+ [FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]: true,+ })+ await expectLogic(logic).toFinishAllListeners()++ expect(mockRetrieve).toHaveBeenCalledTimes(1)+ })+// The scorecards are the entry point into the list: each one states a count and// filters to that set. If the counter and the filter predicate drift apart, a card// reading "1 spread route" filters to a different number of rows.diff --git a/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.ts b/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.tsindex 68db7adea61e..62c8a76ccc37 100644--- a/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.ts+++ b/products/mcp_analytics/frontend/clustering/mcpClusteringLogic.ts@@ -5,11 +5,14 @@ import { actionToUrl, router, urlToAction } from 'kea-router'import { lemonToast } from '@posthog/lemon-ui'import api from 'lib/api'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { teamLogic } from 'scenes/teamLogic'import { MCPToolCategoryMapItem, NodeKind } from '~/queries/schema/schema-general'import { urls } from '~/scenes/urls'+import type { FeatureFlagsSet } from '../../../../frontend/src/lib/logic/featureFlagLogic'import { mcpAnalyticsIntentClustersRecompute, mcpAnalyticsIntentClustersRetrieve } from '../generated/api'import type {MCPIntentClusterApi,@@ -221,6 +224,7 @@ function median(values: number[]): number | null {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface mcpClusteringLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogiccurrentProjectId: number | string // teamLogicavailableCategories: string[]categoriesByTool: Record<string, string[]>@@ -236,6 +240,7 @@ export interface mcpClusteringLogicValues {fitMedian: number | nullhasSnapshot: booleanhasToolPivot: boolean+ intentRoutingEnabled: booleanisComputing: booleanrouteShapeCounts: RouteShapeCountsscatterPoints: ScatterPoint[]@@ -352,6 +357,7 @@ export interface mcpClusteringLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface mcpClusteringLogicMeta {__keaTypeGenInternalSelectorTypes: {+ intentRoutingEnabled: (featureFlags: FeatureFlagsSet) => booleanclusters: (snapshot: MCPIntentClusterSnapshotApi) => readonly MCPIntentClusterApi[]tools: (snapshot: MCPIntentClusterSnapshotApi) => readonly MCPToolPivotApi[]categoriesByTool: (categoryMap: MCPToolCategoryMapItem[]) => Record<string, string[]>@@ -404,7 +410,7 @@ export type mcpClusteringLogicType = MakeLogicType<export const mcpClusteringLogic = kea<mcpClusteringLogicType>([path(['products', 'mcp_analytics', 'frontend', 'clustering', 'mcpClusteringLogic']),connect(() => ({- values: [teamLogic, ['currentProjectId']],+ values: [featureFlagLogic, ['featureFlags'], teamLogic, ['currentProjectId']],})),actions({selectCluster: (clusterId: number | null) => ({ clusterId }),@@ -426,14 +432,14 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([EMPTY_SNAPSHOT as MCPIntentClusterSnapshotApi,{loadSnapshot: async () => {- if (!values.currentProjectId) {+ if (!values.currentProjectId || !values.intentRoutingEnabled) {return EMPTY_SNAPSHOT}const response = await mcpAnalyticsIntentClustersRetrieve(String(values.currentProjectId))return normalizeSnapshot(response)},triggerRecompute: async () => {- if (!values.currentProjectId) {+ if (!values.currentProjectId || !values.intentRoutingEnabled) {return EMPTY_SNAPSHOT}const response = await mcpAnalyticsIntentClustersRecompute(String(values.currentProjectId))@@ -448,6 +454,9 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([[] as MCPToolCategoryMapItem[],{loadCategoryMap: async (): Promise<MCPToolCategoryMapItem[]> => {+ if (!values.intentRoutingEnabled) {+ return []+ }const response = (await api.query({kind: NodeKind.MCPToolCategoryMapQuery,dateRange: { date_from: CATEGORY_LOOKBACK },@@ -528,6 +537,10 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([],}),selectors({+ intentRoutingEnabled: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING],+ ],clusters: [(s) => [s.snapshot],(snapshot: MCPIntentClusterSnapshotApi): readonly MCPIntentClusterApi[] => snapshot.clusters,@@ -781,6 +794,17 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([],}),listeners(({ actions, values, cache }) => ({+ [featureFlagLogic.actionTypes.setFeatureFlags]: () => {+ if (!values.intentRoutingEnabled) {+ cache.snapshotRequested = false+ actions.stopPolling()+ return+ }+ if (!cache.snapshotRequested) {+ cache.snapshotRequested = true+ actions.loadSnapshot()+ }+ },loadSnapshotSuccess: ({ snapshot }) => {if (snapshot.status === 'computing') {actions.startPolling()@@ -921,7 +945,11 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([}),urlToAction(({ actions, values }) => ({[urls.mcpAnalyticsIntentClustering()]: (_, searchParams) => {- if (!values.categoryMapRequested && values.categoryMapAttempts < MAX_CATEGORY_MAP_ATTEMPTS) {+ if (+ values.intentRoutingEnabled &&+ !values.categoryMapRequested &&+ values.categoryMapAttempts < MAX_CATEGORY_MAP_ATTEMPTS+ ) {actions.loadCategoryMap()}const viewMode: ClusteringViewMode = searchParams.view === 'tools' ? 'tools' : 'intents'@@ -950,7 +978,10 @@ export const mcpClusteringLogic = kea<mcpClusteringLogicType>([}},})),- afterMount(({ actions }) => {- actions.loadSnapshot()+ afterMount(({ actions, values, cache }) => {+ if (values.intentRoutingEnabled) {+ cache.snapshotRequested = true+ actions.loadSnapshot()+ }}),])diff --git a/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx b/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsxindex e90247b397b3..8cd26af7d587 100644--- a/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx+++ b/products/mcp_analytics/frontend/dashboard/DashboardCards.stories.tsx@@ -154,6 +154,7 @@ export const KeyMetrics: Story = {intentClusterCount={metric(6, 0, [], 'up')}kpisLoading={false}usersLoading={false}+ showIntentClusterstheme={buildTheme()}incompleteTail={false}/>@@ -170,6 +171,7 @@ export const KeyMetricsInProgressBucket: Story = {intentClusterCount={metric(6, 0, [], 'up')}kpisLoading={false}usersLoading={false}+ showIntentClusterstheme={buildTheme()}incompleteTail/>diff --git a/products/mcp_analytics/frontend/dashboard/KpiTiles.tsx b/products/mcp_analytics/frontend/dashboard/KpiTiles.tsxindex 68ab287abd31..1d512b95546d 100644--- a/products/mcp_analytics/frontend/dashboard/KpiTiles.tsx+++ b/products/mcp_analytics/frontend/dashboard/KpiTiles.tsx@@ -68,6 +68,7 @@ export function KpiTiles({intentClusterCount,kpisLoading,usersLoading,+ showIntentClusters,theme,incompleteTail,}: {@@ -76,6 +77,7 @@ export function KpiTiles({intentClusterCount: KPIMetrickpisLoading: booleanusersLoading: boolean+ showIntentClusters: booleantheme: ChartTheme// When true, the sparklines' final point is the current in-progress interval — dash it so a// partial period doesn't read as a decline. Required rather than optional: an omitted prop@@ -129,27 +131,34 @@ export function KpiTiles({loading: kpisLoading,summaryLabel: 'Latest',},- {- label: 'Intent clusters',- metric: intentClusterCount,- href: urls.mcpAnalyticsIntentClustering(),- format: formatNumber,- color: theme.colors[6],- loading: false,- summaryLabel: 'Total',- // Clusters come from the latest clustering snapshot across all sessions, so- // unlike the other tiles this count isn't scoped by the date or test-account- // filters. Label it so the grid doesn't read as a single consistent scope.- subtitle: 'Latest run · all sessions',- },+ ...(showIntentClusters+ ? [+ {+ label: 'Intent clusters',+ metric: intentClusterCount,+ href: urls.mcpAnalyticsIntentClustering(),+ format: formatNumber,+ color: theme.colors[6],+ loading: false,+ summaryLabel: 'Total',+ // Clusters come from the latest clustering snapshot across all sessions, so+ // unlike the other tiles this count isn't scoped by the date or test-account+ // filters. Label it so the grid doesn't read as a single consistent scope.+ subtitle: 'Latest run · all sessions',+ },+ ]+ : []),]- // Wrap the six tiles only into rows that divide evenly (6 → 3+3 → 2+2+2), never a lone- // trailing card. Container queries key off the card area's own width, so the sidebar can't- // push it to an awkward 5+1 the way viewport breakpoints or plain auto-fit would.+ // Keep both flag states balanced: six tiles wrap as 3+3 or 2+2+2, while five stay on one+ // wide row. Container queries key off the card area's width rather than the viewport.return (<div className="@container">- <div className="grid grid-cols-2 gap-3 @xl:grid-cols-3 @6xl:grid-cols-6">+ <div+ className={`grid gap-3 ${+ showIntentClusters ? 'grid-cols-2 @xl:grid-cols-3 @6xl:grid-cols-6' : 'grid-cols-1 @xl:grid-cols-5'+ }`}+ >{tiles.map((tile) => (<KPITile key={tile.label} tile={tile} theme={theme} incompleteTail={incompleteTail} />))}diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.mdindex 2459acb73db4..a8e9739d574d 100644--- a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md@@ -218,8 +218,9 @@ carries the property reference and worked query examples._Breaks:_ no `$mcp_intent` captured at all (the agent never filled the injected `context`argument and no `intentFallback` was configured), so there is nothing to summarize; LLMkey or quota problems.-6. **Intent clustering** -> embed (cached in `MCPIntentEmbeddingCache`) -> agglomerative- clustering (cosine, average linkage, `DEFAULT_DISTANCE_THRESHOLD`) -> JSONB+6. **Intent clustering** (behind `mcp-analytics-intent-routing`) -> embed (cached in+ `MCPIntentEmbeddingCache`) -> agglomerative clustering (cosine, average linkage,+ `DEFAULT_DISTANCE_THRESHOLD`) -> JSONB`MCPIntentClusterSnapshot`. **Temporal end-to-end, no Celery.** On-demand recompute(`trigger_intent_cluster_recompute`, serialized with `select_for_update()` and adeterministic per-team workflow id) and the `cluster_mcp_intents` management command both@@ -242,12 +243,16 @@ carries the property reference and worked query examples.(router in `backend/presentation/urls.py`) plus custom actions(`sessions/{id}/tool_calls`, `sessions/{id}/generate_intent`, `sessions/intent_digest`,`sessions/activity_overview`, `intent_clusters/recompute`). Parallel surface: step 4's- runners, exposed to agents as the `query-mcp-*` tools.+ runners, exposed to agents as the `query-mcp-*` tools. The intent-cluster read and+ recompute endpoints require `mcp-analytics-intent-routing`; the other endpoints use+ `mcp-analytics`.8. **Frontend** -> Kea scene `MCPAnalyticsScene.tsx`, with tabs enumerated by`MCPAnalyticsTab` in `mcpAnalyticsSceneLogic.ts`: activity, dashboard, sessions,tool quality, intent clustering, notifications. The landing tab is volume-gated by`dashboardStage` in `mcpAnalyticsOnboardingLogic.ts` and applies only to the bare`/mcp-analytics` redirect — deep links and explicit tab clicks are never overridden.+ The intent clustering tab, dashboard KPI, and tool-detail cluster section are all gated by+ `mcp-analytics-intent-routing`; a direct unflagged link renders the standard not-found page.- **Activity** (`earlyData/`): live tool-call feed plus the intent-**themes** card."Theme" (the LLM digest, Activity tab) is **not** "cluster" (the embedding clustering,its own tab). Conflating the two is the most common mistake here.