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.

fix(surveys): clarify MCP property targeting (#86779)

Matt Pua22e33f4897c1
diff --git a/products/surveys/mcp/tools.yaml b/products/surveys/mcp/tools.yaml
index 5d7e16a3061a..0cd3af1516bb 100644
--- a/products/surveys/mcp/tools.yaml
+++ b/products/surveys/mcp/tools.yaml
@@ -78,9 +78,10 @@ tools:
user wants structured answers. Questions can include inline translations on each question.
conditions:
description: >
- Display and targeting conditions for in-app surveys, such as URL matching, event triggers, device
- filters, or linked flag variants. Do not use URL, selector, event, device, or linkedFlagVariant
- conditions for external_survey forms.
+ Display conditions for in-app surveys, such as URL matching, event triggers, device filters, or
+ linked flag variants. To target people, groups, or cohorts by properties, use targeting_flag_filters
+ instead. Do not use URL, selector, event, device, or linkedFlagVariant conditions for
+ external_survey forms.
start_date:
description: >
Setting this launches the survey immediately. Leave unset unless the user explicitly asks to launch
@@ -91,8 +92,9 @@ tools:
a feature flag. Resolve the flag ID first, preferably with SQL in v2.
targeting_flag_filters:
description: >
- User targeting rules for in-app surveys. Use only when the user wants the survey shown to a subset
- of users. Do not use this for external_survey forms.
+ Target an in-app survey to a subset of users by person, group, or cohort properties. Pass one or
+ more rules in groups[].properties[], each with key, value, operator, and an optional type. Use this
+ instead of conditions for property targeting. Do not use this for external_survey forms.
enable_iframe_embedding:
description: >
Allows an external_survey form to be embedded in an iframe. Use only when the user explicitly asks
@@ -132,8 +134,9 @@ tools:
enrich_url: '{id}'
title: Get a specific survey by ID.
description: >
- Get a specific survey by ID. Returns the survey configuration including questions, targeting, and scheduling
- details.
+ Get a specific survey by ID. Returns its questions, targeting flag — including current property targeting
+ rules under targeting_flag.filters — and scheduling details. To change targeting, use targeting_flag_filters
+ with survey-update.
ui_app: survey
survey-launch:
operation: surveys_launch
@@ -234,9 +237,17 @@ tools:
question list. New questions should omit id. Do not regenerate existing questions from scratch.
conditions:
description: >
- Complete replacement display and targeting conditions object. Do not provide this field unless
- changing display targeting. Preserve existing URL, selector, event, device, wait-period, and linked
- flag variant conditions unless explicitly changing them.
+ Complete replacement display conditions object. Do not provide this field unless changing display
+ targeting. Use targeting_flag_filters for person, group, or cohort property targeting. Preserve
+ existing URL, selector, event, device, wait-period, and linked flag variant conditions unless
+ explicitly changing them.
+ targeting_flag_filters:
+ description: >
+ Update an in-app survey's person, group, or cohort property targeting. Pass rules in
+ groups[].properties[], each with key, value, operator, and an optional type. Use this instead of
+ conditions for property targeting. Complete replacement: fetch the survey first, start from
+ targeting_flag.filters, and send the full groups list — omitted groups are removed. Do not use this
+ for external_survey forms.
translations:
description: >
Complete replacement survey-level translations object. Do not provide this field unless changing
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index e489a7198b01..bb828645f131 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -10325,7 +10325,7 @@
}
},
"survey-get": {
- "description": "Get a specific survey by ID. Returns the survey configuration including questions, targeting, and scheduling details.",
+ "description": "Get a specific survey by ID. Returns its questions, targeting flag — including current property targeting rules under targeting_flag.filters — and scheduling details. To change targeting, use targeting_flag_filters with survey-update.",
"category": "Surveys",
"feature": "surveys",
"summary": "Get a specific survey by ID.",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 7abe9b940320..901a40312925 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -10866,7 +10866,7 @@
}
},
"survey-get": {
- "description": "Get a specific survey by ID. Returns the survey configuration including questions, targeting, and scheduling details.",
+ "description": "Get a specific survey by ID. Returns its questions, targeting flag — including current property targeting rules under targeting_flag.filters — and scheduling details. To change targeting, use targeting_flag_filters with survey-update.",
"category": "Surveys",
"feature": "surveys",
"summary": "Get a specific survey by ID.",
diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.json
index 2830b38555da..c28ec84ee3eb 100644
--- a/services/mcp/schema/tool-definitions.json
+++ b/services/mcp/schema/tool-definitions.json
@@ -515,7 +515,7 @@
}
},
"survey-get": {
- "description": "Get a specific survey by ID. Returns the survey configuration including questions, targeting, and scheduling details.",
+ "description": "Get a specific survey by ID. Returns its questions, targeting flag — including current property targeting rules under targeting_flag.filters — and scheduling details. To change targeting, use targeting_flag_filters with survey-update.",
"category": "Surveys",
"summary": "Get a specific survey by ID.",
"required_scopes": ["survey:read"],
diff --git a/services/mcp/src/tools/generated/surveys.ts b/services/mcp/src/tools/generated/surveys.ts
index 7817017a5c60..5ff7a6d68591 100644
--- a/services/mcp/src/tools/generated/surveys.ts
+++ b/services/mcp/src/tools/generated/surveys.ts
@@ -51,7 +51,7 @@ const SurveyCreateSchema = SurveysCreateBody.omit({
'Complete survey question list. Prefer 1-3 questions unless the user explicitly asks for a longer survey. Use rating questions for NPS/CSAT, open for freeform feedback, and choice questions when the user wants structured answers. Questions can include inline translations on each question.'
),
conditions: SurveysCreateBody.shape['conditions'].describe(
- 'Display and targeting conditions for in-app surveys, such as URL matching, event triggers, device filters, or linked flag variants. Do not use URL, selector, event, device, or linkedFlagVariant conditions for external_survey forms.'
+ 'Display conditions for in-app surveys, such as URL matching, event triggers, device filters, or linked flag variants. To target people, groups, or cohorts by properties, use targeting_flag_filters instead. Do not use URL, selector, event, device, or linkedFlagVariant conditions for external_survey forms.'
),
start_date: SurveysCreateBody.shape['start_date'].describe(
'Setting this launches the survey immediately. Leave unset unless the user explicitly asks to launch now.'
@@ -60,7 +60,7 @@ const SurveyCreateSchema = SurveysCreateBody.omit({
'Feature flag ID linked to this survey. Use only when the user explicitly wants the survey linked to a feature flag. Resolve the flag ID first, preferably with SQL in v2.'
),
targeting_flag_filters: SurveysCreateBody.shape['targeting_flag_filters'].describe(
- 'User targeting rules for in-app surveys. Use only when the user wants the survey shown to a subset of users. Do not use this for external_survey forms.'
+ 'Target an in-app survey to a subset of users by person, group, or cohort properties. Pass one or more rules in groups[].properties[], each with key, value, operator, and an optional type. Use this instead of conditions for property targeting. Do not use this for external_survey forms.'
),
enable_iframe_embedding: SurveysCreateBody.shape['enable_iframe_embedding'].describe(
'Allows an external_survey form to be embedded in an iframe. Use only when the user explicitly asks for iframe embedding.'
@@ -251,7 +251,10 @@ const SurveyUpdateSchema = SurveysPartialUpdateParams.omit({ project_id: true })
"Complete replacement question list. Existing question IDs are tied to response data and must be preserved. Before sending this field, fetch the survey first, modify the existing question objects in place, keep every unchanged or edited question's id, and include the complete intended ordered question list. New questions should omit id. Do not regenerate existing questions from scratch."
),
conditions: SurveysPartialUpdateBody.shape['conditions'].describe(
- 'Complete replacement display and targeting conditions object. Do not provide this field unless changing display targeting. Preserve existing URL, selector, event, device, wait-period, and linked flag variant conditions unless explicitly changing them.'
+ 'Complete replacement display conditions object. Do not provide this field unless changing display targeting. Use targeting_flag_filters for person, group, or cohort property targeting. Preserve existing URL, selector, event, device, wait-period, and linked flag variant conditions unless explicitly changing them.'
+ ),
+ targeting_flag_filters: SurveysPartialUpdateBody.shape['targeting_flag_filters'].describe(
+ "Update an in-app survey's person, group, or cohort property targeting. Pass rules in groups[].properties[], each with key, value, operator, and an optional type. Use this instead of conditions for property targeting. Complete replacement: fetch the survey first, start from targeting_flag.filters, and send the full groups list — omitted groups are removed. Do not use this for external_survey forms."
),
translations: SurveysPartialUpdateBody.shape['translations'].describe(
'Complete replacement survey-level translations object. Do not provide this field unless changing translations. Preserve existing language keys and translated fields that should remain. Use null only when the user explicitly asks to remove survey-level translations.'
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-create.json
index e93919e2868b..3c6410c666dc 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-create.json
@@ -181,7 +181,7 @@
"type": "null"
}
],
- "description": "Display and targeting conditions for in-app surveys, such as URL matching, event triggers, device filters, or linked flag variants. Do not use URL, selector, event, device, or linkedFlagVariant conditions for external_survey forms."
+ "description": "Display conditions for in-app surveys, such as URL matching, event triggers, device filters, or linked flag variants. To target people, groups, or cohorts by properties, use targeting_flag_filters instead. Do not use URL, selector, event, device, or linkedFlagVariant conditions for external_survey forms."
},
"description": {
"description": "Survey description. Internal only: unlike the name and questions, it is never delivered to visitors.",
@@ -1178,7 +1178,7 @@
"type": "null"
}
],
- "description": "User targeting rules for in-app surveys. Use only when the user wants the survey shown to a subset of users. Do not use this for external_survey forms."
+ "description": "Target an in-app survey to a subset of users by person, group, or cohort properties. Pass one or more rules in groups[].properties[], each with key, value, operator, and an optional type. Use this instead of conditions for property targeting. Do not use this for external_survey forms."
},
"translations": {
"description": "Optional survey-level translations keyed by language code. Use for translated survey name, description, and thank-you message fields. Question text translations belong inside each question's translations object."
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-update.json
index 494f3d1657fd..ab8dd36911ec 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/survey-update.json
@@ -185,7 +185,7 @@
"type": "null"
}
],
- "description": "Complete replacement display and targeting conditions object. Do not provide this field unless changing display targeting. Preserve existing URL, selector, event, device, wait-period, and linked flag variant conditions unless explicitly changing them."
+ "description": "Complete replacement display conditions object. Do not provide this field unless changing display targeting. Use targeting_flag_filters for person, group, or cohort property targeting. Preserve existing URL, selector, event, device, wait-period, and linked flag variant conditions unless explicitly changing them."
},
"description": {
"description": "Survey description. Internal only: unlike the name and questions, it is never delivered to visitors.",
@@ -1209,7 +1209,7 @@
"type": "null"
}
],
- "description": "Target specific users based on their properties. Example: {groups: [{properties: [{key: 'email', value: ['@company.com'], operator: 'icontains'}], rollout_percentage: 100}]}"
+ "description": "Update an in-app survey's person, group, or cohort property targeting. Pass rules in groups[].properties[], each with key, value, operator, and an optional type. Use this instead of conditions for property targeting. Complete replacement: fetch the survey first, start from targeting_flag.filters, and send the full groups list — omitted groups are removed. Do not use this for external_survey forms."
},
"targeting_flag_id": {
"description": "An existing targeting flag to use for this survey.",