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-analytics): share the tool-call feed and add recent calls to the dashboard (#103105)

Lucas Faria7833aaa4dc59
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 18804f12384e..3852bf5d15e5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -9389,25 +9389,25 @@ snapshots:
scenes-app-max-ai-replay-vision-scan-widget--with-skipped--light:
hash: v1.k794b7964.c543228b0f31abb2aae3b274819abdee4ba6a89fb3324fc6aaa2b18aefee5815.S9etTEY8oT2JhOgLO5hdc6VqvbvYhD-nU4P1WKh24yg
scenes-app-mcp-analytics--activity--dark:
- hash: v1.k794b7964.bd9ad40b13237376df1be9d2bcc4e0626a5b3d13ee4315436c094e42951c4df6.DOejp3v9E9JQquINe1YNs7AGMb25qUL1yvGNErz_xfA
+ hash: v1.k794b7964.00f97861fa156d012a6cadda9803ead69a56979837d992f287de841ad8b0d303.auxpVnXeHCG3i8WWD3Lf-xwFtaMlkYsYRZhf2iIHpXw
scenes-app-mcp-analytics--activity--light:
- hash: v1.k794b7964.76a5d56a4628f578be89c1199b8e4e0b6dd4ca97d0ba64b15bfae8b0c01e3275.GzIBk3Ben0mNfwQ2LSV_y0B8BcltRVbqXs--o11sEVY
+ hash: v1.k794b7964.07eb69e8d1b5cf2b74a60f5c8b7e6eebf4db9430368ec576b96a5fa3a88449a8.yn7ORnsE9a5c2FZGJbzFylVqx-Y82LVj7TH7Lhh4KOY
scenes-app-mcp-analytics--dashboard--medium--dark:
- hash: v1.k794b7964.0cf0143fd54e5488bdbe265c0f018fc0ef72eca2c3caa2f33be108d85d5c3454.zBedzvqGymzmPxC2lA4udKZJk-R46MP0JnyxXeQ7488
+ hash: v1.k794b7964.d720f243a9d94d614c00a31063df879f070eac53b3fce76c9d42931304941769.nsNkPSEGWTyU5u1XdmhHnveET4Lvu2hC4egcz9pV12M
scenes-app-mcp-analytics--dashboard--medium--light:
- hash: v1.k794b7964.2602ad305dffd5feb78571306509f2da8a344f11216241089a8aea5a5d47f737.5EI9Ho9QGiZ3zRC1EKL6VoJHQKot9L6-9wa7llLt9Qs
+ hash: v1.k794b7964.c5dde84ed01a52e28ff57f057b2d0993b16a7065379f56cb488cb3ebce808cd1.ks9koqUwkuRomk18V2XOYYr7lzCtOpd_okVyNWEC4uk
scenes-app-mcp-analytics--dashboard--wide--dark:
- hash: v1.k794b7964.4026a734c3a503398f737ae2b004bc268dfcf9ca899a1f18b7567d391d8034ef.4s9dXACnKksRn1H0sWJJuTzEzsNs089095Hdg-Uri44
+ hash: v1.k794b7964.d3b1c5113067612f9728a8c5c70be035835fb88bb59f41504d540a3082e10cf3.YMt083wjL8ONNKACcE2MfklxNqoCaswcpPIlqfu7dWA
scenes-app-mcp-analytics--dashboard--wide--light:
- hash: v1.k794b7964.ec75bb99de5711f35d930df547c97fbc1fc015281e16e6b86d419456a49f1d83.x6nDZwmvWOmBz0Z4EPrwsX0Duu9vGaRQE_6212bRF6Q
+ hash: v1.k794b7964.a14a0ccf927f4e04bbc5c583f1d196f0d6393575c5d598a7be93c9653cf0ac26.KpVtmJD_IqnqceAJH0BPqnPwOV7G5xeZ8LLA6fgcaSg
scenes-app-mcp-analytics--dashboard-narrow--dark:
- hash: v1.k794b7964.1eca69c67f716834ba5ba66b95fe32ee279b87d793660f7f7fa1666e0e54d721.b1SxCPOhEOb8L_aN8jV3hlWJMBe1TAdIFJ3WENqMF-o
+ hash: v1.k794b7964.5ef51629653e5bdf8c6d171ed5995cb83e8c1769d6805fbf4bc44a0bbbd21561.VTO1aGPaafx0iDWOzORTXl_RU9_IY06QCDfRFI290VQ
scenes-app-mcp-analytics--dashboard-narrow--light:
- hash: v1.k794b7964.bd79e3b02ea7dc859f14956fbc8563193703653988ae5601a31677058e950afa.8RuB40GSzDwKwGez-Ky2j0uoeSpilDe8YQTso7GwBOA
+ hash: v1.k794b7964.1b0f034d65b83b016c1b956f6fd26ceeea9b3eec2b911fd914abdba311d3bcdf.u4FmLXfh5WKo8bYdFk1OcMlYEt7RDMn3Gs2hjTOiCPw
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
- hash: v1.k794b7964.c7e1d2d45b22d888f76f434c4a72e0f07da8499ec0637ed1714d7aaf7a8f6013.iwrGnkw0EnPW22OT3hpBxg9npMBcnSWHt_Ya7c0g4yg
+ hash: v1.k794b7964.8a64effc30dcb139ee46eb38eab71c5f7ee39b5fdd8df865f9ebd82b15e9e752.lF2iXnflVWCXsmZXOukWLUQTKgKM5Ijb9OGMO1jUwUc
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
- hash: v1.k794b7964.01e9ef267e631b01571c3e620972e6c48a1a425c780e147ec9fdbb524b6768e9.5pZ6OrgBpdN6XditgJxcxGYdnr7HTJ7x-ZJ0LQXF4pw
+ hash: v1.k794b7964.5950f14c1cba87ea5610ce1ae7f67791bf2320688e3bd04ffbd1154e465a163f.dyk-zwl99Fj0Dg39JnvwPOnx-zbxUeoxq1nT9FHqGfM
scenes-app-mcp-analytics--intent-clustering--dark:
hash: v1.k794b7964.9549b853f80d754b9d6ccf17ab144d24218143200c90df7af687e184e7de5329.Er1_HM8avmrqmulj2hCLnkp98-HeuRvF5ed3j-_jS2A
scenes-app-mcp-analytics--intent-clustering--light:
@@ -9449,9 +9449,9 @@ snapshots:
scenes-app-mcp-analytics-dashboard-cards--key-metrics-in-progress-bucket--light:
hash: v1.k794b7964.987a4b9f762bab3f88f39ea33fb0eca000d0e5f6aeb2c0a89e2979399f4d5797.ziZ_6D2TpdPk2pVJqrCMfEcmRufZDVVVqN51I5vIHgM
scenes-app-mcp-analytics-dashboard-cards--overview-unknown-models--dark:
- hash: v1.k794b7964.3e8288cb5f6b30da0b2f5bd08bccf9ba259575198c08de2207559cdd126b1b73.ytmEscJE4vL_gGkPU36_H9MK8hMVLnU3NdR1e049Xnc
+ hash: v1.k794b7964.4c40cc6779bd26466fc6daf6f82971827f145612adae1a28bf238e341d262962.ob9TvsNiXCUfk7O4CymtRroNcRzXSGsbPULAieP2JzQ
scenes-app-mcp-analytics-dashboard-cards--overview-unknown-models--light:
- hash: v1.k794b7964.63d410d2348788e7560a07d8e3c9d0611f59263686f0e97f76a82e1516b36e9d.ISLU0iW7Lq4rttXqp-EfkdjrJAdlSaEfs61-ta1Cy0M
+ hash: v1.k794b7964.5e4192071ebd122aa925a7186a25b50b94d23fc1a5d45b91e1b200d7341626b8.-A4DoyQrFq5Hfj1H7i4FhJfBfPQXEQokksPNGBmFL_A
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--dark:
hash: v1.k794b7964.fde18be0efabaa2cf352bb9fb0a666d8093559da70e0aae8c810eacc1e729eb4.ZVHWg1s6g2RxLBy2o-N7DQE84oHBJ6a0krFomsu7Vlw
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--light:
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index d7ee6e8b9321..956e2a4f9d2a 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -16,6 +16,7 @@ import { HarnessBarChart } from './dashboard/HarnessBarChart'
import { KpiTiles } from './dashboard/KpiTiles'
import { ModelBarChart } from './dashboard/ModelBarChart'
import { NotableSessionsTable } from './dashboard/NotableSessionsTable'
+import { RecentToolCallsCard } from './dashboard/RecentToolCallsCard'
import { ToolErrorRateChart } from './dashboard/ToolErrorRateChart'
import { ToolUsageChart } from './dashboard/ToolUsageChart'
import { MCP_ANALYTICS_DASHBOARD_FEEDBACK_PROMPT } from './feedback/constants'
@@ -161,6 +162,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
<NotableSessionsTable sessions={notableSessions} loading={sessionRowsLoading} />
</div>
</section>
+ <RecentToolCallsCard filters={queryFilters} />
</div>
)
}
diff --git a/products/mcp_analytics/frontend/components/ToolCallFeed.tsx b/products/mcp_analytics/frontend/components/ToolCallFeed.tsx
new file mode 100644
index 000000000000..638072af95a9
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/ToolCallFeed.tsx
@@ -0,0 +1,89 @@
+import { LemonTag, Link } from '@posthog/lemon-ui'
+
+import { QueryFeature } from '~/queries/nodes/DataTable/queryFeatures'
+import { Query } from '~/queries/Query/Query'
+import { DataTableNode } from '~/queries/schema/schema-general'
+
+import { mcpSessionUrl } from '../tool-quality/errorContext'
+import {
+ MCP_ACTIVITY_ERROR_COLUMN,
+ MCP_ACTIVITY_INTENT_COLUMN,
+ MCP_ACTIVITY_MAX_ROWS,
+ MCP_ACTIVITY_SESSION_COLUMN,
+} from './toolCallFeedQuery'
+
+function IntentCell({ value }: { value: unknown }): JSX.Element {
+ return <span className="block min-w-64 whitespace-normal">{value ? String(value) : '—'}</span>
+}
+
+// SDK versions stamp $mcp_is_error as a boolean, the string 'true', or 1; the backend treats all three as failures.
+export const MCP_ERROR_VALUES: ReadonlyArray<unknown> = [true, 'true', 1, '1']
+
+function ErrorCell({ value }: { value: unknown }): JSX.Element {
+ const failed = MCP_ERROR_VALUES.includes(value)
+ return failed ? (
+ <LemonTag type="danger" size="small">
+ Failed
+ </LemonTag>
+ ) : (
+ <span className="text-muted">OK</span>
+ )
+}
+
+function SessionCell({ value }: { value: unknown }): JSX.Element {
+ if (!value) {
+ return <span className="text-muted">—</span>
+ }
+ return (
+ <Link to={mcpSessionUrl(String(value))} data-attr="mcp-analytics-activity-session-link">
+ View session
+ </Link>
+ )
+}
+
+/** The MCP tool-call events table with its cell renderers, shared by the activity feed and the dashboard glance. */
+export function ToolCallFeed({
+ query,
+ setQuery,
+ uniqueKey,
+ dataNodeCollectionId,
+ attachTo,
+ maxRows = MCP_ACTIVITY_MAX_ROWS,
+}: {
+ query: DataTableNode
+ setQuery?: (query: DataTableNode) => void
+ uniqueKey: string
+ dataNodeCollectionId?: string
+ attachTo?: Parameters<typeof Query>[0]['attachTo']
+ /** Rows the table may page up to; at the query's own limit, "load more" never shows. */
+ maxRows?: number
+}): JSX.Element {
+ return (
+ <Query
+ attachTo={attachTo}
+ uniqueKey={uniqueKey}
+ query={query}
+ setQuery={setQuery}
+ context={{
+ dataTableMaxPaginationRows: maxRows,
+ dataTableAllowContentScroll: true,
+ dataTableNouns: ['tool call', 'tool calls'],
+ compactDataTableToolbar: true,
+ hideRecordingButton: true,
+ columns: {
+ [MCP_ACTIVITY_INTENT_COLUMN]: { render: IntentCell, width: '20rem' },
+ [MCP_ACTIVITY_ERROR_COLUMN]: { render: ErrorCell, title: 'Result' },
+ [MCP_ACTIVITY_SESSION_COLUMN]: { render: SessionCell },
+ },
+ emptyStateDetail: 'Adjust the date range or filters, or wait for agents to call a tool.',
+ emptyStateHeading: 'No MCP tool calls in this period',
+ extraDataTableQueryFeatures: [QueryFeature.showCount],
+ insightProps: {
+ dashboardItemId: `new-${uniqueKey}`,
+ dataNodeCollectionId,
+ },
+ showOpenEditorButton: false,
+ }}
+ />
+ )
+}
diff --git a/products/mcp_analytics/frontend/components/toolCallFeedQuery.test.ts b/products/mcp_analytics/frontend/components/toolCallFeedQuery.test.ts
new file mode 100644
index 000000000000..ea72064a0a3b
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/toolCallFeedQuery.test.ts
@@ -0,0 +1,61 @@
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+
+import {
+ DEFAULT_MCP_ACTIVITY_QUERY,
+ MCP_ACTIVITY_COLUMNS,
+ MCP_ACTIVITY_MAX_ROWS,
+ MCP_ACTIVITY_PAGE_SIZE,
+ MCP_RECENT_TOOL_CALLS_LIMIT,
+ buildRecentToolCallsQuery,
+} from './toolCallFeedQuery'
+
+describe('tool call feed queries', () => {
+ it('starts the expandable MCP activity feed at 100 rows with room to load more', () => {
+ expect(DEFAULT_MCP_ACTIVITY_QUERY).toMatchObject({
+ embedded: false,
+ expandable: true,
+ showCount: true,
+ showDateRange: true,
+ showPropertyFilter: expect.any(Array),
+ source: {
+ events: ['$mcp_tool_call'],
+ limit: 100,
+ orderBy: ['timestamp DESC'],
+ },
+ })
+ expect(MCP_ACTIVITY_PAGE_SIZE).toBe(100)
+ expect(MCP_ACTIVITY_MAX_ROWS).toBeGreaterThan(MCP_ACTIVITY_PAGE_SIZE)
+ expect(MCP_ACTIVITY_COLUMNS).toContain('*')
+ expect(MCP_ACTIVITY_COLUMNS.find((column) => column.endsWith('-- Tool'))).toContain('$mcp_exec_tool_call_name')
+ })
+
+ it('scopes the dashboard glance to the dashboard filters and drops the toolbar', () => {
+ const toolFilter: AnyPropertyFilter = {
+ key: '$mcp_tool_name',
+ value: ['search'],
+ operator: PropertyOperator.Exact,
+ type: PropertyFilterType.Event,
+ }
+
+ const query = buildRecentToolCallsQuery({
+ dateRange: { date_from: '-7d', date_to: '-1d' },
+ properties: [toolFilter],
+ filterTestAccounts: true,
+ })
+
+ expect(query).toMatchObject({
+ embedded: false,
+ showDateRange: false,
+ showPropertyFilter: false,
+ showReload: false,
+ source: {
+ select: MCP_ACTIVITY_COLUMNS,
+ after: '-7d',
+ before: '-1d',
+ properties: [toolFilter],
+ filterTestAccounts: true,
+ limit: MCP_RECENT_TOOL_CALLS_LIMIT,
+ },
+ })
+ })
+})
diff --git a/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts b/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts
new file mode 100644
index 000000000000..9bd2293ec890
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts
@@ -0,0 +1,69 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { MCP_TOOL_CALL_EVENT } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+
+import { DataTableNode, HogQLFilters, NodeKind } from '~/queries/schema/schema-general'
+
+export const MCP_ACTIVITY_DATA_COLLECTION_ID = 'mcp-analytics-activity'
+export const MCP_ACTIVITY_PAGE_SIZE = 100
+export const MCP_ACTIVITY_MAX_ROWS = 1000
+export const MCP_ACTIVITY_INTENT_COLUMN = 'properties.$mcp_intent -- Agent intent'
+export const MCP_ACTIVITY_ERROR_COLUMN = 'properties.$mcp_is_error -- Error'
+export const MCP_ACTIVITY_SESSION_COLUMN = 'properties.$session_id -- Session'
+
+export const MCP_ACTIVITY_COLUMNS = [
+ '*',
+ "coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) -- Tool",
+ MCP_ACTIVITY_INTENT_COLUMN,
+ MCP_ACTIVITY_ERROR_COLUMN,
+ 'properties.$mcp_duration_ms -- Duration (ms)',
+ 'properties.$mcp_client_name -- Client',
+ MCP_ACTIVITY_SESSION_COLUMN,
+ 'timestamp',
+]
+
+export const DEFAULT_MCP_ACTIVITY_QUERY: DataTableNode = {
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.EventsQuery,
+ select: MCP_ACTIVITY_COLUMNS,
+ events: [MCP_TOOL_CALL_EVENT],
+ after: '-30d',
+ orderBy: ['timestamp DESC'],
+ limit: MCP_ACTIVITY_PAGE_SIZE,
+ },
+ embedded: false,
+ expandable: true,
+ showActions: true,
+ showCount: true,
+ showDateRange: true,
+ showPropertyFilter: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ showReload: true,
+}
+
+/** How many rows the dashboard's recent-calls card shows: a glance, not a feed. */
+export const MCP_RECENT_TOOL_CALLS_LIMIT = 20
+
+/** The same columns as the activity feed, scoped to the dashboard's filters and stripped of the toolbar. */
+export function buildRecentToolCallsQuery(filters: HogQLFilters): DataTableNode {
+ return {
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.EventsQuery,
+ select: MCP_ACTIVITY_COLUMNS,
+ events: [MCP_TOOL_CALL_EVENT],
+ after: filters.dateRange?.date_from ?? undefined,
+ before: filters.dateRange?.date_to ?? undefined,
+ properties: filters.properties,
+ filterTestAccounts: filters.filterTestAccounts,
+ orderBy: ['timestamp DESC'],
+ limit: MCP_RECENT_TOOL_CALLS_LIMIT,
+ },
+ embedded: false,
+ expandable: true,
+ showActions: false,
+ showCount: false,
+ showDateRange: false,
+ showPropertyFilter: false,
+ showReload: false,
+ }
+}
diff --git a/products/mcp_analytics/frontend/dashboard/RecentToolCallsCard.tsx b/products/mcp_analytics/frontend/dashboard/RecentToolCallsCard.tsx
new file mode 100644
index 000000000000..bcc96ae2f6a3
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/RecentToolCallsCard.tsx
@@ -0,0 +1,39 @@
+import { useMemo } from 'react'
+
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { urls } from 'scenes/urls'
+
+import { HogQLFilters } from '~/queries/schema/schema-general'
+
+import { ToolCallFeed } from '../components/ToolCallFeed'
+import { MCP_RECENT_TOOL_CALLS_LIMIT, buildRecentToolCallsQuery } from '../components/toolCallFeedQuery'
+
+// A glance at the newest calls under the dashboard's filters. Aggregates say how the server is
+// doing; this says what it did a minute ago, and links to the full feed for more. The Activity
+// feed keeps its own filters, so the link carries none of the dashboard's.
+// Rendered outside the dashboard's quill sections on purpose: the events table is a LemonUI
+// component, and quill's color variables recolor its rows and expanded events.
+export function RecentToolCallsCard({ filters }: { filters: HogQLFilters }): JSX.Element {
+ const query = useMemo(() => buildRecentToolCallsQuery(filters), [filters])
+
+ return (
+ <section className="flex min-w-0 flex-col gap-2" data-attr="mcp-dashboard-recent-tool-calls">
+ <div className="flex items-center justify-between gap-2">
+ <h2 className="mb-0 text-xl font-semibold text-primary">Recent activity</h2>
+ <LemonButton
+ type="secondary"
+ size="small"
+ to={urls.mcpAnalyticsActivity()}
+ data-attr="mcp-dashboard-recent-tool-calls-see-all"
+ >
+ View all tool calls
+ </LemonButton>
+ </div>
+ <ToolCallFeed
+ query={query}
+ uniqueKey="mcp-dashboard-recent-tool-calls"
+ maxRows={MCP_RECENT_TOOL_CALLS_LIMIT}
+ />
+ </section>
+ )
+}
diff --git a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
index ddb2d67f94f9..6771659a7080 100644
--- a/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
+++ b/products/mcp_analytics/frontend/earlyData/MCPAnalyticsEarlyData.tsx
@@ -9,15 +9,13 @@ import { dataColorVars } from 'lib/colors'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { urls } from 'scenes/urls'
-import { QueryFeature } from '~/queries/nodes/DataTable/queryFeatures'
-import { Query } from '~/queries/Query/Query'
-
+import { ToolCallFeed } from '../components/ToolCallFeed'
+import { MCP_ACTIVITY_DATA_COLLECTION_ID } from '../components/toolCallFeedQuery'
import { Card } from '../dashboard/Card'
import { formatNumber } from '../dashboard/formatters'
import { HarnessLogo } from '../dashboard/harness'
import type { MCPIntentThemeApi } from '../generated/api.schemas'
import { METRICS_UNLOCK_LIFETIME_CALLS, mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'
-import { MCP_ACTIVITY_DATA_COLLECTION_ID, MCP_ACTIVITY_INTENT_COLUMN, MCP_ACTIVITY_MAX_ROWS } from './mcpActivityQuery'
import type { ChecklistItem } from './mcpEarlyDataLogic'
import { mcpEarlyDataLogic } from './mcpEarlyDataLogic'
@@ -98,39 +96,18 @@ function LiveActivityCard(): JSX.Element {
{/* Fills the card so the feed ends where the sidebar does; the rest scrolls. Stacked
layouts have no sidebar to match, so they fall back to a fixed cap. */}
<div className="flex flex-1 min-h-0 max-h-[36rem] overflow-hidden lg:max-h-none">
- <Query
- attachTo={mcpEarlyDataLogic}
- uniqueKey="mcp-analytics-activity"
+ <ToolCallFeed
query={activityQuery}
setQuery={setActivityQuery}
- context={{
- dataTableMaxPaginationRows: MCP_ACTIVITY_MAX_ROWS,
- dataTableAllowContentScroll: true,
- dataTableNouns: ['tool call', 'tool calls'],
- compactDataTableToolbar: true,
- hideRecordingButton: true,
- columns: {
- [MCP_ACTIVITY_INTENT_COLUMN]: { render: MCPActivityIntentCell, width: '20rem' },
- },
- emptyStateDetail: 'Adjust the date range or filters, or wait for agents to call a tool.',
- emptyStateHeading: 'No MCP tool calls in this period',
- extraDataTableQueryFeatures: [QueryFeature.showCount],
- insightProps: {
- dashboardItemId: 'new-mcp-analytics-activity',
- dataNodeCollectionId: MCP_ACTIVITY_DATA_COLLECTION_ID,
- },
- showOpenEditorButton: false,
- }}
+ uniqueKey="mcp-analytics-activity"
+ dataNodeCollectionId={MCP_ACTIVITY_DATA_COLLECTION_ID}
+ attachTo={mcpEarlyDataLogic}
/>
</div>
</section>
)
}
-function MCPActivityIntentCell({ value }: { value: unknown }): JSX.Element {
- return <span className="block min-w-64 whitespace-normal">{value ? String(value) : '—'}</span>
-}
-
// `total` is every intent analysed, so the bar reads as this theme's share of them. The backend
// assigns each intent to at most one theme, which is what keeps the shares adding up.
//
diff --git a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
index 8a385cd6870f..c33cb4111194 100644
--- a/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
+++ b/products/mcp_analytics/frontend/earlyData/earlyData.test.ts
@@ -1,11 +1,5 @@
import { buildActivitySummary } from './activitySummary'
import { buildChecklist, EarlyStats } from './earlyDataChecklist'
-import {
- DEFAULT_MCP_ACTIVITY_QUERY,
- MCP_ACTIVITY_COLUMNS,
- MCP_ACTIVITY_MAX_ROWS,
- MCP_ACTIVITY_PAGE_SIZE,
-} from './mcpActivityQuery'
const stats = (overrides: Partial<EarlyStats>): EarlyStats => ({
totalCalls: 0,
@@ -19,25 +13,6 @@ const stats = (overrides: Partial<EarlyStats>): EarlyStats => ({
})
describe('early data derivations', () => {
- it('starts the expandable MCP activity feed at 100 rows with room to load more', () => {
- expect(DEFAULT_MCP_ACTIVITY_QUERY).toMatchObject({
- embedded: false,
- expandable: true,
- showCount: true,
- showDateRange: true,
- showPropertyFilter: expect.any(Array),
- source: {
- events: ['$mcp_tool_call'],
- limit: 100,
- orderBy: ['timestamp DESC'],
- },
- })
- expect(MCP_ACTIVITY_PAGE_SIZE).toBe(100)
- expect(MCP_ACTIVITY_MAX_ROWS).toBeGreaterThan(MCP_ACTIVITY_PAGE_SIZE)
- expect(MCP_ACTIVITY_COLUMNS).toContain('*')
- expect(MCP_ACTIVITY_COLUMNS.find((column) => column.endsWith('-- Tool'))).toContain('$mcp_exec_tool_call_name')
- })
-
it.each([
// First calls get the celebratory copy, not a stats sentence.
[
diff --git a/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts b/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts
deleted file mode 100644
index 4752e0a270d7..000000000000
--- a/products/mcp_analytics/frontend/earlyData/mcpActivityQuery.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
-import { MCP_TOOL_CALL_EVENT } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
-
-import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
-
-export const MCP_ACTIVITY_DATA_COLLECTION_ID = 'mcp-analytics-activity'
-export const MCP_ACTIVITY_PAGE_SIZE = 100
-export const MCP_ACTIVITY_MAX_ROWS = 1000
-export const MCP_ACTIVITY_INTENT_COLUMN = 'properties.$mcp_intent -- Agent intent'
-
-export const MCP_ACTIVITY_COLUMNS = [
- '*',
- "coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) -- Tool",
- MCP_ACTIVITY_INTENT_COLUMN,
- 'properties.$mcp_is_error -- Error',
- 'properties.$mcp_duration_ms -- Duration (ms)',
- 'properties.$mcp_client_name -- Client',
- 'timestamp',
-]
-
-export const DEFAULT_MCP_ACTIVITY_QUERY: DataTableNode = {
- kind: NodeKind.DataTableNode,
- source: {
- kind: NodeKind.EventsQuery,
- select: MCP_ACTIVITY_COLUMNS,
- events: [MCP_TOOL_CALL_EVENT],
- after: '-30d',
- orderBy: ['timestamp DESC'],
- limit: MCP_ACTIVITY_PAGE_SIZE,
- },
- embedded: false,
- expandable: true,
- showActions: true,
- showCount: true,
- showDateRange: true,
- showPropertyFilter: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
- showReload: true,
-}
diff --git a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
index 40d23e94733b..b06797311ab7 100644
--- a/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
+++ b/products/mcp_analytics/frontend/earlyData/mcpEarlyDataLogic.ts
@@ -17,13 +17,13 @@ import { teamLogic } from 'scenes/teamLogic'
import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'
import { DataTableNode } from '~/queries/schema/schema-general'
+import { DEFAULT_MCP_ACTIVITY_QUERY, MCP_ACTIVITY_DATA_COLLECTION_ID } from '../components/toolCallFeedQuery'
import { mcpAnalyticsSessionsActivityOverview, mcpAnalyticsSessionsIntentDigest } from '../generated/api'
import type { MCPActivityOverviewApi, MCPIntentThemeApi } from '../generated/api.schemas'
import { mcpAnalyticsOnboardingLogic } from '../mcpAnalyticsOnboardingLogic'
import type { MCPOnboardingSignals } from '../mcpAnalyticsOnboardingLogic'
import { buildActivitySummary } from './activitySummary'
import { ChecklistItem, EarlyStats, buildChecklist } from './earlyDataChecklist'
-import { DEFAULT_MCP_ACTIVITY_QUERY, MCP_ACTIVITY_DATA_COLLECTION_ID } from './mcpActivityQuery'
export type { ChecklistItem, EarlyStats } from './earlyDataChecklist'