Skip to content
MCP Shelf

PostHog MCP Server

Ask PostHog questions in plain words and manage flags, experiments and dashboards.

View on GitHub
  • Needs your setup first
  • ★ 40.5K GitHub stars
  • Last commit 28 Oct 2026

What is PostHog MCP?

PostHog MCP is PostHog's official MCP server that lets an AI assistant query product analytics and SQL, and manage feature flags, experiments, dashboards, error tracking and more in your PostHog project.

Tools
exec (CLI mode)
Runs on
Your computer or hosted
Licence
MIT
GitHub stars
40.5K

Good for

  • Answering product questions without writing the query yourself
  • Creating and rolling out feature flags and A/B tests from the editor
  • Looking into an error or a drop in a funnel with the data at hand

You'll need

  • A PostHog Cloud account (US or EU), or a self-hosted instance
  • A personal API key with the MCP Server preset, unless your client signs in with OAuth
Works withClaude CodeCursorClaude DesktopVS CodeCodexWindsurfChatGPTEach has a ready-made config on the Install tab, built from the README.

Needs your setup firstIt needs something our Linux test machine does not have (an account, a desktop app, a Mac or a running service), so on 24 Nov 2026 we read its tools from the source code instead of running this config.

Try asking PostHog MCP

Once it is installed, ask your assistant things like:

  • How many unique users signed up in the last 7 days, by day?
  • Create a feature flag called new-checkout-flow for 20% of users.
  • What are the top errors in error tracking this week, and which users hit them?

MCP Shelf take

PostHog needs something our Linux test machine does not have (an account, an app or a service), so on 24 Nov 2026 we read its source and counted 1 tool. None of them is read-only, so keep "ask before each tool call" on. It is the most-starred of the 11 servers in its category on our shelf (40.5K stars).
MCP Shelf tests: numbers from our own runs, not the README · tested on 24 Nov 2026

What can PostHog MCP read and change?

It can read

  • Events, persons, cohorts, insights and dashboards in your project
  • SQL results from your PostHog data and connected warehouse sources
  • Error tracking issues, session replays, logs and survey responses

It can change

  • Creates and edits feature flags, including rollout percentages
  • Creates experiments, surveys, dashboards, insights and annotations
  • Can switch the active project and organisation for the session

Safer setup: Add ?split_writes=true so read tools can run freely while every change needs your approval, and narrow it with ?features= to the groups you need.

PostHog MCP in more detail

PostHog maintains this server in its main repository and hosts it at mcp.posthog.com. It reaches almost every part of PostHog: trends and funnels, HogQL SQL, dashboards and insights, feature flags, experiments, error tracking, session replays, surveys, logs and the docs. Ask how many people signed up last week, or create a flag for 20% of users, and the assistant does it in your project.

Most clients get one exec tool that wraps every PostHog command, which keeps the tool list short. You can split it into a read tool and a write tool, so reads run freely while every change asks first, and narrow the tools with ?features= on the URL, such as flags,dashboards.

Made by
PostHog (PostHog/posthog, services/mcp)
Last commit
28 Oct 2026
Setup checked
24 Nov 2026
Page updated
24 Nov 2026

What's in the pod

What tools does PostHog MCP have?

We found 1 tool in its source code on 24 Nov 2026. 0 only read. The rest can change things, so keep your app's "ask before each tool call" setting on for them.

How we tested it: Taken from the README in PostHog/posthog (services/mcp). The hosted server needs a PostHog sign-in or personal API key. Most clients get this single exec tool (CLI mode); ?split_writes=true lists exec-read and exec-write instead, and ?mode=tools lists every PostHog tool separately.

Runs commands1 tool · Can start programs or run code.

ToolWhat it is for
execThe one tool most clients get. The model runs discovery commands to find the PostHog tool it needs, reads its schema, then calls it.

Tool groups

Product analytics
insights (trends, funnels and retention queries), product_analytics, dashboards, web_analytics, cohorts, persons, events, actions and annotations.
Data and SQL
sql for HogQL queries, data_schema, data_warehouse, warehouse_sources, data_catalog and batch_exports.
Releases and experiments
flags (feature flags), experiments, early_access_features and surveys.
Debugging
error_tracking, replay (session replays), logs, tracing, llm_analytics and alerts.
Workspace
workspace (switching organisation and project), docs search, notebooks, hog_functions, workflows and more. Pick groups with ?features= on the URL.

Grouped and described by us. The README on GitHub lists the inputs each tool takes.

How do I install PostHog MCP?

