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): separate mcp properties in the taxonomic filter (#69575)

Paul D'Ambra19d248a3a72b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f6366d3b4d52..0f32b4fd1307 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2389,9 +2389,9 @@ snapshots:
filters-taxonomic-filter--autocapture-context-promotes-elements--light:
hash: v1.k794b7964.c722c0459b4a089a0dc855c7eb7b688e664a664bbf29daaed388dcf52d6276f5.ElSHvviHqjy6Q6a_YSrS_kzfubNi_We12Jc6axljfmE
filters-taxonomic-filter--empty-events-with-stale-toggle--dark:
- hash: v1.k794b7964.d08f0442c528a45b0dd17aad225290450b8e2b49397989522a58227812581864.oeNJAL-xExYaq43ciKuZi2vLX6QmP2ORP3MPuTZ3EM8
+ hash: v1.k794b7964.d413ed3c275cff90db4ad99a203b0e4b30a59778ab7b56fb52f183069146615a.JtkbjIECyHMD3TFGt3XKQ5tWXnvj3YvtJZOmzq9aSCE
filters-taxonomic-filter--empty-events-with-stale-toggle--light:
- hash: v1.k794b7964.850802fb4ef87a299ed50f75ba5ade9799c935569f906b3b80e60c68b97c0d7a.Zn71wI3Z-L-CjoB2MdeUS2YsyYuiNVdPFTtD1rRufGo
+ hash: v1.k794b7964.f335923ba1906a322ecb0a3b826fe8bd932fc5b7d9c945539e3c31014cc8be46.w5JGvCGVMfbuQy1tFD1bZZIoPEjBBdtNDqF9AFm5JOw
filters-taxonomic-filter--events-free--dark:
hash: v1.k794b7964.422ddb7aef488b7df5fb0a27715994aed79448f280b62f4e786e08f755c88b3c.QRr2tV6xVwM-BwtU7yaivV0kH9MUWMZYRUvBMmsi1k4
filters-taxonomic-filter--events-free--light:
@@ -2400,6 +2400,10 @@ snapshots:
hash: v1.k794b7964.422ddb7aef488b7df5fb0a27715994aed79448f280b62f4e786e08f755c88b3c.kny9iJ5G5fwjTNqF1xKveHzAT06hjte-CATByxBVFaM
filters-taxonomic-filter--events-premium--light:
hash: v1.k794b7964.81a78bc8ee376be4d5515ddcab000082de15195a6ea1e700546a2346d4cb17f3.BZBvpIZWaczTKJuEBUyigcG45af_A0jgpe10HbXQ9rQ
+ filters-taxonomic-filter--mcp-tool-call-context-leads-with-mcp-properties--dark:
+ hash: v1.k794b7964.13fd306591ab8aa983b98d475f2fa5566c4fdc3f8cf86d634d98c884c326a779.ZS2ZfxmIjJjZY9VD_0Ueclr1mbmK_5qkuHbny_eV2B4
+ filters-taxonomic-filter--mcp-tool-call-context-leads-with-mcp-properties--light:
+ hash: v1.k794b7964.f05515f639b708d7040f3eeea94ac1f1bb819da3c9b2fde01b279fcc890ade64.0ehdaKblJiZDrwKVE3vZIUuyTQgC8w3pwJz1hjnUXtA
filters-taxonomic-filter--numerical-properties--dark:
hash: v1.k794b7964.211cf5cd352dfb7271a57636456aa1941fc4fee60d3b9cb90fd5e085590c15df.n-ZDoAvfpbf_TK1KAI71t8q8LlsAC7SFPpUVDGTmfyA
filters-taxonomic-filter--numerical-properties--light:
diff --git a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
index aea708cef488..b025a0b44d0b 100644
--- a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
@@ -50,6 +50,9 @@ import { OperandTag } from './OperandTag'
import { taxonomicPropertyFilterLogic } from './taxonomicPropertyFilterLogic'
export const DEFAULT_TAXONOMIC_GROUP_TYPES = [
+ // Only materializes when the picker is scoped to $mcp_* events (see taxonomicGroups),
+ // leading with the known MCP schema there; a no-op everywhere else.
+ TaxonomicFilterGroupType.MCPProperties,
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
diff --git a/frontend/src/lib/components/PropertyFilters/utils.test.ts b/frontend/src/lib/components/PropertyFilters/utils.test.ts
index aba63f602625..4d377efdfba6 100644
--- a/frontend/src/lib/components/PropertyFilters/utils.test.ts
+++ b/frontend/src/lib/components/PropertyFilters/utils.test.ts
@@ -301,6 +301,14 @@ describe('type mapping round-trip', () => {
expect(backToPropertyType).toEqual(propertyType)
})
+ it('MCPProperties maps one-way to the Event property filter type', () => {
+ // The rebuild menu commits with the tab's own group type, so without this
+ // mapping an MCP-tab selection would produce a filter with no type.
+ expect(taxonomicFilterTypeToPropertyFilterType(TaxonomicFilterGroupType.MCPProperties)).toEqual(
+ PropertyFilterType.Event
+ )
+ })
+
it('Group type round-trips with group_type_index preserved', () => {
const filter = {
type: PropertyFilterType.Group,
diff --git a/frontend/src/lib/components/PropertyFilters/utils.ts b/frontend/src/lib/components/PropertyFilters/utils.ts
index 87e1bc8a89d3..285b56a058fc 100644
--- a/frontend/src/lib/components/PropertyFilters/utils.ts
+++ b/frontend/src/lib/components/PropertyFilters/utils.ts
@@ -524,6 +524,11 @@ export function taxonomicFilterTypeToPropertyFilterType(
return PropertyFilterType.Event
}
+ if (filterType === TaxonomicFilterGroupType.MCPProperties) {
+ // The curated $mcp_* schema is a subgroup of event properties
+ return PropertyFilterType.Event
+ }
+
if (filterType == TaxonomicFilterGroupType.DataWarehouseProperties) {
return PropertyFilterType.DataWarehouse
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index ffc91de972f9..26fac931aaf8 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -248,6 +248,7 @@ const renderItemContents = ({
listGroupType === TaxonomicFilterGroupType.SessionProperties ||
listGroupType === TaxonomicFilterGroupType.MaxAIContext ||
listGroupType === TaxonomicFilterGroupType.ErrorTrackingProperties ||
+ listGroupType === TaxonomicFilterGroupType.MCPProperties ||
listGroupType.startsWith(TaxonomicFilterGroupType.GroupsPrefix) ? (
<>
<div className={clsx('taxonomic-list-row-contents', isStale && 'text-muted')}>
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
index 2375c3cf22fd..77005d40943d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
@@ -442,6 +442,36 @@ export const AutocaptureContextPromotesElements: Story = {
},
}
+export const MCPToolCallContextLeadsWithMCPProperties: Story = {
+ render: (args) => {
+ useMountedLogic(actionsModel)
+ return (
+ <div className="w-fit border rounded p-2 bg-surface-primary">
+ <SeedRecents count={0} />
+ <TaxonomicFilter {...args} />
+ </div>
+ )
+ },
+ args: {
+ taxonomicFilterLogicKey: 'mcp-tool-call-context',
+ eventNames: ['$mcp_tool_call'],
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.MCPProperties,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ ],
+ },
+ parameters: {
+ ...SUGGESTED_FILTERS_PARAMETERS,
+ docs: {
+ description: {
+ story: 'When the picker is scoped to $mcp_tool_call, the known @posthog/mcp schema is separated into a leading "MCP properties" group, and SuggestedFilters leads with the tool name (the event\'s primary property) and error state. Without an $mcp_* event in scope the group disappears entirely.',
+ },
+ },
+ },
+}
+
function CategoryDropdownStoryRender({
variant,
...args
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
index 1b8aeb6c29a5..7c0008af6b5b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
@@ -105,6 +105,46 @@ describe('useGroupList', () => {
expect(result.current.isLoading).toBe(false)
})
+ it.each([
+ {
+ name: 'different excludedProperties do not share a cache entry',
+ a: { excludedProperties: ['$mcp_tool_name'] },
+ b: { excludedProperties: [] },
+ expectedFetches: 2,
+ },
+ {
+ name: 'different propertyAllowList do not share a cache entry',
+ a: { propertyAllowList: ['$mcp_tool_name'] },
+ b: {},
+ expectedFetches: 2,
+ },
+ {
+ name: 'reordered content-equal excludedProperties share a cache entry',
+ a: { excludedProperties: ['$mcp_tool_name', '$mcp_is_error'] },
+ b: { excludedProperties: ['$mcp_is_error', '$mcp_tool_name'] },
+ expectedFetches: 1,
+ },
+ ])('$name', async ({ a, b, expectedFetches }) => {
+ // Exclusions/allowlists are fetch-time params: dropping them from the cache key
+ // would let one picker silently serve another's list for the whole staleTime
+ // window, while keying on order would double-fetch content-equal sets.
+ apiGet.mockResolvedValue({ results: [], count: 0 })
+ const base = {
+ type: TaxonomicFilterGroupType.EventProperties,
+ endpoint: 'api/projects/1/property_definitions',
+ }
+ renderHook(() => useGroupList({ group: makeGroup({ ...base, ...a }), searchQuery: '' }))
+ renderHook(() => useGroupList({ group: makeGroup({ ...base, ...b }), searchQuery: '' }))
+ // The exact count is deterministic: fetches fire synchronously from act-flushed
+ // effects, so both hooks' requests (or cache hits) precede waitFor's first poll.
+ await waitFor(() => expect(apiGet).toHaveBeenCalledTimes(expectedFetches))
+ if (expectedFetches === 2) {
+ // The differing params must actually reach the request, not just the cache key.
+ const [firstUrl, secondUrl] = apiGet.mock.calls.map(([url]) => url)
+ expect(firstUrl).not.toEqual(secondUrl)
+ }
+ })
+
it('respects minSearchQueryLength gating', () => {
const group = makeGroup({
endpoint: 'api/projects/1/whatever',
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
index 5b51e31356b8..91776b3a8809 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
@@ -40,7 +40,11 @@ import { createFuse } from 'lib/utils/fuseSearch'
import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import { fetchTaxonomicListPage } from './fetchTaxonomicListPage'
-import { useTaxonomicResource } from './useTaxonomicResource'
+import {
+ TAXONOMIC_LIST_KEY_FAMILY,
+ TAXONOMIC_LIST_SEARCH_KEY_FAMILY,
+ useTaxonomicResource,
+} from './useTaxonomicResource'
export const NO_ITEM_SELECTED = -1
@@ -209,9 +213,18 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
const clientFilter = !!group.clientFilterFirstPage
const remoteSearchQuery = clientFilter ? '' : searchQuery
+ // The cache is shared across pickers, and two pickers can build the same endpoint with
+ // different group-level exclusions/allowlists (e.g. the MCP tab excludes its schema from
+ // Event properties only when present) — those are fetch-time params, so key on them too.
+ // Sorted so content-equal sets in a different order share an entry: safe because the
+ // backend set-converts these params, so order never changes the response. (The allowlist
+ // also rides order-sensitively inside `group.endpoint`, so it doesn't get the collapse.)
+ const excludedPropertiesKey = JSON.stringify([...(group.excludedProperties ?? [])].sort())
+ const propertyAllowListKey = JSON.stringify([...(group.propertyAllowList ?? [])].sort())
+
const remoteKey = useMemo(
() => [
- 'taxonomic-list',
+ TAXONOMIC_LIST_KEY_FAMILY,
group.type,
group.endpoint,
group.scopedEndpoint ?? null,
@@ -221,6 +234,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
showNumericalPropsOnly,
hideBehavioralCohorts,
excludeStale,
+ excludedPropertiesKey,
+ propertyAllowListKey,
],
[
group.type,
@@ -232,6 +247,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
showNumericalPropsOnly,
hideBehavioralCohorts,
excludeStale,
+ excludedPropertiesKey,
+ propertyAllowListKey,
]
)
@@ -251,8 +268,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
}),
// Long staleTime for client-filtered groups — the cached first page
// is the single source of truth for the whole typing session.
- // Cohort create/update should invalidate via `invalidateTaxonomicResource`
- // (TODO) so a fresh fetch picks up the new item.
+ // Cohort mutations invalidate both key families via
+ // `invalidateTaxonomicResourcesWhere` in cohortsModel.
{
enabled: remoteEnabled,
staleTime: clientFilter ? 5 * 60_000 : 60_000,
@@ -274,7 +291,7 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
const serverSearchKey = useMemo(
() => [
- 'taxonomic-list-search',
+ TAXONOMIC_LIST_SEARCH_KEY_FAMILY,
group.type,
group.endpoint,
group.scopedEndpoint ?? null,
@@ -284,6 +301,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
showNumericalPropsOnly,
hideBehavioralCohorts,
excludeStale,
+ excludedPropertiesKey,
+ propertyAllowListKey,
],
[
group.type,
@@ -295,6 +314,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
showNumericalPropsOnly,
hideBehavioralCohorts,
excludeStale,
+ excludedPropertiesKey,
+ propertyAllowListKey,
]
)
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
index 9aa21655f7b1..4ba27a2a5737 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
@@ -8,6 +8,7 @@ import { groupsModel } from '~/models/groupsModel'
import { performQuery } from '~/queries/query'
import { initKeaTests } from '~/test/init'
+import { recentTaxonomicFiltersLogic } from '../recentTaxonomicFiltersLogic'
import { TaxonomicFilterGroupType } from '../types'
import { useTaxonomicFilter } from './useTaxonomicFilter'
import { __clearTaxonomicResourceCache } from './useTaxonomicResource'
@@ -27,6 +28,8 @@ const wrapper = ({ children }: { children: ReactNode }): JSX.Element => <Provide
describe('useTaxonomicFilter', () => {
beforeEach(() => {
__clearTaxonomicResourceCache()
+ // Recents persist to localStorage — clear so no test depends on what ran before it.
+ localStorage.clear()
;(performQuery as jest.Mock).mockResolvedValue({ tables: {}, joins: [] })
useMocks({
get: { '/api/projects/:team/event_definitions': { results: [], count: 0 } },
@@ -294,6 +297,48 @@ describe('useTaxonomicFilter', () => {
expect(result.current.searchQuery).toBe('')
})
+ it('selectItem records recents under an option-declared group, not the curated tab group', async () => {
+ // Mirrors legacy `getItemGroup` resolution: without the remap, an MCP-tab pick is
+ // recorded as `mcp_properties` while legacy records `event_properties`, and the
+ // shared recents storage grows near-duplicate rows across the two variants.
+ // Drain deferred recents writes scheduled by earlier tests first — they are
+ // skipped while the logic is unmounted, but would land once we mount it.
+ await act(async () => new Promise((resolve) => setTimeout(resolve, 0)))
+ recentTaxonomicFiltersLogic.mount()
+ try {
+ const { result } = renderHook(
+ () =>
+ useTaxonomicFilter({
+ // Only the curated tab — its canonical EventProperties group isn't a
+ // visible tab, so the remap must resolve against ALL group definitions.
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.MCPProperties],
+ eventNames: ['$mcp_tool_call'],
+ }),
+ { wrapper }
+ )
+ const mcpGroup = result.current.groups.find((g) => g.type === TaxonomicFilterGroupType.MCPProperties)!
+ const option = {
+ name: '$mcp_tool_name',
+ value: '$mcp_tool_name',
+ group: TaxonomicFilterGroupType.EventProperties,
+ }
+ act(() => result.current.selectItem(mcpGroup, '$mcp_tool_name', option))
+ // The recents write is deferred one tick — flush the macrotask queue.
+ await act(async () => new Promise((resolve) => setTimeout(resolve, 0)))
+ expect(recentTaxonomicFiltersLogic.values.recentFilters).toContainEqual(
+ expect.objectContaining({
+ groupType: TaxonomicFilterGroupType.EventProperties,
+ value: '$mcp_tool_name',
+ })
+ )
+ expect(
+ recentTaxonomicFiltersLogic.values.recentFilters.map((f: { groupType: string }) => f.groupType)
+ ).not.toContain(TaxonomicFilterGroupType.MCPProperties)
+ } finally {
+ recentTaxonomicFiltersLogic.unmount()
+ }
+ })
+
it('Escape key clears search', () => {
const { result } = renderHook(
() =>
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
index 188e6318d6f4..eac1da3c796f 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
@@ -298,6 +298,7 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
const ctx = useTaxonomicGroupsContext({
eventNames,
+ taxonomicGroupTypes,
schemaColumns,
schemaColumnsLoading,
metadataSource,
@@ -451,14 +452,26 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
// shares its entryKey but lacks the contains label/telemetry);
// pinned/recent context wrappers get stripped before persisting.
if (valueIn != null && item && !isQuickFilterItem(item) && !isContainsShortcutItem(item)) {
- const sourceGroupType = hasRecentContext(item) ? item._recentContext.sourceGroupType : group.type
- const stripped = hasRecentContext(item) ? stripRecentContext(item) : item
+ const recentContext = hasRecentContext(item) ? item._recentContext : undefined
+ const stripped = recentContext ? stripRecentContext(item) : item
+ // Options in curated tabs (MCP properties, internal event properties) declare
+ // the canonical group they commit as. Legacy resolves it via `getItemGroup`
+ // before dispatching, so recents must be recorded under the declared group
+ // here too — otherwise the same property gets near-duplicate Recent rows
+ // across variants (recents dedupe on groupType + value and share storage).
+ const declaredGroup =
+ !recentContext && stripped && typeof stripped === 'object' && 'group' in stripped
+ ? // Resolve against every group definition (like legacy `getItemGroup`), not just
+ // the visible tabs — a curated tab can be requested without its canonical group.
+ allGroups.find((g) => g.type === stripped.group)
+ : undefined
+ const sourceGroupType = recentContext?.sourceGroupType ?? declaredGroup?.type ?? group.type
const cleanItem = {
name: stripped.name,
...(stripped.id ? { id: stripped.id } : {}),
}
- const sourceGroupName = hasRecentContext(item) ? item._recentContext.sourceGroupName : group.name
- const propertyFilterFromRecent = hasRecentContext(item) ? item._recentContext.propertyFilter : undefined
+ const sourceGroupName = recentContext?.sourceGroupName ?? declaredGroup?.name ?? group.name
+ const propertyFilterFromRecent = recentContext?.propertyFilter
// Defer one tick — keeps the recents write off the
// commit's render cycle so React doesn't re-render the
// closing popover with a stale list.
@@ -478,7 +491,7 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
onChange?.(group, valueIn, item)
setSearchQuery('')
},
- [onChange, setSearchQuery]
+ [allGroups, onChange, setSearchQuery]
)
const selectSelected = useCallback(() => {
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
index 8221ac504e83..9ccc5bf259ce 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
@@ -40,6 +40,8 @@ import { joinsLogic } from 'products/data_warehouse/frontend/shared/logics/joins
*/
export interface UseTaxonomicGroupsContextInput {
eventNames?: string[]
+ /** Requested group types — read by group definitions that adapt to which tabs are present. */
+ taxonomicGroupTypes?: TaxonomicFilterGroupType[]
schemaColumns?: DatabaseSchemaField[]
schemaColumnsLoading?: boolean
metadataSource?: AnyDataNode
@@ -106,6 +108,7 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
aggregationLabel
),
eventNames: input.eventNames ?? (EMPTY_ARRAY as unknown as string[]),
+ taxonomicGroupTypes: input.taxonomicGroupTypes,
schemaColumns: input.schemaColumns ?? (EMPTY_ARRAY as unknown as DatabaseSchemaField[]),
schemaColumnsLoading: input.schemaColumnsLoading,
metadataSource: input.metadataSource ?? DEFAULT_METADATA_SOURCE,
@@ -131,7 +134,13 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
eventMetadataPropertyDefinitions,
personMetadataPropertyDefinitions,
featureFlags,
- input.eventNames,
+ // Content-keyed: consumers pass fresh array literals per render. The legacy logic
+ // stabilizes the same props differently — reference-equality inputs with objectsEqual
+ // on the selector result (see eventNamesWithPrimaryProperties) — same end effect.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ JSON.stringify(input.eventNames),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ JSON.stringify(input.taxonomicGroupTypes),
input.schemaColumns,
input.schemaColumnsLoading,
input.metadataSource,
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicResource.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicResource.ts
index 060fc049b545..a8248a66bbef 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicResource.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicResource.ts
@@ -24,6 +24,13 @@
*/
import { useEffect, useRef, useSyncExternalStore } from 'react'
+/** Leading element of `useGroupList`'s `remoteKey` — the cached-first-page / full remote fetch.
+ * Owned here beside the cache so key producers and invalidation predicates share one source. */
+export const TAXONOMIC_LIST_KEY_FAMILY = 'taxonomic-list'
+/** Leading element of `useGroupList`'s `serverSearchKey` — the server-side search fallback for
+ * `clientFilterFirstPage` groups whose dataset exceeds one page. */
+export const TAXONOMIC_LIST_SEARCH_KEY_FAMILY = 'taxonomic-list-search'
+
export interface UseTaxonomicResourceOptions {
/** Disable execution. Defaults to true. */
enabled?: boolean
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index 8e1df9cc0aad..cf42bd48c19d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -12,6 +12,7 @@ import {
taxonomicFilterLogic,
} from 'lib/components/TaxonomicFilter/taxonomicFilterLogic'
import { TaxonomicFilterGroupType, TaxonomicFilterLogicProps } from 'lib/components/TaxonomicFilter/types'
+import { getMCPPropertyFilterOptions } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -781,6 +782,105 @@ describe('taxonomicFilterLogic', () => {
})
})
+ describe('MCP properties group by event scope', () => {
+ // Mirrors the rebuild-side assertions in utils/mcpProperties.test.ts — the two
+ // variants define the group independently, so both sides guard against drift.
+ it.each([
+ { eventNames: ['$mcp_tool_call'], expectPresent: true },
+ { eventNames: ['$pageview'], expectPresent: false },
+ { eventNames: undefined, expectPresent: false },
+ ])(
+ 'MCP group present=$expectPresent for eventNames=$eventNames',
+ ({ eventNames, expectPresent }: { eventNames?: string[]; expectPresent: boolean }) => {
+ const testLogic = taxonomicFilterLogic({
+ taxonomicFilterLogicKey: `testMcp-${eventNames?.join('-') ?? 'none'}`,
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.MCPProperties,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.EventFeatureFlags,
+ ],
+ eventNames,
+ })
+ testLogic.mount()
+
+ const groupTypes = testLogic.values.taxonomicGroupTypes
+ expect(groupTypes.includes(TaxonomicFilterGroupType.MCPProperties)).toBe(expectPresent)
+ if (expectPresent) {
+ // The curated schema leads the tabs when in scope — the separation is the point.
+ expect(groupTypes.indexOf(TaxonomicFilterGroupType.MCPProperties)).toBeLessThan(
+ groupTypes.indexOf(TaxonomicFilterGroupType.EventProperties)
+ )
+ const suggested = testLogic.values.taxonomicGroups.find(
+ (g) => g.type === TaxonomicFilterGroupType.SuggestedFilters
+ )
+ expect(suggested?.options).toContainEqual({
+ name: '$mcp_is_error',
+ group: TaxonomicFilterGroupType.EventProperties,
+ })
+ }
+
+ testLogic.unmount()
+ }
+ )
+
+ it.each([
+ {
+ name: 'excludes the known schema from Event properties when the MCP tab is requested',
+ eventNames: ['$mcp_tool_call'],
+ groupTypes: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: true,
+ },
+ {
+ name: 'keeps Event properties intact when the MCP tab is not requested',
+ eventNames: ['$mcp_tool_call'],
+ groupTypes: [TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: false,
+ },
+ {
+ name: 'keeps Event properties intact when not scoped to MCP events',
+ eventNames: ['$pageview'],
+ groupTypes: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: false,
+ },
+ ])(
+ '$name',
+ ({
+ name,
+ eventNames,
+ groupTypes,
+ expectExcluded,
+ }: {
+ name: string
+ eventNames: string[]
+ groupTypes: TaxonomicFilterGroupType[]
+ expectExcluded: boolean
+ }) => {
+ const testLogic = taxonomicFilterLogic({
+ taxonomicFilterLogicKey: `testMcpExclusion-${name}`,
+ taxonomicGroupTypes: groupTypes,
+ eventNames,
+ })
+ testLogic.mount()
+
+ const eventProperties = testLogic.values.taxonomicGroups.find(
+ (g) => g.type === TaxonomicFilterGroupType.EventProperties
+ )
+ if (expectExcluded) {
+ // Exclusive like autocapture: the known schema lives only in the MCP tab.
+ // The concrete key guards against arrayContaining([]) matching vacuously.
+ expect(eventProperties?.excludedProperties).toContain('$mcp_tool_name')
+ expect(eventProperties?.excludedProperties).toEqual(
+ expect.arrayContaining(getMCPPropertyFilterOptions())
+ )
+ } else {
+ expect(eventProperties?.excludedProperties ?? []).not.toContain('$mcp_tool_name')
+ }
+
+ testLogic.unmount()
+ }
+ )
+ })
+
describe('SuggestedFilters presence by variant', () => {
afterEach(() => {
featureFlagLogic.actions.setFeatureFlags([], {
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index e8ad385a5f48..e4a1a126843b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -49,6 +49,13 @@ import {
TaxonomicFilterValue,
isQuickFilterItem,
} from 'lib/components/TaxonomicFilter/types'
+import {
+ MCP_TOOL_CALL_EVENT,
+ MCP_TOOL_CALL_SUGGESTED_PROPERTIES,
+ getMCPExcludedEventProperties,
+ getMCPPropertyFilterOptions,
+ includesMCPAnalyticsEvents,
+} from 'lib/components/TaxonomicFilter/utils/mcpProperties'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconCohort } from 'lib/lemon-ui/icons'
import { Link } from 'lib/lemon-ui/Link'
@@ -489,17 +496,20 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
(eventNames) => eventNames ?? [],
{ resultEqualityCheck: objectsEqual },
],
- // Combined selector that returns both event names and the distinct primary properties
- // for those events. Combined into a single selector so taxonomicGroups stays under
- // kea's 16-dep tuple type limit; consumers destructure both fields.
+ // Combined selector that returns the event names, the distinct primary properties for
+ // those events, and the known MCP schema to hide from Event properties when the MCP tab
+ // hosts it. Combined into a single selector so taxonomicGroups stays under kea's 16-dep
+ // tuple type limit; consumers destructure the fields.
eventNamesWithPrimaryProperties: [
- (s) => [s.eventNames, s.primaryProperties],
+ (s) => [s.eventNames, s.primaryProperties, (_, props) => props.taxonomicGroupTypes],
(
eventNames: string[],
- primaryProperties: Record<string, string>
+ primaryProperties: Record<string, string>,
+ taxonomicGroupTypes: TaxonomicFilterGroupType[] | undefined
): {
eventNames: string[]
primaryPropertiesForContextEvents: string[]
+ mcpExcludedEventProperties: string[]
} => {
const distinct = new Set<string>()
for (const eventName of eventNames) {
@@ -511,6 +521,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
return {
eventNames,
primaryPropertiesForContextEvents: Array.from(distinct),
+ mcpExcludedEventProperties: getMCPExcludedEventProperties(eventNames, taxonomicGroupTypes),
}
},
{ resultEqualityCheck: objectsEqual },
@@ -620,6 +631,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
eventNamesWithPrimaryProperties: {
eventNames: string[]
primaryPropertiesForContextEvents: string[]
+ mcpExcludedEventProperties: string[]
},
schemaColumns: DatabaseSchemaField[],
schemaColumnsLoading: boolean | undefined,
@@ -642,7 +654,8 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
featureFlags: Record<string, boolean | string | undefined>
): TaxonomicFilterGroup[] => {
- const { eventNames, primaryPropertiesForContextEvents } = eventNamesWithPrimaryProperties
+ const { eventNames, primaryPropertiesForContextEvents, mcpExcludedEventProperties } =
+ eventNamesWithPrimaryProperties
const { id: teamId } = currentTeam
const { excludedProperties, propertyAllowList } = propertyFilters
const groups: TaxonomicFilterGroup[] = [
@@ -832,6 +845,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
...(!featureFlags[FEATURE_FLAGS.TRAFFIC_TYPE_VIRTUAL_PROPERTIES]
? TRAFFIC_TYPE_VIRTUAL_PROPERTIES
: []),
+ // The known MCP schema lives only in its own group when that tab is
+ // present — excluded via the same mechanism as TRAFFIC_TYPE_VIRTUAL_PROPERTIES
+ // above; the exclusivity intent is documented on getMCPExcludedEventProperties.
+ ...mcpExcludedEventProperties,
],
propertyAllowList:
propertyAllowList?.[TaxonomicFilterGroupType.EventProperties]?.filter(isString),
@@ -859,6 +876,26 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getIcon: getPropertyDefinitionIcon,
getPopoverHeader: () => 'Internal event properties',
},
+ // Only offered when the picker is scoped to canonical MCP events, so the
+ // known @posthog/mcp schema is separated out without adding a tab anywhere else.
+ ...(includesMCPAnalyticsEvents(eventNames)
+ ? [
+ {
+ name: 'MCP properties',
+ searchPlaceholder: 'MCP properties',
+ type: TaxonomicFilterGroupType.MCPProperties,
+ options: getMCPPropertyFilterOptions().map((value) => ({
+ name: value,
+ value,
+ group: TaxonomicFilterGroupType.EventProperties,
+ })),
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getIcon: getPropertyDefinitionIcon,
+ getPopoverHeader: () => 'MCP property',
+ },
+ ]
+ : []),
{
name: 'Event metadata',
searchPlaceholder: 'event metadata',
@@ -1552,6 +1589,12 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
group: TaxonomicFilterGroupType.Elements,
}))
: []),
+ ...(eventNames.includes(MCP_TOOL_CALL_EVENT)
+ ? MCP_TOOL_CALL_SUGGESTED_PROPERTIES.map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.EventProperties,
+ }))
+ : []),
],
getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index 934dcf62e051..6f13979e7421 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -341,6 +341,7 @@ export enum TaxonomicFilterGroupType {
Resources = 'resources',
ErrorTrackingProperties = 'error_tracking_properties',
ActivityLogProperties = 'activity_log_properties',
+ MCPProperties = 'mcp_properties',
// Max AI Context
MaxAIContext = 'max_ai_context',
// Workflows execution variables
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index fa96037c790a..b36bbbcd286b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
@@ -17,6 +17,13 @@ import {
TaxonomicFilterValue,
} from 'lib/components/TaxonomicFilter/types'
import { withKeywordShortcuts } from 'lib/components/TaxonomicFilter/utils/keywordShortcuts'
+import {
+ MCP_TOOL_CALL_EVENT,
+ MCP_TOOL_CALL_SUGGESTED_PROPERTIES,
+ getMCPExcludedEventProperties,
+ getMCPPropertyFilterOptions,
+ includesMCPAnalyticsEvents,
+} from 'lib/components/TaxonomicFilter/utils/mcpProperties'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconCohort } from 'lib/lemon-ui/icons'
import { Link } from 'lib/lemon-ui/Link'
@@ -135,6 +142,12 @@ export interface BuildTaxonomicGroupsContext {
groupAnalyticsTaxonomicGroups: TaxonomicFilterGroup[]
groupAnalyticsTaxonomicGroupNames: TaxonomicFilterGroup[]
eventNames: string[]
+ /**
+ * The picker's requested group types — read by group definitions that adapt to which
+ * tabs are present (e.g. Event properties excludes the known MCP schema only when the
+ * MCP properties tab is there to host it).
+ */
+ taxonomicGroupTypes?: TaxonomicFilterGroupType[]
/**
* Distinct promoted properties for events currently in context. Surfaced first in the
* SuggestedFilters tab so the team's chosen "summary" property is one click away.
@@ -354,6 +367,10 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
...(!featureFlags[FEATURE_FLAGS.TRAFFIC_TYPE_VIRTUAL_PROPERTIES]
? TRAFFIC_TYPE_VIRTUAL_PROPERTIES
: []),
+ // The known MCP schema lives only in its own group when that tab is
+ // present — excluded via the same mechanism as TRAFFIC_TYPE_VIRTUAL_PROPERTIES
+ // above; the exclusivity intent is documented on getMCPExcludedEventProperties.
+ ...getMCPExcludedEventProperties(eventNames, ctx.taxonomicGroupTypes),
],
propertyAllowList: propertyAllowList?.[TaxonomicFilterGroupType.EventProperties]?.filter(isString),
...withKeywordShortcuts<PropertyDefinition>(
@@ -380,6 +397,26 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
getIcon: getPropertyDefinitionIcon,
getPopoverHeader: () => 'Internal event properties',
},
+ // Only offered when the picker is scoped to canonical MCP events, so the
+ // known @posthog/mcp schema is separated out without adding a tab anywhere else.
+ ...(includesMCPAnalyticsEvents(eventNames)
+ ? [
+ {
+ name: 'MCP properties',
+ searchPlaceholder: 'MCP properties',
+ type: TaxonomicFilterGroupType.MCPProperties,
+ options: getMCPPropertyFilterOptions().map((value) => ({
+ name: value,
+ value,
+ group: TaxonomicFilterGroupType.EventProperties,
+ })),
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getIcon: getPropertyDefinitionIcon,
+ getPopoverHeader: () => 'MCP property',
+ },
+ ]
+ : []),
{
name: 'Event metadata',
searchPlaceholder: 'event metadata',
@@ -1057,6 +1094,12 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
group: TaxonomicFilterGroupType.Elements,
}))
: []),
+ ...(eventNames.includes(MCP_TOOL_CALL_EVENT)
+ ? MCP_TOOL_CALL_SUGGESTED_PROPERTIES.map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.EventProperties,
+ }))
+ : []),
],
getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.test.ts b/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.test.ts
new file mode 100644
index 000000000000..3003fb838255
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.test.ts
@@ -0,0 +1,137 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import {
+ buildTaxonomicGroups,
+ BuildTaxonomicGroupsContext,
+} from 'lib/components/TaxonomicFilter/utils/buildTaxonomicGroups'
+import {
+ MCP_TOOL_CALL_EVENT,
+ getMCPPropertyFilterOptions,
+ includesMCPAnalyticsEvents,
+} from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+import { getPrimaryPropertyForEvent } from 'lib/utils/events'
+
+import { NodeKind } from '~/queries/schema/schema-general'
+import { TeamType } from '~/types'
+
+describe('mcpProperties', () => {
+ it('leads with the funnel-relevant properties and derives the rest of the known schema', () => {
+ const options = getMCPPropertyFilterOptions()
+
+ expect(options.slice(0, 4)).toEqual([
+ '$mcp_tool_name',
+ '$mcp_tool_category',
+ '$mcp_is_error',
+ '$mcp_error_type',
+ ])
+ // Non-priority schema properties come from the taxonomy-derived group, so new
+ // $mcp_* taxonomy entries surface without touching this module.
+ expect(options).toContain('$mcp_transport')
+ expect(options.every((key) => key.startsWith('$mcp_'))).toBe(true)
+ expect(new Set(options).size).toBe(options.length)
+ })
+
+ it.each([
+ { eventNames: [MCP_TOOL_CALL_EVENT], expected: true },
+ { eventNames: ['$mcp_tools_list'], expected: true },
+ { eventNames: ['$pageview', MCP_TOOL_CALL_EVENT], expected: true },
+ // Frozen legacy event names carry an unprefixed schema, so they don't count.
+ { eventNames: ['mcp_tool_call'], expected: false },
+ { eventNames: ['$pageview'], expected: false },
+ { eventNames: [], expected: false },
+ ])('includesMCPAnalyticsEvents($eventNames) is $expected', ({ eventNames, expected }) => {
+ expect(includesMCPAnalyticsEvents(eventNames)).toBe(expected)
+ })
+
+ it('surfaces the tool name as the primary property of $mcp_tool_call', () => {
+ // Guards the taxonomy entry and its regenerated JSON — this is what makes
+ // tool-call funnel steps and event rows describe themselves by tool name.
+ expect(getPrimaryPropertyForEvent(MCP_TOOL_CALL_EVENT)).toBe('$mcp_tool_name')
+ })
+
+ describe('rebuild group availability (buildTaxonomicGroups)', () => {
+ const baseContext: BuildTaxonomicGroupsContext = {
+ currentTeam: { id: 997 } as TeamType,
+ projectId: 997,
+ groupAnalyticsTaxonomicGroups: [],
+ groupAnalyticsTaxonomicGroupNames: [],
+ eventNames: [],
+ schemaColumns: [],
+ schemaColumnsLoading: false,
+ metadataSource: { kind: NodeKind.HogQLQuery, query: 'select event from events' },
+ suggestedFiltersLabel: undefined,
+ propertyFilters: { excludedProperties: {} },
+ eventMetadataPropertyDefinitions: [],
+ personMetadataPropertyDefinitions: [],
+ maxContextOptions: [],
+ hideBehavioralCohorts: false,
+ endpointFilters: undefined,
+ hogQLExpressionComponentProps: { showBreakdownLabelHint: false },
+ featureFlags: {},
+ }
+
+ it('only offers the MCP properties group when scoped to canonical MCP events', () => {
+ const unscoped = buildTaxonomicGroups(baseContext)
+ expect(unscoped.find((g) => g.type === TaxonomicFilterGroupType.MCPProperties)).toBeUndefined()
+
+ const scoped = buildTaxonomicGroups({ ...baseContext, eventNames: [MCP_TOOL_CALL_EVENT] })
+ const mcpGroup = scoped.find((g) => g.type === TaxonomicFilterGroupType.MCPProperties)
+ expect(mcpGroup).toBeTruthy()
+ // Options remap to EventProperties so selecting one creates a plain event property filter.
+ expect(mcpGroup?.options?.[0]).toEqual({
+ name: '$mcp_tool_name',
+ value: '$mcp_tool_name',
+ group: TaxonomicFilterGroupType.EventProperties,
+ })
+ })
+
+ it.each([
+ {
+ name: 'excludes the known schema from Event properties when the MCP tab is requested',
+ eventNames: [MCP_TOOL_CALL_EVENT],
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: true,
+ },
+ {
+ name: 'keeps Event properties intact when the MCP tab is not requested',
+ eventNames: [MCP_TOOL_CALL_EVENT],
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: false,
+ },
+ {
+ name: 'keeps Event properties intact when not scoped to MCP events',
+ eventNames: ['$pageview'],
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.MCPProperties, TaxonomicFilterGroupType.EventProperties],
+ expectExcluded: false,
+ },
+ ])('$name', ({ eventNames, taxonomicGroupTypes, expectExcluded }) => {
+ const groups = buildTaxonomicGroups({ ...baseContext, eventNames, taxonomicGroupTypes })
+ const eventProperties = groups.find((g) => g.type === TaxonomicFilterGroupType.EventProperties)
+ if (expectExcluded) {
+ // Exclusive like autocapture: the known schema lives only in the MCP tab.
+ // The concrete key guards against arrayContaining([]) matching vacuously.
+ expect(eventProperties?.excludedProperties).toContain('$mcp_tool_name')
+ expect(eventProperties?.excludedProperties).toEqual(
+ expect.arrayContaining(getMCPPropertyFilterOptions())
+ )
+ } else {
+ expect(eventProperties?.excludedProperties ?? []).not.toContain('$mcp_tool_name')
+ }
+ })
+
+ it('seeds $mcp_is_error into SuggestedFilters when scoped to $mcp_tool_call', () => {
+ const scoped = buildTaxonomicGroups({ ...baseContext, eventNames: [MCP_TOOL_CALL_EVENT] })
+ const suggested = scoped.find((g) => g.type === TaxonomicFilterGroupType.SuggestedFilters)
+ expect(suggested?.options).toContainEqual({
+ name: '$mcp_is_error',
+ group: TaxonomicFilterGroupType.EventProperties,
+ })
+
+ const unscoped = buildTaxonomicGroups(baseContext)
+ const unscopedSuggested = unscoped.find((g) => g.type === TaxonomicFilterGroupType.SuggestedFilters)
+ expect(unscopedSuggested?.options).not.toContainEqual({
+ name: '$mcp_is_error',
+ group: TaxonomicFilterGroupType.EventProperties,
+ })
+ })
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.ts b/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.ts
new file mode 100644
index 000000000000..e9577027f042
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/mcpProperties.ts
@@ -0,0 +1,73 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import { CORE_FILTER_DEFINITIONS_BY_GROUP, POSTHOG_EVENT_PROMOTED_PROPERTIES } from '~/taxonomy/taxonomy'
+
+/**
+ * MCP analytics helpers shared by the legacy taxonomic filter (`taxonomicFilterLogic.tsx`)
+ * and the rebuild (`buildTaxonomicGroups.tsx`), so the two variants can't drift.
+ *
+ * Events captured by the @posthog/mcp SDK carry a known `$mcp_*` property schema.
+ * The `mcp_properties` group in `posthog/taxonomy/taxonomy.py` (the `$mcp_`-prefixed
+ * subset of event properties) is the source of truth for that schema — this module
+ * only orders and highlights it. When a picker is scoped to those events, the schema
+ * is surfaced as a dedicated "MCP properties" group — the same way autocapture
+ * separates its element properties.
+ */
+
+export const MCP_TOOL_CALL_EVENT = '$mcp_tool_call'
+
+/** Canonical @posthog/mcp events are `$mcp_`-prefixed — any of them qualifies, and the
+ * group always offers the full known schema (event-specific properties' popovers say
+ * which event carries them). The frozen legacy names (`mcp_tool_call`, ...) carry an
+ * unprefixed property schema, so they deliberately don't get the dedicated group. */
+export function isMCPAnalyticsEventName(eventName: string): boolean {
+ // eventNames is assembled dynamically by many surfaces; unlike the `.includes()`
+ // scope checks alongside this one, `.startsWith` would throw on a stray null.
+ return typeof eventName === 'string' && eventName.startsWith('$mcp_')
+}
+
+export function includesMCPAnalyticsEvents(eventNames: string[]): boolean {
+ return eventNames.some(isMCPAnalyticsEventName)
+}
+
+/** The properties funnels and paths between tool calls pivot on, shown first — the
+ * event's promoted properties, so picker ordering and event-inspector promotion
+ * can't drift apart. The rest of the known schema follows in taxonomy order. */
+const PRIORITY_MCP_PROPERTIES: string[] = POSTHOG_EVENT_PROMOTED_PROPERTIES[MCP_TOOL_CALL_EVENT]
+
+// Derived once from the (already static, module-load-resolved) taxonomy — no need to cache
+// beyond the top-level const, since CORE_FILTER_DEFINITIONS_BY_GROUP never changes at runtime.
+const MCP_PROPERTY_FILTER_OPTIONS: string[] = (() => {
+ const known = Object.keys(CORE_FILTER_DEFINITIONS_BY_GROUP[TaxonomicFilterGroupType.MCPProperties])
+ const prioritized = PRIORITY_MCP_PROPERTIES.filter((key) => known.includes(key))
+ return [...prioritized, ...known.filter((key) => !PRIORITY_MCP_PROPERTIES.includes(key))]
+})()
+
+export function getMCPPropertyFilterOptions(): string[] {
+ return MCP_PROPERTY_FILTER_OPTIONS
+}
+
+/** Seeded into the Suggested tab when the picker is scoped to `$mcp_tool_call`, so
+ * success/failure splits are one click away. In the legacy picker `$mcp_tool_name`
+ * also lands there via the event's `primary_property`; the rebuild doesn't seed
+ * primary properties yet (`promotedPropertiesForContextEvents` is unwired), so it
+ * shows only this list. */
+export const MCP_TOOL_CALL_SUGGESTED_PROPERTIES: string[] = ['$mcp_is_error']
+
+/** When the MCP properties group is available in a picker, the known schema is
+ * excluded from Event properties so each property lives in exactly one group —
+ * the exclusivity autocapture gets structurally (element properties are their own
+ * namespace), emulated via the same exclusion mechanism as
+ * TRAFFIC_TYPE_VIRTUAL_PROPERTIES. `$mcp_*` keys a team ingests beyond the known
+ * schema still surface under Event properties. With `requestedGroupTypes` undefined
+ * the exclusion stays off — degrading toward duplication (benign) rather than
+ * hiding properties. */
+export function getMCPExcludedEventProperties(
+ eventNames: string[],
+ requestedGroupTypes: TaxonomicFilterGroupType[] | undefined
+): string[] {
+ return includesMCPAnalyticsEvents(eventNames) &&
+ requestedGroupTypes?.includes(TaxonomicFilterGroupType.MCPProperties)
+ ? getMCPPropertyFilterOptions()
+ : []
+}
diff --git a/frontend/src/models/cohortsModel.ts b/frontend/src/models/cohortsModel.ts
index 71cd90d7e53d..30d3f34a63af 100644
--- a/frontend/src/models/cohortsModel.ts
+++ b/frontend/src/models/cohortsModel.ts
@@ -4,7 +4,11 @@ import { router } from 'kea-router'
import { v4 as uuidv4 } from 'uuid'
import api, { CountedPaginatedResponse } from 'lib/api'
-import { invalidateTaxonomicResourcesWhere } from 'lib/components/TaxonomicFilter/hooks/useTaxonomicResource'
+import {
+ TAXONOMIC_LIST_KEY_FAMILY,
+ TAXONOMIC_LIST_SEARCH_KEY_FAMILY,
+ invalidateTaxonomicResourcesWhere,
+} from 'lib/components/TaxonomicFilter/hooks/useTaxonomicResource'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { permanentlyMount } from 'lib/utils/kea-logic-builders'
@@ -119,12 +123,14 @@ function processCohortCriteria(criteria: AnyCohortCriteriaType): AnyCohortCriter
/**
* Predicate for `invalidateTaxonomicResourcesWhere` — matches the cache
* entries belonging to the `Cohorts` / `CohortsWithAllUsers` taxonomic
- * groups. The key shape is set in `useGroupList`:
- * ['taxonomic-list', groupType, endpoint, scopedEndpoint, isExpanded,
- * searchQuery, limit, showNumericalPropsOnly, hideBehavioralCohorts]
+ * groups. `useGroupList.ts` caches under two key families — `remoteKey`
+ * (`TAXONOMIC_LIST_KEY_FAMILY`) and `serverSearchKey`
+ * (`TAXONOMIC_LIST_SEARCH_KEY_FAMILY`) — both shaped
+ * `[family, groupType, ...fetch params]` and growing with new fetch params,
+ * so rely only on the leading two positions here.
*/
function isCohortTaxonomicListKey(key: unknown[]): boolean {
- if (key[0] !== 'taxonomic-list') {
+ if (key[0] !== TAXONOMIC_LIST_KEY_FAMILY && key[0] !== TAXONOMIC_LIST_SEARCH_KEY_FAMILY) {
return false
}
return key[1] === TaxonomicFilterGroupType.Cohorts || key[1] === TaxonomicFilterGroupType.CohortsWithAllUsers
@@ -300,6 +306,11 @@ export const cohortsModel = kea<cohortsModelType>([
endpoint: api.cohorts.determineDeleteEndpoint(),
object: cohort,
callback: (undo) => {
+ if (undo) {
+ // The delete-time invalidation above already ran; a restore needs its
+ // own, or pickers keep serving the deleted-state cache for staleTime.
+ invalidateTaxonomicResourcesWhere(isCohortTaxonomicListKey)
+ }
actions.loadCohorts()
if (cohort.id && cohort.id !== 'new') {
if (undo) {
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 50b368f58d80..3325451824dc 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -46268,6 +46268,7 @@
"resources",
"error_tracking_properties",
"activity_log_properties",
+ "mcp_properties",
"max_ai_context",
"workflow_variables",
"suggested_filters",
diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx b/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
index f288cd71d641..d854c0b6ab85 100644
--- a/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
@@ -45,6 +45,7 @@ export const TaxonomicBreakdownPopover = ({
taxonomicGroupTypes = [TaxonomicFilterGroupType.CohortsWithAllUsers]
} else if (isRetentionQuery(query) || (isInsightVizNode(query) && isRetentionQuery(query.source))) {
taxonomicGroupTypes = [
+ TaxonomicFilterGroupType.MCPProperties,
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
@@ -55,6 +56,9 @@ export const TaxonomicBreakdownPopover = ({
]
} else {
taxonomicGroupTypes = [
+ // Only materializes when the insight has $mcp_* series in scope, so breakdowns
+ // by e.g. tool name or error state lead with the known MCP schema.
+ TaxonomicFilterGroupType.MCPProperties,
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
diff --git a/frontend/src/scenes/insights/utils/propertyTaxonomicGroupTypes.ts b/frontend/src/scenes/insights/utils/propertyTaxonomicGroupTypes.ts
index 90db6e53b447..c5519424ce52 100644
--- a/frontend/src/scenes/insights/utils/propertyTaxonomicGroupTypes.ts
+++ b/frontend/src/scenes/insights/utils/propertyTaxonomicGroupTypes.ts
@@ -17,6 +17,9 @@ export function getInsightPropertyFilterGroupTypes({
includeDataWarehouseProperties?: boolean
}): TaxonomicFilterGroupType[] {
return [
+ // Only materializes when the picker is scoped to $mcp_* events (e.g. a funnel
+ // step on an MCP tool call), leading with the known MCP schema there.
+ TaxonomicFilterGroupType.MCPProperties,
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.json
index 0451091db1d5..8e94272b13a5 100644
--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json
+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json
@@ -3959,7 +3959,8 @@
},
"$mcp_tool_call": {
"description": "Fires every time an MCP server tool is invoked via @posthog/mcp. Includes the tool name, wall-clock duration, error state, and (when the client supplied a context argument) the agent's stated intent. Canonical replacement for the legacy `mcp_tool_call`.",
- "label": "MCP tool call"
+ "label": "MCP tool call",
+ "primary_property": "$mcp_tool_name"
},
"$mcp_tools_list": {
"description": "Fires when an MCP client requests the list of available tools. Useful for measuring discovery \u2014 whether new clients are finding the server. Canonical replacement for the legacy `mcp_tools_list`.",
@@ -4158,6 +4159,252 @@
"label": "Console log message"
}
},
+ "mcp_properties": {
+ "$mcp_client_name": {
+ "description": "The MCP client that initiated the connection. Common values are coding agents (Claude Code, Codex) and chat clients (Claude desktop, Claude on web).",
+ "examples": [
+ "claude-code",
+ "codex-mcp-client",
+ "Anthropic/ClaudeAI"
+ ],
+ "label": "MCP client name"
+ },
+ "$mcp_client_user_agent": {
+ "description": "Full User-Agent string the MCP client sent on the transport. Often includes the agent name, version, and runtime mode \u2014 useful when $mcp_client_name and $mcp_client_version alone don't disambiguate the caller.",
+ "examples": [
+ "claude-code/2.1.141 (cli)",
+ "Anthropic/ClaudeAI"
+ ],
+ "label": "MCP client user agent"
+ },
+ "$mcp_client_version": {
+ "description": "The version of the MCP client that initiated the connection.",
+ "label": "MCP client version"
+ },
+ "$mcp_consumer": {
+ "description": "The upstream surface that initiated the MCP request, supplied via the `x-posthog-mcp-consumer` header. 'posthog-code' means the request came through PostHog Code; 'slack' means it was triggered from Slack.",
+ "examples": [
+ "posthog-code",
+ "slack"
+ ],
+ "label": "MCP consumer"
+ },
+ "$mcp_conversation_id": {
+ "description": "Stable, agent-echoed conversation identifier that stitches multiple tool calls into a single logical session. The MCP server mints a UUID when the agent omits one and prompts the agent to reuse it on subsequent calls; subsequent calls within the same conversation carry the same value. Unlike $mcp_session_id this survives reconnects and process restarts. Only present when the server has `enableConversationId` turned on.",
+ "label": "MCP conversation ID"
+ },
+ "$mcp_duration_ms": {
+ "description": "Wall-clock duration of the MCP tool or resource call, in milliseconds.",
+ "examples": [
+ 42,
+ 1280
+ ],
+ "label": "MCP duration (ms)",
+ "type": "Numeric"
+ },
+ "$mcp_error_message": {
+ "description": "Error message for a failed MCP tool call, truncated. Present when the server passes the thrown error to the SDK; PostHog's own server omits it to avoid capturing query content. Only set when $mcp_is_error is true.",
+ "label": "MCP error message"
+ },
+ "$mcp_error_status": {
+ "description": "Upstream HTTP status code when an MCP tool call failed against a PostHog API (e.g. 429, 500). Only set for API-originated failures.",
+ "examples": [
+ 429,
+ 500,
+ 403
+ ],
+ "label": "MCP error status",
+ "type": "Numeric"
+ },
+ "$mcp_error_type": {
+ "description": "Failure category for an errored MCP tool call, for breaking failures down by reason. PostHog's server emits a semantic bucket (missing_context, validation, permission, timeout, rate_limited, api_4xx, api_5xx, internal); external servers using the SDK fall back to the thrown error's type. Only set when $mcp_is_error is true.",
+ "examples": [
+ "rate_limited",
+ "validation",
+ "timeout",
+ "api_4xx"
+ ],
+ "label": "MCP error type"
+ },
+ "$mcp_exec_inner_tool_names": {
+ "description": "Array of every inner tool name available to the agent at the time of a tools/list request. Stored as a JSON array \u2014 filter with `contains` against a single tool name (e.g. 'execute-sql'). Only stamped on mcp_tools_list events when running in single-exec mode (in multi-tool mode the SDK's $mcp_listed_tool_names already carries the catalog). Lets you compute zombie tools by diffing against $mcp_exec_tool_call_name from mcp_tool_call events.",
+ "examples": [
+ "execute-sql",
+ "feature-flag-get-all"
+ ],
+ "label": "MCP exec inner tool catalog"
+ },
+ "$mcp_exec_tool_call_description": {
+ "description": "In single-exec mode, $mcp_tool_name is always 'exec' (the dispatcher), so the SDK's $mcp_tool_description is the dispatcher's static text on every call. This property carries the description of the inner tool the agent was actually invoking via 'call <tool> ...' \u2014 derived server-side by parsing the exec command and looking the inner tool up in our catalog. Only present when an exec call targets a recognized inner tool.",
+ "examples": [
+ "Run a HogQL/SQL query against PostHog.",
+ "List feature flags in the project."
+ ],
+ "label": "MCP exec inner tool description"
+ },
+ "$mcp_exec_tool_call_name": {
+ "description": "In single-exec mode, $mcp_tool_name is always 'exec' (the dispatcher), so by itself it doesn't tell you which inner tool the agent was actually invoking. This property carries the inner tool's name \u2014 derived server-side by parsing the exec command's `call <tool> ...` form and looking it up in our catalog. Use it for breakdowns / funnels that should pivot on the real tool rather than the dispatcher. Only present when an exec call targets a recognized inner tool.",
+ "examples": [
+ "execute-sql",
+ "feature-flag-get-all"
+ ],
+ "label": "MCP exec inner tool name"
+ },
+ "$mcp_intent": {
+ "description": "Free-text description of why the agent is calling this tool, written by the agent itself. Comes from a context argument the client supplied at call time, or \u2014 if none was supplied \u2014 from an intentFallback the MCP server provides.",
+ "examples": [
+ "Listing recent error tracking issues to triage a spike in 500s.",
+ "Fetching the trace referenced by the inbox signal to inspect the user message."
+ ],
+ "label": "MCP intent"
+ },
+ "$mcp_intent_source": {
+ "description": "Where $mcp_intent came from. 'context_parameter' means the client supplied it directly on the call; 'inferred' means the MCP server derived it via its intentFallback.",
+ "examples": [
+ "context_parameter",
+ "inferred"
+ ],
+ "label": "MCP intent source"
+ },
+ "$mcp_is_error": {
+ "description": "Whether the MCP tool call failed. True if the tool returned an error result or threw an exception.",
+ "label": "MCP is error"
+ },
+ "$mcp_listed_tool_names": {
+ "description": "Array of every tool name advertised to the agent on a tools/list request, in multi-tool mode. Stored as a JSON array \u2014 filter with `contains` against a single tool name (e.g. 'execute-sql'). Lets you compute zombie tools (advertised but never called) by diffing against $mcp_tool_name from mcp_tool_call events. In single-exec mode the catalog rides on $mcp_exec_inner_tool_names instead. Only present on mcp_tools_list.",
+ "examples": [
+ "execute-sql",
+ "feature-flag-get-all"
+ ],
+ "label": "MCP listed tool names"
+ },
+ "$mcp_mode": {
+ "description": "Which tool-registration mode the MCP server ran in for this request. 'cli' is single-exec mode (the v2 wrapper that exposes one dispatcher tool taking a `call <tool> ...` command); 'tools' exposes every tool individually.",
+ "examples": [
+ "cli",
+ "tools"
+ ],
+ "label": "MCP mode"
+ },
+ "$mcp_oauth_client_name": {
+ "description": "The OAuth client name captured during the MCP handshake, when the connection used OAuth instead of a personal API key.",
+ "label": "MCP OAuth client name"
+ },
+ "$mcp_organization_id": {
+ "description": "PostHog organization ID resolved for the authenticated MCP session.",
+ "label": "MCP organization ID"
+ },
+ "$mcp_parameters": {
+ "description": "The arguments the client passed when invoking the tool. Large strings and sensitive keys (tokens, API keys, etc.) are redacted before capture.",
+ "label": "MCP parameters"
+ },
+ "$mcp_project_id": {
+ "description": "PostHog project (team) numeric ID for the active project on the MCP session.",
+ "label": "MCP project ID"
+ },
+ "$mcp_project_name": {
+ "description": "Display name of the active PostHog project on the MCP session.",
+ "label": "MCP project name"
+ },
+ "$mcp_project_uuid": {
+ "description": "PostHog project UUID for the active project on the MCP session.",
+ "label": "MCP project UUID"
+ },
+ "$mcp_protocol_version": {
+ "description": "The MCP protocol version negotiated between client and server during initialize.",
+ "examples": [
+ "2025-11-25",
+ "2025-06-18"
+ ],
+ "label": "MCP protocol version"
+ },
+ "$mcp_read_only": {
+ "description": "Whether the MCP session is operating in read-only mode. When true, write/mutation tools are not registered on the server.",
+ "label": "MCP read-only"
+ },
+ "$mcp_region": {
+ "description": "The PostHog cloud region the MCP server routed the request to.",
+ "examples": [
+ "us",
+ "eu"
+ ],
+ "label": "MCP region"
+ },
+ "$mcp_resource_name": {
+ "description": "The name of the MCP resource, prompt, or tool the event refers to.",
+ "label": "MCP resource name"
+ },
+ "$mcp_response": {
+ "description": "The response the MCP server returned. Large strings and sensitive keys are redacted before capture.",
+ "label": "MCP response"
+ },
+ "$mcp_server_name": {
+ "description": "The advertised name of the MCP server that handled the request.",
+ "examples": [
+ "PostHog"
+ ],
+ "label": "MCP server name"
+ },
+ "$mcp_server_version": {
+ "description": "The advertised version of the MCP server that handled the request.",
+ "label": "MCP server version"
+ },
+ "$mcp_session_id": {
+ "description": "Transport-level session handle the MCP SDK observed for this request (e.g. MCP `extra.sessionId` or a framework session cookie). Rotates per process restart, reconnect, or framework boundary \u2014 use $mcp_conversation_id when you need a stable identifier across reconnects.",
+ "label": "MCP session ID"
+ },
+ "$mcp_source": {
+ "description": "Constant identifier for the analytics SDK that emitted the event. Lets you separate events from different SDK versions or unrelated MCP servers.",
+ "examples": [
+ "posthog_mcp_analytics"
+ ],
+ "label": "MCP source"
+ },
+ "$mcp_tool_category": {
+ "description": "The product category the invoked tool belongs to \u2014 the grouping dimension the MCP analytics dashboard buckets tool calls by. Stamped server-side from the tool catalog (PostHog's server) or declared per tool (external servers). Omitted when the tool has no catalogued category (e.g. the `exec` dispatcher), which the dashboard buckets as 'Uncategorized'. Present on mcp_tool_call.",
+ "examples": [
+ "Error tracking",
+ "Logs",
+ "Feature flags",
+ "Session replays"
+ ],
+ "label": "MCP tool category"
+ },
+ "$mcp_tool_description": {
+ "description": "The MCP tool's description as advertised to the agent at the time of the call. Useful when triaging errors to see what the agent thought the tool would do \u2014 descriptions change over time, so the value captured here is the version the agent actually saw. Only present on mcp_tool_call and the paired $exception event.",
+ "examples": [
+ "Run a HogQL/SQL query against PostHog.",
+ "Fetch the trace referenced by an AI observability URL."
+ ],
+ "label": "MCP tool description"
+ },
+ "$mcp_tool_name": {
+ "description": "The name of the MCP tool that was invoked. Only present on mcp_tool_call.",
+ "examples": [
+ "execute-sql",
+ "feature-flag-get-all"
+ ],
+ "label": "MCP tool name"
+ },
+ "$mcp_transport": {
+ "description": "The transport the MCP client used to connect to the server.",
+ "examples": [
+ "stdio",
+ "sse",
+ "streamable-http"
+ ],
+ "label": "MCP transport"
+ },
+ "$mcp_version": {
+ "description": "Server-resolved MCP version. May differ from the version the client reported because of the mcp-version-2 feature flag.",
+ "examples": [
+ 1,
+ 2
+ ],
+ "label": "MCP server version (internal)",
+ "type": "Numeric"
+ }
+ },
"metadata": {
"distinct_id": {
"description": "The current distinct ID of the user.",
diff --git a/frontend/src/taxonomy/taxonomy.tsx b/frontend/src/taxonomy/taxonomy.tsx
index e9ba72b87280..a31a399f08ee 100644
--- a/frontend/src/taxonomy/taxonomy.tsx
+++ b/frontend/src/taxonomy/taxonomy.tsx
@@ -123,6 +123,15 @@ export const POSTHOG_EVENT_PROMOTED_PROPERTIES = {
'$exception_types',
'$exception_values',
],
+ $mcp_tool_call: [
+ '$mcp_tool_name',
+ '$mcp_tool_category',
+ '$mcp_is_error',
+ '$mcp_error_type',
+ '$mcp_duration_ms',
+ '$mcp_client_name',
+ '$mcp_intent',
+ ],
}
export type KNOWN_PROMOTED_PROPERTY_PARENTS = keyof typeof POSTHOG_EVENT_PROMOTED_PROPERTIES
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 20fc5eb99cdb..19a2354c8347 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3400,6 +3400,7 @@ class TaxonomicFilterGroupType(StrEnum):
RESOURCES = "resources"
ERROR_TRACKING_PROPERTIES = "error_tracking_properties"
ACTIVITY_LOG_PROPERTIES = "activity_log_properties"
+ MCP_PROPERTIES = "mcp_properties"
MAX_AI_CONTEXT = "max_ai_context"
WORKFLOW_VARIABLES = "workflow_variables"
SUGGESTED_FILTERS = "suggested_filters"
diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.py
index 71dcdd811d92..d2acbcb354f7 100644
--- a/posthog/taxonomy/taxonomy.py
+++ b/posthog/taxonomy/taxonomy.py
@@ -297,6 +297,7 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"$mcp_tool_call": {
"label": "MCP tool call",
"description": "Fires every time an MCP server tool is invoked via @posthog/mcp. Includes the tool name, wall-clock duration, error state, and (when the client supplied a context argument) the agent's stated intent. Canonical replacement for the legacy `mcp_tool_call`.",
+ "primary_property": "$mcp_tool_name",
},
"$mcp_tools_list": {
"label": "MCP tools listed",
@@ -3838,6 +3839,16 @@ for key in SESSION_PROPERTIES_ALSO_INCLUDED_IN_EVENTS:
}
+# The @posthog/mcp SDK captures a known property schema on its events. Mirror those properties
+# into their own group so MCP-scoped pickers can surface the expected schema as a dedicated
+# taxonomic filter category (the way autocapture separates element properties).
+# Keep this below every block that mutates "event_properties", or late additions would
+# silently miss the mirror.
+CORE_FILTER_DEFINITIONS_BY_GROUP["mcp_properties"] = {
+ key: value for key, value in CORE_FILTER_DEFINITIONS_BY_GROUP["event_properties"].items() if key.startswith("$mcp_")
+}
+
+
PROPERTY_NAME_ALIASES = {
key: value["label"]
for key, value in CORE_FILTER_DEFINITIONS_BY_GROUP["event_properties"].items()
diff --git a/posthog/taxonomy/test/test_event_properties_taxonomy.py b/posthog/taxonomy/test/test_event_properties_taxonomy.py
index 1eb4ddb555c1..43fedd41d243 100644
--- a/posthog/taxonomy/test/test_event_properties_taxonomy.py
+++ b/posthog/taxonomy/test/test_event_properties_taxonomy.py
@@ -27,3 +27,9 @@ def test_should_have_every_property_in_session_adopted_from_person() -> None:
session_props = CORE_FILTER_DEFINITIONS_BY_GROUP["session_properties"].keys()
for prop in SESSION_INITIAL_PROPERTIES_ADAPTED_FROM_EVENTS:
assert f"$entry_{prop.replace('$', '')}" in session_props
+
+
+def test_mcp_properties_mirrors_every_mcp_event_property() -> None:
+ expected = {key for key in CORE_FILTER_DEFINITIONS_BY_GROUP["event_properties"] if key.startswith("$mcp_")}
+ assert expected, "expected $mcp_* keys in event_properties"
+ assert set(CORE_FILTER_DEFINITIONS_BY_GROUP["mcp_properties"]) == expected
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 8462c5de01b0..90d07720f263 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -4915,6 +4915,7 @@ export const TaxonomicFilterGroupTypeApi = {
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',
ActivityLogProperties: 'activity_log_properties',
+ McpProperties: 'mcp_properties',
MaxAiContext: 'max_ai_context',
WorkflowVariables: 'workflow_variables',
SuggestedFilters: 'suggested_filters',
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index a3a028d72dea..efec2eea9ece 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -61,6 +61,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
propertyFilters={propertyFilters}
onChange={setPropertyFilters}
taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.MCPProperties,
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
]}
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index f939f428b4f8..642ec42b57a9 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -4268,6 +4268,7 @@ export const TaxonomicFilterGroupTypeApi = {
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',
ActivityLogProperties: 'activity_log_properties',
+ McpProperties: 'mcp_properties',
MaxAiContext: 'max_ai_context',
WorkflowVariables: 'workflow_variables',
SuggestedFilters: 'suggested_filters',
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 3293f5012bbc..4fe978a52215 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -5860,6 +5860,7 @@ export namespace Schemas {
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',
ActivityLogProperties: 'activity_log_properties',
+ McpProperties: 'mcp_properties',
MaxAiContext: 'max_ai_context',
WorkflowVariables: 'workflow_variables',
SuggestedFilters: 'suggested_filters',