Integrations

How to connect PostHog to AI agents?

Connect PostHog to Sequel and ask about your product analytics in plain English — events, funnels, retention, active users, cohorts, and saved insights — from the Sequel app or any AI tool wired up to the MCP server. Sequel writes HogQL (PostHog's SQL dialect) under the hood, only ever reads, and can join PostHog with your other connected sources.

What you'll need

  • A PostHog account (PostHog Cloud or self-hosted).
  • A Personal API key with read-only scopes: query:read, event_definitions:read, property_definitions:read, insight:read, cohort:read, project:read.
  • Your hosthttps://us.posthog.com for US Cloud (default), https://eu.posthog.com for EU Cloud, or your self-hosted base URL (no trailing slash).
  • Your numeric project ID — found in your PostHog URL: app.posthog.com/project/<id>.

Read-only by design

The PostHog connector ships only read tools (HogQL query, list events, list properties, list insights, list cohorts). Granting the Personal API key read-only scopes means Sequel can't create or change insights, dashboards, cohorts, or feature flags — even in principle. Rotate or revoke the key from PostHog Settings at any time.

Connect it

Open a new connection

In the Sequel dashboard, go to Connections → New connection and choose PostHog.

Create a Personal API key

In PostHog, go to Settings → Personal API Keys → Create personal API key. Grant the read-only scopes: query:read, event_definitions:read, property_definitions:read, insight:read, cohort:read, and project:read. Copy the key — PostHog only shows it once.

Enter your key, host, and project ID

Paste the API key into Sequel, set the host (US Cloud, EU Cloud, or your self-hosted base URL), and enter your numeric project ID from the PostHog URL.

Test and save

Sequel verifies the credentials against your project and confirms the connection by name. A green check means it's live.

What you can query

Sequel exposes PostHog's product-analytics data as read-only tools:

  • HogQL queries — arbitrary SQL against the events, persons, sessions, groups, and cohort_people tables for counts, funnels, retention, MAU/DAU, and property breakdowns.
  • Event definitions — event names with first-/last-seen timestamps and 30-day volume, so the agent uses the events you actually track.
  • Property definitions — event and person properties with type info to compose accurate HogQL.
  • Insights — saved trends, funnels, and retention insights the team has already built.
  • Cohorts — saved user segments, referenceable from HogQL as person_id IN COHORT <id>.

Try it

  • "How many unique users triggered $pageview yesterday, by country?"
  • "Show me the signup → activation funnel for users created in the last 30 days."
  • "What's the 7-day retention of users in the 'Power users' cohort?"
  • "Show me daily active users, broken down by self-serve vs sales-led signup."

Join it with other sources

PostHog is most powerful next to your accounts and revenue data. With Postgres also connected, ask:

"For accounts in our Postgres customers table on the Pro plan, what's their 30-day active usage of the checkout flow in PostHog?"

Troubleshooting

SymptomLikely fix
Invalid or unauthorized keyRe-check the key for typos, or create a fresh Personal API key in PostHog with the required read scopes and paste it again.
Connection fails or returns the wrong projectConfirm the host matches your region — us.posthog.com vs eu.posthog.com (or your self-hosted base URL, no trailing slash).
Queries return no dataVerify the numeric project ID is correct and that data exists in the date range you're asking about.