Analytics

Connect PostHog to AI Agents

Connect PostHog and ask about your events and people using PostHog's own HogQL, look up feature flags, or have an agent turn one on or off, in plain English.

What you'll need

  • A PostHog account, on Cloud US, Cloud EU, or your own self-hosted instance.
  • A Personal API Key scoped to Query, Person and Feature Flag read access, plus Feature Flag write access if you want an agent to toggle flags.

PostHog connects with that key, not OAuth. PostHog has no third-party app to authorize.

Connect it

Generate a Personal API Key
In PostHog, go to your account menu, then Settings, then Personal API Keys, and create one with the scopes above.
Open Connectors
In your SourcetoMCP dashboard, go to Connectors and choose Add Connection, then PostHog.
Paste your key and pick your host
SourcetoMCP verifies it against PostHog.
Confirm
The connection shows up as Connected in your Connectors table.

The one write is narrow: it only flips a feature flag's active switch. It can't change who a flag targets, its rollout percentage, or its key or name. An archived flag can be found and turned off, but PostHog itself refuses to turn one on until it's unarchived.

Try it

  • "How many signups came from our checkout flow this week?"
  • "Look up this person by email and show me their recent events."
  • "List every active feature flag and when each one was last changed."
  • "Did this flag's rollout hurt checkout conversion? If so, turn it off."
  • "Find flags stuck at 100% rollout that have been on for months."

Join it with other sources

"Compare PostHog signups with Google Ads spend for the campaigns that drove them."

Troubleshooting

SymptomLikely fix
Reads work but toggling a flag failsYour key needs Feature Flag write access specifically. Generate a new one with that scope added and reconnect.
A query times out on a large date rangePostHog itself allows a query up to 10 minutes, but SourcetoMCP's own ceiling is much shorter. Narrow the range or add filters.
A flag won't turn onExpected if it's archived. Unarchive it in PostHog first, this connector can't do that step.

Related