Connect PostHog to your AI chat agent

Product analytics questions rarely fit a fixed report menu. HogQL, PostHog's own query language, lets your agent ask whatever you'd actually ask.

SourcetoMCP connects it straight to Claude, ChatGPT, or any MCP-compatible agent, so it can query real events and people, check feature flags, and turn one on or off, instead of guessing.

Agent asks

What's our week-over-week signup trend?

1,382 signups this week vs 1,190 last week, up 16%. Query: events where event = 'signed_up', grouped by week.

Agent asks

Turn off the new-checkout-flow flag for everyone.

new-checkout-flow is now inactive. Confirmed by reading its real state back from PostHog.

Why PostHog data matters for your agent

Product questions don't come pre-shaped into the handful of report types most analytics tools offer. Your agent should be able to ask the actual question, not the closest canned approximation of it.

  • A real query language, not a report picker. HogQL covers trends, funnels, breakdowns, and retention-shaped questions in one general capability, instead of a fixed menu that never quite matches what you actually want to know.
  • People, not just aggregate numbers. Ask about a specific user by name, email, or distinct id and get their real profile back, not just a count they contributed to.
  • Feature flags your agent can actually see and use. Check what's live, and turn something off the moment it looks wrong, in the same conversation where you noticed it.
  • Deliberately narrow write access. The only thing your agent can change is a flag's on/off switch — never who it targets, never its rollout percentage.

How it works

1

Connect PostHog. Paste a Personal API Key from your PostHog account settings, pick US Cloud, EU Cloud, or your self-hosted URL, and choose which project your agent can access.

2

Your agent asks in plain language. It writes the HogQL query, or calls the right lookup, behind the scenes and gets real data back, never a guess.

3

Every answer shows its work. Structured rows come back keyed by the query's own columns, so you can see exactly what was asked, not just take the summary on faith.

posthog.query

SELECT event, count() FROM events ... GROUP BY event

eventcount()
$pageview48,204
signed_up1,382
checkout_completed969
See it work

Ask about your PostHog data. Get real answers back.

master — ✳ Claude Code — claude — 120×30
Claude Code v2.1.224
Sonnet 5 · Claude Pro
/Users/master
⚠ 1 MCP server needs authentication · run /mcp
| Using Sonnet 5 (from .claude/settings.json) · /model
  +1 more · /status
master Sonnet 5
‖ manual mode on

Built for real questions, not a fixed report menu

Query with HogQL, not a fixed report menu

Your agent writes a real query against your events, persons, and sessions — trends, funnels, breakdowns, retention-shaped questions — anything expressible as a SELECT, not a curated list of canned report types.

Look up any person

Search by name, email, or distinct id and get back their full profile: every property, every merged device id, first and last seen.

See every feature flag's real state

Key, name, active or archived, and the raw release-condition configuration — rollout percentage and targeted groups — not a simplified guess at what's live.

Turn a flag on or off from the conversation

Ask your agent to disable a flag and it does, immediately, then reads back the real post-change state rather than assuming the request worked.

Safety by default on the one write action

Toggling a flag only ever changes whether it's on — never its targeting, rollout percentage, or who it's shown to. There's no ambiguous default: you say active or inactive.

Connects with your own API key, not an OAuth app

Paste a personal API key scoped to exactly what you want to grant. No app to approve, no consent screen — revoke it from PostHog whenever you want.

Works with Cloud or self-hosted

US Cloud, EU Cloud, or your own self-hosted instance's URL — same connector either way.

Real answers, not hallucinated schemas

Every query runs against your actual project. If an event or property doesn't exist, your agent finds that out from PostHog, not by guessing.

No canned prompts needed, just ask

PostHog doesn't have dedicated entries in the Prompt Library yet, but your agent doesn't need them. It already has direct access to your events, people, and feature flags through the operations above, so you can ask in your own words from day one.

PostHog MCP FAQ

Common questions from teams connecting PostHog to an agent.

Anything expressible as a HogQL query against your events, persons, and sessions, plus dedicated lookups for people and feature flags, and the ability to turn a feature flag on or off: 4 registered operations in total.

Claude, ChatGPT, Cursor, or any MCP-compatible client. Connect once from your dashboard's "Connect an agent" page and every tool you've paired can use it.

No. PostHog doesn't use an OAuth app for this the way most of our other connectors do — you paste a Personal API Key from your own PostHog account settings, scoped to whatever projects that key can already see, and revoke it from PostHog any time.

In one narrow way: it can turn an existing feature flag on or off. It can't create new flags, and it can't change who a flag targets (release conditions, rollout percentage). Nothing else in PostHog is written to.

Real data. HogQL queries run directly against your project's own events, persons, and sessions tables — the same data PostHog's own product uses, not a pre-aggregated summary.

Yes. When connecting, choose US Cloud, EU Cloud, or enter your own self-hosted instance's URL.

PostHog is available on paid plans. See Pricing for how many connections each plan includes.

Securely connect your PostHog to AI chat agents.

Connect your first source in minutes.