Quick install

One command from the README sets it up for you:

Terminal
npx @posthog/wizard@latest mcp add

Or paste it into your app by hand:

Where it goes: Your terminal, in the project folder

Claude Code
claude mcp add posthog -e 'POSTHOG_AUTH_HEADER=Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}' -- npx -y mcp-remote@latest https://mcp.posthog.com/mcp --header 'Authorization:${POSTHOG_AUTH_HEADER}'

npx @posthog/wizard@latest mcp add sets it up for Claude Code. To do it by hand: claude mcp add --transport http posthog https://mcp.posthog.com/mcp, then /mcp to sign in.

Codex, Windsurf, ChatGPT and more →

Install steps from the PostHog MCP README

The project's own instructions, copied from its README on GitHub on 24 Nov 2026 under its MIT licence. They are the source of truth; the ready-made configs further down are built from them. The full README is on GitHub.

Quick install

You can install the MCP server automatically into Cursor, Claude, Claude Code, VS Code and Zed by running the following command:

npx @posthog/wizard@latest mcp add
Manual install
  1. Obtain a personal API key using the MCP Server preset.

  2. Add the MCP configuration to your desktop client (e.g. Cursor, Windsurf, Claude Desktop) and add your personal API key

{
  "mcpServers": {
    "posthog": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote@latest",
        "https://mcp.posthog.com/mcp",
        "--header",
        "Authorization:${POSTHOG_AUTH_HEADER}"
      ],
      "env": {
        "POSTHOG_AUTH_HEADER": "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}"
      }
    }
  }
}

What you need first

  • A PostHog Cloud account (US or EU), or a self-hosted instance
  • A personal API key with the MCP Server preset, unless your client signs in with OAuth

Add PostHog MCP to your app

Pick your app for a ready-to-paste snippet and where it goes, built from the steps above.

Where it goes: Your terminal, in the project folder

Claude Code
claude mcp add posthog -e 'POSTHOG_AUTH_HEADER=Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}' -- npx -y mcp-remote@latest https://mcp.posthog.com/mcp --header 'Authorization:${POSTHOG_AUTH_HEADER}'

npx @posthog/wizard@latest mcp add sets it up for Claude Code. To do it by hand: claude mcp add --transport http posthog https://mcp.posthog.com/mcp, then /mcp to sign in.

Create the key from the MCP Server preset in your PostHog settings and put it after Bearer. Add ?split_writes=true to the URL to get separate read and write tools.

Remote option

Clients that take a URL can connect here directly and sign in with OAuth. EU accounts use mcp-eu.posthog.com.

Server URL
https://mcp.posthog.com/mcp

Checked against the project's own install docs on 24 Nov 2026: github.com/PostHog/posthog/tree/master/services/mcp, posthog.com/docs/model-context-protocol.

Did this work for you?

Projects change their install steps often. If PostHog MCP did not install, or something here no longer matches the project, tell us and we will check it against the README and fix the page.

New to this? See the setup guides for Claude Code, Cursor, Claude Desktop, VS Code, Codex and ChatGPT. If it will not start, test it in MCP Inspector and look up the error in Fixing MCP server errors.

PostHog MCP not working? Common fixes

401 or authentication errors with mcp-remote
POSTHOG_AUTH_HEADER must read Bearer, a space, then a personal API key made with the MCP Server preset. A project API key will not work.
OAuth signs you in to the wrong region
EU accounts should connect to mcp-eu.posthog.com instead of mcp.posthog.com.
The model sees only one tool called exec
That is CLI mode, the default for most clients. The model discovers commands through it. Add ?mode=tools to the URL if your client works better with every tool listed separately.
It queries the wrong project
A session starts in your active organisation and project. Ask the assistant to switch project, which the workspace tools handle.

How do I configure PostHog MCP?

Names are exactly as the project spells them. Required ones are marked.

SettingWhat it does
POSTHOG_AUTH_HEADEREnvironment variableHolds Bearer followed by your personal API key, for the mcp-remote config. Create the key with the MCP Server preset in your PostHog settings.Bearer phx_...
?features=ConfigLimits the server to some feature groups. Hyphens and underscores both work.https://mcp.posthog.com/mcp?features=flags,dashboards,insights
?tools=ConfigLimits it to named tools, on its own or combined with features.https://mcp.posthog.com/mcp?tools=dashboard-get,execute-sql
?mode= or x-posthog-mcp-modeConfigcli wraps every command in one exec tool (the default for most clients); tools lists each PostHog tool separately.
?split_writes=true or x-posthog-split-writesConfigReplaces exec with exec-read and exec-write, so reads can be allowed while every write asks first.
mcp-eu.posthog.comConfigThe address for PostHog Cloud EU accounts, so OAuth goes to the EU instance.
POSTHOG_API_BASE_URLEnvironment variablePoints a server you run yourself at a self-hosted PostHog instance.

