Cédric Rittié

PostHog
MCP · Analytics

PostHog

PostHog's official MCP exposes 27+ tools to query your analytics project in plain English. Claude reads events, creates feature flags, lists errors, generates insights. Useful whenever you want to understand a behavior without leaving the terminal.

Official docsFree (up to 1M events/month)

Use cases

  • Answer an analytics question without opening the dashboard
  • Create a feature flag with progressive rollout from Claude
  • Investigate a regression: which users, pages, errors

Installation

1.Generate a Personal API Key in PostHog: Settings → Personal API keys → Create key. Recommended scopes: read on projects, feature_flag and query.

2.One line, one terminal
$ claude mcp add posthog -- npx -y @posthog/mcp-server --api-key=YOUR_KEY

Replace YOUR_KEY with your key. Restart Claude Code then check with /mcp (you should see posthog in the list).

Need to install Claude Code first? See the Claude Code page · Official docs

Concrete examples

"Combien de visiteurs uniques sur cedricrittie.com cette semaine, et quelle est la page la plus vue ?"

Claude calls two MCP tools: trends-get (unique users over 7 days) and insights-query (top pages). Returns raw numbers plus a micro-analysis.

Sample output
→ Calling posthog.trends_get (event=$pageview, interval=week)
→ Calling posthog.insights_query (top pages, 7d)

Unique visitors (last 7 days): 1,247 (+18% vs previous week)

Top 5 pages
1. /en/blog/claude-code-skills           342 views
2. /en                                   298 views
3. /en/resources                         187 views
4. /en/blog/mcp-connect-claude-tools     156 views
5. /en/path                               92 views

Note: the Skills article concentrates 27% of traffic. The MCP article is
climbing steadily since its publication 12 days ago.
"Crée un feature flag 'new-onboarding' actif à 10% sur les users US, et explique-moi ce que j'ai créé."

Claude calls feature_flag_create with a progressive rollout conditional on geography. Returns the final config and a plain-English summary.

Sample output
→ Calling posthog.feature_flag_create
   name: "new-onboarding"
   rollout: 10%
   filter: user.country == "US"

✓ Feature flag created (id 8412)

Summary: the 'new-onboarding' flag is active for 10% of users located in
the United States. Other users (outside the US + the remaining 90% of US
users) see the old flow. The flag is editable without a code redeploy:
change the rollout or condition directly in PostHog.
"Investigue la chute de conversion sur /pricing entre hier et aujourd'hui."

Claude cross-references events (pageviews), errors (JS/API errors) and session_recordings to pinpoint the likely cause. Combines 3 MCP tools in one investigation.

Sample output
→ Analysis window: rolling 24h vs previous 24h

Funnel /pricing → checkout: 8.2% (previous 12.4%). Drop of -34%.

Errors found
- Stripe.js error "Invalid publishable key": 47 occurrences since 4pm yesterday
- Blocks the "Pay" button with no visible message to the user

Related sessions (3 sampled replays): user clicks, nothing happens,
abandons after 12-20 seconds.

Hypothesis: your Stripe key was rotated or expired yesterday around 4pm.
Check the Stripe dashboard and redeploy with the new key. The fix should
restore conversion to normal levels within 24h.