PostHog MCP server for AI agents

Query PostHog product analytics with SQL, read insights, dashboards, persons, cohorts, experiments, surveys and session recordings, and manage feature flags and annotations.

PostHogBEARER_TOKEN

Runs with your users' own PostHog accounts. Credentials stay on prompt-tm.com.

22 tools · 0 triggers

Auth
Access token
Tools
22
Triggers
0
Category
Analytics, Developer tools

Tools and triggers

  • Get the current user

    POSTHOG_USERS_RETRIEVE

    Returns the user the key belongs to, with their current organization (`organization.id`) and project (`team.id`).read-only

  • List projects

    POSTHOG_ORGANIZATIONS_PROJECTS_LIST

    Lists the projects of an organization, with their numeric IDs.read-only

  • Run a query

    POSTHOG_QUERY_CREATE

    Runs a query against the project's data and returns the rows. The usual form is SQL (HogQL): `{ "kind": "HogQLQuery", "query": "select event, count() from events where timestamp > now() - interval 7 day group by event order by count() desc limit 20" }`. Tables include `events`, `persons` and `sessions`.read-only

  • List persons

    POSTHOG_PERSONS_LIST

    Lists or searches the people PostHog has seen, with their properties and distinct IDs. To set properties, send `$set` with an event instead.read-only

  • Get a person

    POSTHOG_PERSONS_RETRIEVE

    Returns one person with all their properties and distinct IDs.read-only

  • List insights

    POSTHOG_INSIGHTS_LIST

    Lists saved insights (trends, funnels, retention, SQL and others). Set `basic` for metadata only, which is faster.read-only

  • Get an insight

    POSTHOG_INSIGHTS_RETRIEVE

    Returns one insight with its query and results.read-only

  • Create an insight

    POSTHOG_INSIGHTS_CREATE

    Saves a new insight from a query, such as `{ "kind": "InsightVizNode", "source": { "kind": "TrendsQuery", "series": [{ "kind": "EventsNode", "event": "$pageview" }] } }` or a `HogQLQuery` for SQL.

  • List dashboards

    POSTHOG_DASHBOARDS_LIST

    Lists the project's dashboards.read-only

  • Get a dashboard

    POSTHOG_DASHBOARDS_RETRIEVE

    Returns one dashboard with its tiles and the insights on them.read-only

  • Create a dashboard

    POSTHOG_DASHBOARDS_CREATE

    Creates a dashboard, empty or as a copy of an existing one.

  • List feature flags

    POSTHOG_FEATURE_FLAGS_LIST

    Lists the project's feature flags with their keys, release conditions and whether they're on.read-only

  • Get a feature flag

    POSTHOG_FEATURE_FLAGS_RETRIEVE

    Returns one feature flag with its release conditions, variants, payloads and `version`.read-only

  • Create a feature flag

    POSTHOG_FEATURE_FLAGS_CREATE

    Creates a feature flag. With `active` true it starts serving to the users its release conditions match.destructive

  • Update a feature flag

    POSTHOG_FEATURE_FLAGS_PARTIAL_UPDATE

    Changes a feature flag: switch it on or off, change the rollout or rename it. Fields left out stay as they are. Changes reach users as soon as they're saved.destructive

  • List annotations

    POSTHOG_ANNOTATIONS_LIST

    Lists the notes marked on the project's charts (releases, incidents, campaigns).read-only

  • Create an annotation

    POSTHOG_ANNOTATIONS_CREATE

    Marks a moment on the project's charts with a note, such as a deploy or a campaign launch.

  • List cohorts

    POSTHOG_COHORTS_LIST

    Lists the project's cohorts (saved groups of persons) with their sizes.read-only

  • List experiments

    POSTHOG_EXPERIMENTS_LIST

    Lists the project's A/B tests with their feature flags, dates and status.read-only

  • Get an experiment

    POSTHOG_EXPERIMENTS_RETRIEVE

    Returns one experiment with its variants, metrics, feature flag and dates.read-only

  • List surveys

    POSTHOG_SURVEYS_LIST

    Lists the project's surveys with their questions and dates.read-only

  • List session recordings

    POSTHOG_SESSION_RECORDINGS_LIST

    Lists session recordings with their person, duration, activity counts and start URL.read-only

Try PostHog now

Sign in, connect your account and run any of these in the playground, or ask your agent through the router.

Try it free

Connect via MCP

Create an MCP server for PostHog in the dashboard, then add its URL to your client. This is the Claude Code command; the client guide has the others.

terminal
claude mcp add --transport http posthog \
  "https://www.prompt-tm.com/mcp/<server id>?user_id=<your user>" \
  --header "x-api-key: ptm_…"

Connect via REST

Run a tool with one request. The response is { data, error, successful, log_id } for every tool.

terminal
curl -X POST https://www.prompt-tm.com/api/v3/tools/execute/POSTHOG_USERS_RETRIEVE \
  -H "x-api-key: $PROMPT_TM_KEY" -H "content-type: application/json" \
  -d '{ "user_id": "alice", "arguments": {} }'

PostHog questions