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. It sits on the same connection as your ad accounts, Search Console and Google Analytics, so one question can cross all of them: what a campaign cost, what it sent you, and what those people then did in the product.

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 question you actually have, in the shape you have it.

  • A real query language. HogQL covers trends, funnels, breakdowns, and retention-shaped questions in one general capability, so you are never stuck with the closest item on a fixed menu.
  • People, as well as aggregate numbers. Ask about a specific user by name, email, or distinct id and get their real profile back, with every property and merged device id on it.
  • 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. Who it targets and its rollout percentage stay put.

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.

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 instead of taking the summary on faith.

Event counts

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 whatever you actually want to ask

hogql

Query your data with real HogQL

Your agent writes a SELECT against your events, persons, and sessions, so trends, funnels, breakdowns, and retention-shaped questions all come from the same operation.

persons

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.

feature flags

See every feature flag's real state

Key, name, active or archived, and the raw release-condition configuration, including rollout percentage and targeted groups, exactly as PostHog stores it.

flag toggle

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.

1 write op

Safety by default on the one write action

Toggling a flag only ever changes whether it is on. Its targeting, rollout percentage, and audience stay exactly as they were, and you say active or inactive rather than relying on a default.

api key

Connects with your own API key

Paste a personal API key scoped to exactly what you want to grant. There is no app to approve and no consent screen, and you can revoke the key from PostHog whenever you want.

us · eu · self-hosted

Works with Cloud or self-hosted

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

real schema

Answers that match your real project

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

Real prompts teams run against PostHog

Every SourcetoMCP account gets these in the Prompt Library, ready to run against your own connected PostHog project.

Feature flag management

  • PostHog Feature Flag Regression Kill Switch
  • PostHog Stale Feature Flag Audit

Ask anything else

Your agent can call these operations directly too, querying events, people, and flags in your own words. The library is a starting point.

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.

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.