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): expose path cleaning on assistant trends breakdown filter (#57627)

posthog[bot]20342e1dcb4e
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 9a8d3e284358..6c3915740715 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -3724,6 +3724,10 @@
"default": 25,
"description": "How many distinct values to show."
},
+ "breakdown_path_cleaning": {
+ "description": "When `true`, applies the project's configured path cleaning rules to URL or path breakdown values (e.g. `$pathname`, `$current_url`). Use this whenever the user asks for a breakdown by a URL or path property and there is no specific reason to keep the raw values. The user does not need to provide a regex — path cleaning rules come from the project's settings.",
+ "type": "boolean"
+ },
"breakdowns": {
"description": "Use this field to define breakdowns.",
"items": {
diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.ts
index 1f9bf421c2d6..57a72ab4dc96 100644
--- a/frontend/src/queries/schema/schema-assistant-queries.ts
+++ b/frontend/src/queries/schema/schema-assistant-queries.ts
@@ -438,6 +438,10 @@ export interface AssistantTrendsBreakdownFilter extends AssistantBreakdownFilter
* @maxLength 3
*/
breakdowns: AssistantMultipleBreakdownFilter[]
+ /**
+ * When `true`, applies the project's configured path cleaning rules to URL or path breakdown values (e.g. `$pathname`, `$current_url`). Use this whenever the user asks for a breakdown by a URL or path property and there is no specific reason to keep the raw values. The user does not need to provide a regex — path cleaning rules come from the project's settings.
+ */
+ breakdown_path_cleaning?: boolean
}
// Remove deprecated display types.
diff --git a/posthog/schema.py b/posthog/schema.py
index 0535efdb7a8a..6ca8d4d6a6ea 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -6183,6 +6183,17 @@ class AssistantTrendsBreakdownFilter(BaseModel):
extra="forbid",
)
breakdown_limit: int | None = Field(default=25, description="How many distinct values to show.")
+ breakdown_path_cleaning: bool | None = Field(
+ default=None,
+ description=(
+ "When `true`, applies the project's configured path cleaning rules to URL"
+ " or path breakdown values (e.g. `$pathname`, `$current_url`). Use this"
+ " whenever the user asks for a breakdown by a URL or path property and"
+ " there is no specific reason to keep the raw values. The user does not"
+ " need to provide a regex — path cleaning rules come from the project's"
+ " settings."
+ ),
+ )
breakdowns: list[AssistantGroupMultipleBreakdownFilter | AssistantGenericMultipleBreakdownFilter] = Field(
..., description="Use this field to define breakdowns.", max_length=3
)
diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.ts
index 630c3e139921..44719486ebce 100644
--- a/services/mcp/src/tools/generated/query-wrappers.ts
+++ b/services/mcp/src/tools/generated/query-wrappers.ts
@@ -41,6 +41,12 @@ const AssistantMultipleBreakdownFilter = z.union([
const AssistantTrendsBreakdownFilter = z.object({
breakdown_limit: integer.describe('How many distinct values to show.').default(25).optional(),
+ breakdown_path_cleaning: z.coerce
+ .boolean()
+ .describe(
+ "When `true`, applies the project's configured path cleaning rules to URL or path breakdown values (e.g. `$pathname`, `$current_url`). Use this whenever the user asks for a breakdown by a URL or path property and there is no specific reason to keep the raw values. The user does not need to provide a regex — path cleaning rules come from the project's settings."
+ )
+ .optional(),
breakdowns: z.array(AssistantMultipleBreakdownFilter).describe('Use this field to define breakdowns.'),
})
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends-actors.json
index 0db0075ecb4f..4284c2d5ffb3 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends-actors.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends-actors.json
@@ -65,6 +65,10 @@
"minimum": -9007199254740991,
"type": "integer"
},
+ "breakdown_path_cleaning": {
+ "description": "When `true`, applies the project's configured path cleaning rules to URL or path breakdown values (e.g. `$pathname`, `$current_url`). Use this whenever the user asks for a breakdown by a URL or path property and there is no specific reason to keep the raw values. The user does not need to provide a regex — path cleaning rules come from the project's settings.",
+ "type": "boolean"
+ },
"breakdowns": {
"description": "Use this field to define breakdowns.",
"items": {
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends.json
index 41cd98304f3b..c681a2c3ecb6 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-trends.json
@@ -24,6 +24,10 @@
"minimum": -9007199254740991,
"type": "integer"
},
+ "breakdown_path_cleaning": {
+ "description": "When `true`, applies the project's configured path cleaning rules to URL or path breakdown values (e.g. `$pathname`, `$current_url`). Use this whenever the user asks for a breakdown by a URL or path property and there is no specific reason to keep the raw values. The user does not need to provide a regex — path cleaning rules come from the project's settings.",
+ "type": "boolean"
+ },
"breakdowns": {
"description": "Use this field to define breakdowns.",
"items": {