:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
# MCP tool definitions. Tools are opt-in: an operation is exposed only when it has an entry here.
# List operations without an entry: pnpm --filter=@posthog/mcp run scaffold-yaml -- --candidates --product surveys
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product surveys
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: Surveys
feature: surveys
url_prefix: /surveys
ui_apps:
survey:
type: detail
view_prop: survey
survey-list:
type: list
detail_tool: survey-get
detail_args: '{ id: item.id }'
survey-stats:
type: detail
view_prop: data
survey-global-stats:
type: detail
view_prop: data
data_type: SurveyStatsData
view_component: SurveyStatsView
tools:
survey-create:
operation: surveys_create
enabled: true
scopes:
- survey:write
annotations:
readOnly: false
destructive: false
idempotent: false
enrich_url: '{id}'
title: Creates a new survey in the project.
description: >
Creates a new survey in the project. For the draft, targeting, preview, and launch workflow, load the
creating-surveys skill when available. Use this for both in-app surveys and hosted forms. Prefer draft
creation by default and do not set start_date unless the user explicitly asks to launch immediately. For
in-app surveys, popover is the default unless the user asks for widget or api. For hosted forms, use
external_survey. Keep surveys short unless the user asks for a longer flow. Survey content is public: anyone
can read the name, questions, and appearance text. In-app surveys send them to every visitor's browser, and
a hosted survey shows them on its public page. Tell the user before putting a customer name or other private
detail in a survey. For substantial visual changes, preview the final draft once before launch if browser
access is already available. Skip browser checks for small edits.
include_params:
- name
- description
- type
- schedule
- questions
- conditions
- appearance
- start_date
- responses_limit
- iteration_count
- iteration_frequency_days
- enable_partial_responses
- enable_iframe_embedding
- linked_flag_id
- targeting_flag_filters
- translations
- form_content
param_overrides:
appearance:
description: >
Optional appearance customization. Omit this to keep the default styling. whiteLabel=true requires
the organization to have the white-labelling entitlement (Enterprise); leave it unset unless
requested and available. surveyPopupDelaySeconds must be non-negative.
type:
description: >
Survey type. Use popover for most in-app surveys, widget for always-available feedback entrypoints,
external_survey for hosted forms with a shareable public URL, and api only for headless custom
implementations.
schedule:
description: >
How often a person can see the survey. Omit this to use the default once behavior. Use recurring
only when the user explicitly asks for a repeated schedule, and set iteration_count and
iteration_frequency_days with it. Use always when the user wants the survey to show every time its
display conditions are met, also after the person responds or dismisses it. The survey editor calls
this "Every time the display conditions are met". An always popover without display conditions or a
wait period shows again and again, so suggest a URL condition or seenSurveyWaitPeriodInDays.
questions:
description: >
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:
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.
start_date:
description: >
Setting this launches the survey immediately. Leave unset unless the user explicitly asks to launch
now.
linked_flag_id:
description: >
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:
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. Cohorts
with behavioral filters cannot be used directly. Use a supported static cohort snapshot only with
user approval; never remove targeting rules to work around validation.
enable_iframe_embedding:
description: >
Allows an external_survey form to be embedded in an iframe. Use only when the user explicitly asks
for iframe embedding.
translations:
description: >
Optional survey-level translations keyed by language code. Use for translated survey name,
description, thank-you message, and intro screen fields. Question text translations belong inside
each question's translations object.
form_content:
description: >
Optional hosted-form content configuration for external_survey forms. Only include this when the
user explicitly asks to customize the hosted form content beyond the standard question flow.
ui_app: survey
survey-delete:
operation: surveys_destroy
enabled: true
scopes:
- survey:write
annotations:
readOnly: false
destructive: true
idempotent: true
title: Delete a survey by ID.
description: |
Delete a survey by ID (soft delete - marks as archived).
param_overrides:
id:
aliases:
- survey_id
- surveyId
soft_delete: archived
survey-get:
operation: surveys_retrieve
enabled: true
scopes:
- survey:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{id}'
title: Get a specific survey by ID.
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.
param_overrides:
id:
aliases:
- survey_id
- surveyId
ui_app: survey
survey-launch:
operation: surveys_launch
enabled: true
scopes:
- survey:write
annotations:
readOnly: false
destructive: false
idempotent: true
enrich_url: '{id}'
title: Launch a survey now.
description: >
Launch a survey by setting `start_date` to the current time. Prefer this over `survey-update` with a manual
`start_date` — it's an explicit lifecycle action and self-documenting in activity logs. No-op if the survey
is already launched. Archived surveys must be unarchived first. Surveys with an end_date in the past must
have that date cleared or extended before launch; do this only when the user asks to reopen the survey.
param_overrides:
id:
aliases:
- survey_id
- surveyId
ui_app: survey
survey-stats:
operation: surveys_stats_retrieve
enabled: true
scopes:
- survey:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{survey_id}'
title: Get response statistics for a specific survey.
description: >
Get response statistics for a specific survey. Includes detailed event counts (shown, dismissed, sent),
unique respondents, conversion rates, and timing data. Supports optional date filtering.
param_overrides:
id:
aliases:
- survey_id
- surveyId
ui_app: survey-stats
survey-stop:
operation: surveys_stop
enabled: true
scopes:
- survey:write
annotations:
readOnly: false
destructive: false
idempotent: true
enrich_url: '{id}'
title: Stop a survey now.
description: >
Stop a survey by setting `end_date` to the current time. No new responses are accepted after this; existing
responses remain available. Prefer this over `survey-update` with a manual `end_date`. No-op if the survey
already has an end_date in the past. To hide the survey from the list, archive it via `survey-update` with
`archived=true` instead.
param_overrides:
id:
aliases:
- survey_id
- surveyId
ui_app: survey
survey-update:
operation: surveys_partial_update
enabled: true
scopes:
- survey:write
annotations:
readOnly: false
destructive: false
idempotent: true
enrich_url: '{id}'
title: Update an existing survey by ID.
description: >
Update an existing survey by ID. Omitted top-level fields are preserved, but nested objects and arrays you
provide may replace existing values. Before changing questions, conditions, appearance, targeting,
translations, or hosted-form content, retrieve the survey first and preserve fields that should remain. Do
not send null to clear a field unless the user explicitly asked to remove it. Survey content is public:
anyone can read the name, questions, and appearance text. In-app surveys send them to every visitor's
browser, and a hosted survey shows them on its public page. Tell the user before putting a customer name or
other private detail in a survey. For substantial visual changes, preview the final survey once if browser
access is already available. Skip browser checks for small edits.
include_params:
- id
- name
- description
- type
- questions
- appearance
- conditions
- schedule
- start_date
- end_date
- archived
- responses_limit
- iteration_count
- iteration_frequency_days
- enable_partial_responses
- enable_iframe_embedding
- linked_flag_id
- targeting_flag_id
- targeting_flag_filters
- remove_targeting_flag
- translations
- form_content
param_overrides:
id:
aliases:
- survey_id
- surveyId
appearance:
description: >
Optional appearance customization. Omit this to preserve current styling. When changing it, fetch
the survey first and preserve existing appearance fields. whiteLabel=true requires the organization
to have the white-labelling entitlement (Enterprise); leave it unset unless requested and available.
surveyPopupDelaySeconds must be non-negative.
schedule:
description: >
How often a person can see the survey: once, recurring, or always. Omit this to keep the current
schedule. When setting recurring, also set iteration_count and iteration_frequency_days. Use always
when the user wants the survey to show every time its display conditions are met, also after the
person responds or dismisses it. The survey editor calls this "Every time the display conditions are
met". When you change away from recurring, the iteration fields are cleared. An always popover
without display conditions or a wait period shows again and again, so suggest a URL condition or
seenSurveyWaitPeriodInDays.
questions:
description: >
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:
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.
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. Cohorts with behavioral filters cannot be used directly. Use a supported
static cohort snapshot only with user approval; never remove targeting rules to work around
validation.
translations:
description: >
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.
form_content:
description: >
Hosted-form content configuration for external_survey forms. Do not provide this field unless
editing hosted-form content. Preserve existing content fields that should remain.
ui_app: survey
surveys-get-all:
operation: surveys_list
enabled: true
scopes:
- survey:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{id}'
list: true
title: List surveys in the project (server-side search + filters).
description: >
List surveys in the project. Use `search` for fuzzy match against survey name and description (handles typos
and prefix-as-you-type). Use `type` to filter by survey kind (popover, widget, external_survey, api). Use
`archived` to filter archived state. Combine with pagination via `limit`/`offset`.
Companion tools to avoid the recon-loop pattern: - For individual response rows: surveys-responses-list -
For aggregate event counts: surveys-stats (single survey) or surveys-global-stats (project-wide)
ui_app: survey-list
surveys-global-stats:
operation: surveys_global_stats_retrieve
enabled: true
scopes:
- survey:read
annotations:
readOnly: true
destructive: false
idempotent: true
title: Get aggregated response statistics across all surveys.
description: >
Get aggregated response statistics across all surveys in the project. Includes event counts (shown,
dismissed, sent), unique respondents, conversion rates, and timing data. Supports optional date filtering.
ui_app: survey-global-stats
surveys-responses-list:
operation: surveys_responses_list
enabled: true
scopes:
- survey:read
- query:read
annotations:
readOnly: true
destructive: false
idempotent: true
title: List individual survey responses with resolved question text.
description: >
List individual responses for a specific survey. Question text is already resolved server-side — callers do
not need to map opaque $survey_response_<id> property keys. Each row carries distinct_id, session_id, and
submitted_at so agents can pivot to recordings, persons, or paths in one follow-up call. Use this instead of
executing raw SQL against `survey sent` events.
Common patterns: - NPS detractors: question_id=<rating question id> + score_lte=6 - Voice-of-customer
mining: question_id=<open question id> + since=<date> - Per-respondent context: read distinct_id from a row,
then pull recordings or events for that user.
For person properties on respondents, follow up with persons-get using the row's distinct_id — this tool
only requires survey:read scope and intentionally doesn't return person data inline. Use limit/offset and
the has_more field to paginate. For surveys with many thousands of responses, prefer scoping with `since` /
`until` over deep offset paging (ClickHouse offset cost grows with skipped rows, and new responses arriving
between pages can shift boundaries).
param_overrides:
id:
aliases:
- survey_id
- surveyId
ui_app: survey-stats
surveys-summarize-responses-create:
operation: surveys_summarize_responses_create
enabled: true
scopes:
- survey:read
annotations:
readOnly: true
destructive: false
idempotent: false
title: Summarize survey responses (per question, or survey-wide headline).
description: >
Summarize survey responses using PostHog's LLM summarization. Pass question_id (preferred) or question_index
to get a per-question theme summary. Omit both to get the survey-wide headline summary instead — the
endpoint dispatches automatically based on what you pass.
Pass force_refresh=true in the body to bypass cached summaries. Per-question summaries are cached on the
survey object; headline summaries are cached on the survey row.
Use this after you have identified a survey of interest. If you need raw response rows for cross-pivot, use
surveys-responses-list instead.
param_overrides:
id:
aliases:
- survey_id
- surveyId