PostHog MCP FAQ

Is PostHog MCP official?

Yes. PostHog builds it inside its main repository, under services/mcp, and hosts it at mcp.posthog.com, with mcp-eu.posthog.com for EU accounts.

What is the quickest way to install PostHog MCP?

Run npx @posthog/wizard@latest mcp add. PostHog's wizard adds the server to Cursor, Claude, Claude Code, VS Code or Zed and walks you through signing in.

Does PostHog MCP need an API key?

Clients that support OAuth can sign in with your PostHog account. Otherwise create a personal API key with the MCP Server preset and pass it as a Bearer token, as the mcp-remote config does.

Can PostHog MCP change my data?

Yes. It can create and edit feature flags, experiments, surveys, dashboards and more. Add ?split_writes=true to the URL so changes go through exec-write, which your client can keep asking you about.

Why does PostHog MCP only show one tool?

To keep the tool list short, most clients get CLI mode: one exec tool that discovers and runs PostHog's commands. Add ?mode=tools to list every tool separately instead.

Does PostHog MCP work with self-hosted PostHog?

Yes, when you run the server yourself. Set POSTHOG_API_BASE_URL to your instance's address. The hosted server at mcp.posthog.com is for PostHog Cloud.

Does PostHog store my analytics data in the MCP server?

No. The server passes queries to your PostHog project and returns the results. It keeps only session state, such as the active project, in the region you connect to.

How do I add PostHog MCP to Cursor?

Run npx @posthog/wizard@latest mcp add and pick Cursor, or add an entry named posthog to ~/.cursor/mcp.json with the mcp-remote config from this page and your personal API key.

Can I use PostHog MCP in VS Code?

Yes, with GitHub Copilot in Agent mode. The PostHog wizard can add it, or add a server named posthog with type http and the URL https://mcp.posthog.com/mcp to .vscode/mcp.json.

Does PostHog MCP work with Codex?

Yes. Run codex mcp add posthog --url https://mcp.posthog.com/mcp and sign in, or add an [mcp_servers.posthog] table with that URL to ~/.codex/config.toml.

Two peas, one chat

Chat with AI about PostHog

Opens a chat primed with PostHog’s README and setup docs from this page, or add it in Cursor to use its tools.

The Cursor button opens Cursor and asks before it adds the server. Fill in any keys it needs in Cursor’s MCP settings.

Peas in a pod

What are the alternatives to PostHog MCP?

How PostHog MCP lines up against its neighbours on the shelf. See every databases and data server.

  • PostHog MCPThis pea

    Ask PostHog questions in plain words and manage flags, experiments and dashboards.

    Tools
    exec (CLI mode)
    Runs on
    Your computer or hosted
    Licence
    MIT
    Stars
    40.5K
  • Postgres MCP Pro

    SQL, query plans, health checks and index advice for Postgres.

    Tools
    9
    Runs on
    Your computer
    Licence
    MIT
    Stars
    3.4K
  • Supabase

    Manage Supabase projects, tables, migrations, logs and Edge Functions.

    Tools
    29
    Runs on
    Hosted
    Licence
    Apache-2.0
    Stars
    3K
  • Neon MCP Server

    Neon Postgres from chat: projects, branches, SQL and migrations tested on a branch.

    Tools
    65
    Runs on
    Hosted
    Licence
    MIT
    Stars
    658
  • MongoDB MCP Server

    Query, inspect and manage MongoDB databases and Atlas clusters, read-only if you like.

    Tools
    20
    Runs on
    Your computer
    Licence
    Apache-2.0
    Stars
    1.2K
  • Redis MCP Server

    Redis's own server: keys, hashes, streams, JSON and vector search in plain English.

    Tools
    53
    Runs on
    Your computer
    Licence
    MIT
    Stars
    641
Full docs on GitHubPostHog/posthog

Something wrong on this page? Tell us.

For bots & AI agents

Machine-readable versions of PostHog MCP and MCP Shelf. Fetch these instead of parsing this page.

This listing (.md)llms.txtllms-full.txtai.txtFull catalog (.md)API specMCP serverMCP manifestDeveloper docs