Connector guide9-minute read28 MCP tools7 languages

How to Connect PostHog to ChatGPT via MCP

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

HCBy HelpCode teamUpdated 9 min read Open-source on GitHub

No credit card · 7-day trial · Self-host alternative available

PostHog

PostHog

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

tools

28

Region

INTL

Category

Analytics

Authentication

Bearer Token

Required env vars

POSTHOG_HOSTPOSTHOG_PERSONAL_API_KEY
Install in one click on Cloud

7-day free trial · No credit card

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Open source · AGPL-3.0
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Skip the install. Get this working in under 2 minutes.

Start a free trial on cloud.anythingmcp.com, add the PostHog in one click, then point your AI client (Claude, ChatGPT, Copilot or Cursor) at the generated MCP endpoint. No Docker, no git clone, zero engineering experience required.

Start free trial

Summary

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Try asking

Example prompts for PostHog

Click any prompt to copy it. Paste into Claude, ChatGPT, Cursor, Gemini, Copilot or OpenClaw to run it against this connector.

PostHog · live via MCP
Share
Opus 4.7

Claude is AI and can make mistakes. Please double-check responses.

💡 No install? Use cloud.anythingmcp.com directly. Sign in, click Connectors → PostHog, paste your credentials, mint an MCP API key and you're done. No Docker, no git clone, no local server.

PostHog + ChatGPT

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Prerequisites

See the full setup instructions baked into the connector (visible in the in-app store when you select the connector). The required environment variables for this connector are:

POSTHOG_HOST, POSTHOG_PERSONAL_API_KEY

