Use product analytics over PostHog MCP

Contents

The PostHog MCP server gives your AI coding agent direct access to your analytics. Query trends, funnels, retention, and custom SQL, and create or update saved insights and dashboards – all from your code editor.

This works in any MCP client: Cursor, Codex, Claude Code, Windsurf, VS Code, and others.

What you can do here

  • Check feature performance before making code changes – "How many users are using the new search feature this week?"
  • Pull conversion rates into your workflow – "What's the funnel conversion from signup to first project?"
  • Investigate metric changes – "Did the login success rate change after last Tuesday's deploy?"
  • Build insights on demand – "Create a trend showing daily active users broken down by plan."
  • Drill into the people behind a number – every query type has an actors variant that lists the individual persons.

Query tools

Each insight type has its own tool, plus an actors variant that lists the persons behind a specific data point.

ToolDescription
query-trendsRun a trends query and return the series.
query-trends-actorsList persons behind a trends data point.
query-funnelRun a funnel query and return step conversion.
query-funnel-actorsList persons who converted through or dropped off at a step.
query-retentionRun a retention query and return the cohort grid.
query-retention-actorsList persons in a retention cohort.
query-pathsRun a user paths query.
query-paths-actorsList persons who followed a specific path.
query-stickinessRun a stickiness query.
query-stickiness-actorsList persons at a stickiness level.
query-lifecycleRun a lifecycle query.
query-lifecycle-actorsList persons in a lifecycle stage.
execute-sqlRun an arbitrary SQL query against your events and warehouse data.
read-data-schemaRead the available tables, columns, and event properties.

The funnel actors tool supports two modes: step mode, where a positive funnelStep means converted and a negative one means dropped off (1-based), and trends-dropoff mode, using funnelTrendsDropOff with funnelTrendsEntrancePeriodStart for funnel-trends visualizations.

Insight tools

ToolDescription
insight-createCreate a saved insight from a query.
insight-getGet details for a specific insight by ID.
insight-queryRun the query behind a saved insight and return fresh results.
insight-updateUpdate a saved insight's name, description, or query.
insight-deleteDelete a saved insight.
insights-listList insights in the project, filtered by name or type.
insights-trending-retrieveGet the insights your team looks at most.
insights-activity-retrieveGet the activity log for an insight.

Dashboard tools

ToolDescription
dashboard-createCreate a new dashboard.
dashboard-getGet a dashboard and its tiles.
dashboards-get-allList all dashboards in the project.
dashboard-updateUpdate a dashboard's name or description.
dashboard-deleteDelete a dashboard.
dashboard-widgets-batch-addAdd insights to a dashboard in one call.
dashboard-insights-runRun every insight on a dashboard.

Example prompts

Try these with your MCP-enabled agent:

  • How is the new checkout flow performing compared to last week?
  • Show me the top 10 events by volume today.
  • Create a funnel from user_signed_up to project_created to insight_viewed.
  • What's the retention rate for users who completed onboarding?
  • Run a SQL query to find the most active users by event count this month.

Customize chart display

When creating or updating SQL-backed insights, you can configure per-series display settings and number formatting on each Y-axis column.

Per-series display – set on each Y-axis column under settings.display:

SettingValuesDescription
yAxisPositionleft, rightWhich Y axis the series uses. Use right for a secondary axis.
displayTypeauto, line, bar, areaOverride the chart-level display for this series. Mix types by setting different values per column.
trendLinetrue, falseDraw a linear trend line for the series.
labelstringCustom label shown in the legend and tooltips instead of the column name.
colorhex string (e.g. #1d4aff)Custom color for the series.

Number formatting – set on each Y-axis column under settings.formatting:

SettingValuesDescription
stylenone, number, short, percentNumber format style. number adds thousands separators, short abbreviates (1.2k, 3.4M).
prefixstringText prepended to values (e.g. $).
suffixstringText appended to values (e.g. % or ms).
decimalPlacesnumberNumber of decimal places to display.

Chart-level settings – set on the DataVisualization node:

SettingValuesDescription
showValuesOnSeriestrue, falseShow values on each data point in the chart.

Example prompts:

  • Create a SQL chart of daily revenue with values formatted as dollars and a trend line.
  • Update insight 123 to show the conversion rate series as a line and the volume series as bars.

Install the MCP server

The recommended way to install is with the AI wizard:

Terminal
npx @posthog/wizard mcp add

The wizard supports Claude, Cursor, Windsurf, VS Code, and more. You can also configure it manually.

See the MCP server docs for full setup instructions.

  • Build the same insights by hand in the web app.
  • Pull results into your own systems with the API.

Community questions

Was this page useful?