Step 1 — Get credentials

  1. In PostHog, open Settings → User → Personal API keys (US Cloud: https://us.posthog.com/settings/user-api-keys, EU Cloud: https://eu.posthog.com/settings/user-api-keys) and click + Create a personal API key.
  2. Give the key a label (for example "AnythingMCP") and choose its organization and project access: all, one organization, or specific projects. A key limited to specific projects cannot list organizations or projects, but posthog_get_current_user still works and names the current project.
  3. Select these scopes:
    • user:read, organization:read, project:read
    • query:read, person:read, cohort:read, experiment:read
    • insight:read, insight:write, dashboard:read
    • feature_flag:read, feature_flag:write
    • annotation:read, annotation:write
  4. Copy the key right away: PostHog shows it only once. It starts with phx_ (a project token starting with phc_ does not work here). Paste it into POSTHOG_PERSONAL_API_KEY, without the word Bearer.
  5. Set POSTHOG_HOST to the address you open PostHog at: https://us.posthog.com for US Cloud, https://eu.posthog.com for EU Cloud, or your self-hosted address, without a trailing slash or path. The ingestion hosts us.i.posthog.com and eu.i.posthog.com are refused, and a key only works in the cloud region where it was created. Then install the connector.
  6. Start with posthog_get_current_user: it shows which PostHog user the key belongs to, the current project and the projects of the organization.

Read-only setup: create the key with only the :read scopes and switch off posthog_create_insight, posthog_update_insight, posthog_create_feature_flag, posthog_update_feature_flag and posthog_create_annotation. Queries never change data, as HogQL only accepts SELECT. The AI sees and changes exactly what the key's user can.

Switched off at install: posthog_delete_insight, posthog_delete_feature_flag and posthog_delete_annotation. PostHog never hard-deletes through the API: these tools mark the insight, flag or annotation as deleted, and it can be restored in the PostHog app. A deleted flag is switched off, so code that checks its key gets false.

Project ids: every project tool takes project_id, the number in the PostHog URL (/project/12345/...), also shown under Settings → Project → General. @current is accepted too, but it means the project the user last opened in the app, which can change: prefer the number. posthog_list_organizations and posthog_list_projects list the others.

Queries: posthog_run_hogql_query runs one HogQL (PostHog's SQL) SELECT over events, persons, sessions and groups; properties are read as properties.$browser or person.properties.email. Always filter on time (for example WHERE timestamp >= now() - INTERVAL 7 DAY): unfiltered scans are slow and use up the read budget. Without a LIMIT you get 100 rows, with one up to 50,000. OFFSET is refused, so the AI pages by timestamp or id. Date literals are read in the project's timezone, not UTC. For trends, funnels, retention, stickiness, lifecycle and paths there is posthog_run_insight_query; conversion and retention percentages are computed from its count values. The query endpoint is meant for ad hoc analysis, not bulk exports.

Insights, dashboards and flags: posthog_get_insight returns the last cached result by default; refresh blocking recalculates a stale one. posthog_get_dashboard returns the tiles with their insights. Feature flags decide what live users see: before creating or changing one, the AI shows you the flag key, active and the rollout and waits for your yes. A new flag is safest with active false or a rollout of 0. Changes send the flag's version from the last read, so nobody else's change is overwritten.

Pagination: list tools take limit and offset and return count, next (null on the last page) and results. Answers over 200 KB are cut.

Rate limits: they apply per organization and are shared by every key and user. Ordinary reads and writes allow 480 requests a minute and 4,800 an hour; analytics such as persons and insight calculations 240 a minute and 1,200 an hour. The query endpoint allows 240 a minute and 2,400 an hour, at most 3 running queries per project, and draws on an hourly read budget per project (smaller on the free plan). Over a limit PostHog answers 429; an exhausted budget says api_queries_budget_exceeded, while cached results keep working.

Common errors: 401 means the key is wrong, deleted, or from the other cloud region: check POSTHOG_HOST. 403 "API key missing required scope" names the scope to add (you can edit the key's scopes later); other 403s mean the key is limited to other projects or organizations, or the organization does not allow personal API keys for members. 404 "Project not found." is a wrong project_id or one the user cannot see. 400 names the invalid field, and for HogQL carries the parser error. 409 on a flag means its version is stale: read the flag again.

The connector does not capture events or set person properties, delete persons, read session replays or surveys, create or edit dashboards, cohorts and experiments, or manage batch exports, members and billing.

Step 2 — Install the adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

Step 3 — Add the connector in ChatGPT

Your server URL: in AnythingMCP, open MCP Servers → the server this connector is on, and copy its URL (https://cloud.anythingmcp.com/mcp/…). Use it wherever this guide shows YOUR_SERVER_ID.

ChatGPT connects to MCP servers as custom apps in developer mode, available on paid plans (not on Free). On Business and Enterprise workspaces an admin may have to allow it first.

  1. In ChatGPT, open Settings → Security and login and turn on Developer mode.
  2. Go to chatgpt.com/plugins and click +.
  3. Enter a name and a short description, e.g. Name: PostHog.
  4. Under Connection, enter the MCP server URL https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID and create the connection.
  5. When ChatGPT asks, sign in to AnythingMCP (OAuth) and allow access.

Available tools

ToolWhat it does
posthog_get_current_userGet the user the personal API key belongs to: uuid, email and name, the current project (id, name, project_id, timezone), the current…
posthog_list_organizationsList the organizations the user belongs to: id (a UUID), name, slug, membership_level, and each organization's projects
posthog_list_projectsList the projects of an organization: id (the project_id every other tool takes), name, project_id, timezone, tags, is_demo and…
posthog_get_projectGet one project's settings: name, timezone, week_start_day, base_currency, app_urls, test account filters, group types, whether events…
posthog_run_hogql_queryRun one read-only HogQL (PostHog SQL) SELECT over events, persons, sessions, groups or warehouse tables and return columns, results (rows…
posthog_run_insight_queryRun one of PostHog's insight calculations without saving it: TrendsQuery, FunnelsQuery, RetentionQuery, StickinessQuery, LifecycleQuery or…
posthog_list_personsList or search persons (identified users and anonymous visitors): id, uuid, name, distinct_ids, properties, created_at and last_seen_at.…
posthog_get_personGet one person by numeric id or UUID: name, distinct_ids, all person properties (email, initial UTM and referrer, geo), created_at and…
posthog_list_insightsList saved insights (charts): id, short_id, name, description, query, tags, favorited, dashboard_tiles, created_by and last_modified_at
posthog_get_insightGet one insight by numeric id or 8-character short_id: name, description, query, result, columns, last_refresh, is_cached, the hogql it ran…
posthog_create_insightSave a new insight (chart) in the project from a query: a product analytics chart or a SQL insight
posthog_update_insightChange a saved insight: name, description, query, tags or favorited
posthog_delete_insightDelete a saved insight (PostHog marks it deleted; it disappears from every dashboard and can be restored in the app)
posthog_list_dashboardsList dashboards: id, name, description, pinned, tags, created_by, created_at and last_viewed_at
posthog_get_dashboardGet one dashboard with its filters and tiles: each tile carries its insight (id, short_id, name, query and the last cached result) or a…
posthog_list_feature_flagsList feature flags: id, key, name (the description), active, filters (release conditions with rollout_percentage, variants, payloads)…
posthog_get_feature_flagGet one feature flag by id: key, name, active, filters (release condition groups with properties and rollout_percentage, multivariate…
posthog_create_feature_flagCreate a feature flag
posthog_update_feature_flagChange a feature flag: switch it on or off, change its rollout or targeting, rename its description, archive it or retag it
posthog_delete_feature_flagDelete a feature flag (PostHog marks it deleted and switches it off; code that checks the key then gets false)
posthog_list_cohortsList cohorts (saved groups of persons): id, name, description, count (persons in it), is_static, is_calculating, filters and created_at
posthog_get_cohortGet one cohort by id: name, description, its definition (filters or query), count of persons, whether it is static or behavioral…
posthog_list_annotationsList annotations (notes on charts such as releases or incidents): id, content, date_marker, scope, the insight or dashboard they belong to…
posthog_get_annotationGet one annotation by id: content, date_marker, scope (project, organization, dashboard or insight), emoji, the insight or dashboard it is…
posthog_create_annotationAdd an annotation, a note shown on charts at a point in time, e.g. a release, a campaign start or an incident
posthog_delete_annotationDelete an annotation (PostHog marks it deleted; it disappears from every chart and can be restored)
posthog_list_experimentsList A/B test experiments: id, name, description, status, start_date, end_date, feature_flag_key, type, conclusion, archived and created_by
posthog_get_experimentGet one experiment by id: status, start and end dates, its feature flag and variants, metrics, parameters, exposure cohort, conclusion and…

Example prompts

  • "How many unique users visited our pricing page each day last week, and which browsers did they use?"
  • "What was the conversion rate of our signup funnel, from pricing page view to completed checkout, over the last 30 days?"
  • "Which feature flags are active right now, and what rollout percentage does each one have?"
  • "Add an annotation for today in our main project: Spring campaign launched."

FAQ

Does the free ChatGPT plan work with custom MCP connectors? No. Custom MCP connections need developer mode, which is only on paid plans.

Next steps

Was this guide helpful?

Your PostHog agent is one click away.

Install the connector, paste the key, prompt ChatGPT. Free for 7 days, no credit card.

Related guides

Connectors

How to Connect PostHog to Claude via MCP

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Connectors

How to Connect PostHog to Cursor via MCP

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Connectors

How to Connect PostHog to Gemini via MCP

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Connectors

How to Connect PostHog to Meta Muse via MCP

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Connectors

PostHog to MCP: Drive PostHog from any AI Agent

Let your AI answer product analytics questions from PostHog: run read-only SQL (HogQL) over events and persons, compute trends, funnels and retention, read saved insights and dashboards, look up persons, cohorts, annotations and experiments, and manage insights and feature flags. PostHog Cloud (US or EU) or self-hosted, with a personal API key.

Connectors

How to Connect Canva to ChatGPT via MCP

Let your AI work in Canva: find and read designs, create new ones, export them to PDF, PNG, PowerPoint or video with download links, organise folders, upload images from a link, read brand templates and comment on designs.