---
title: "PostHog MCP Server: Official Setup, Tools and Read-Only Use"
url: "https://mcpshelf.co/servers/posthog"
description: "PostHog's official MCP server lets Claude, Cursor or Codex query analytics, run SQL and manage feature flags, experiments and errors. One-command setup."
updated: "2026-11-24"
site: "MCP Shelf"
---

# PostHog MCP

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

Source: https://mcpshelf.co/servers/posthog  
Markdown: https://mcpshelf.co/servers/posthog.md  
Generated: 2026-11-24T21:04:31.872Z

## Facts

- **Name:** PostHog MCP
- **Tagline:** Ask PostHog questions in plain words and manage flags, experiments and dashboards.
- **Description:** 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.
- **Repository:** https://github.com/PostHog/posthog
- **Install:** `npx @posthog/wizard@latest mcp add`
- **Server URL:** https://mcp.posthog.com/mcp
- **Transport:** stdio (local), or HTTP via the hosted server
- **Auth:** No required keys or settings listed
- **Tools exposed:** 1: `exec`
- **Category:** Databases and data (https://mcpshelf.co/categories/databases)
- **Stats:** 40.5K GitHub stars, last commit 28 Oct 2026, 0 upvotes on MCP Shelf
- **Install check:** Needs your setup first
- **Listed:** 2026-11-24
- **Page updated:** 2026-11-24

## Full description

### 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.**

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) |
| GitHub | https://github.com/PostHog/posthog |
| Licence | MIT |
| GitHub stars | 40.5K |
| Last commit | 28 Oct 2026 |
| Tools | exec (CLI mode) |
| Runs on | Your computer or hosted |
| Install check | Needs your setup first |
| Category | [Databases and data](https://mcpshelf.co/categories/databases) |
| Works with | Claude Code, Cursor, Claude Desktop, VS Code, Codex, Windsurf, ChatGPT |
| Setup checked | 24 Nov 2026 |
| Page updated | 24 Nov 2026 |

**Our check:** It 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

- "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), tested on 24 Nov 2026

### What tools does PostHog MCP have?

We listed 1 tools on 24 Nov 2026. 0 only read; the rest can change things or run commands.

| Tool | Kind | What it is for |
| --- | --- | --- |
| `exec` | runs | The 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

| Group | Covers |
| --- | --- |
| `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. |

### How do I install PostHog MCP?

#### Install steps from the PostHog MCP README

Copied from the project's [README on GitHub](https://github.com/PostHog/posthog/tree/HEAD/services/mcp#readme) on 24 Nov 2026 under its MIT licence.

##### 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](https://us.posthog.com/settings/user-api-keys?preset=mcp_server).
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

#### Fastest way: one command

```bash
npx @posthog/wizard@latest mcp add
```

PostHog's own installer. It adds the server to Cursor, Claude, Claude Code, VS Code or Zed for you.

#### Claude Code

Where: Your terminal, in the project folder

```bash
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.

#### Cursor

Where: ~/.cursor/mcp.json, or .cursor/mcp.json in a project

```json
{
  "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}"
      }
    }
  }
}
```

#### Claude Desktop

Where: claude_desktop_config.json (Settings → Developer → Edit Config)

```json
{
  "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}"
      }
    }
  }
}
```

#### VS Code

Where: .vscode/mcp.json in your project

```json
{
  "servers": {
    "posthog": {
      "type": "stdio",
      "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}"
      }
    }
  }
}
```

#### Codex

Where: ~/.codex/config.toml, shared by the Codex CLI, IDE extension and ChatGPT desktop app

```
[mcp_servers.posthog]
command = "npx"
args = ["-y", "mcp-remote@latest", "https://mcp.posthog.com/mcp", "--header", "Authorization:${POSTHOG_AUTH_HEADER}"]

[mcp_servers.posthog.env]
POSTHOG_AUTH_HEADER = "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}"
```

codex mcp add posthog --url https://mcp.posthog.com/mcp, then codex mcp login posthog. Codex gets the exec tool by default.

#### Windsurf

Where: ~/.codeium/windsurf/mcp_config.json

```json
{
  "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}"
      }
    }
  }
}
```

#### ChatGPT

Where: chatgpt.com/plugins → + → Add custom MCP server

```
https://mcp.posthog.com/mcp
```

Paste the URL as the server address, choose OAuth if it asks you to sign in, create it as a plugin, then install it before using it in a chat. Workspace admins can block custom servers.

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.

```
https://mcp.posthog.com/mcp
```

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

### How do I configure PostHog MCP?

| Setting | Kind | Required | What it does |
| --- | --- | --- | --- |
| `POSTHOG_AUTH_HEADER` | env | no | Holds Bearer followed by your personal API key, for the mcp-remote config. Create the key with the MCP Server preset in your PostHog settings. Example: `Bearer phx_...` |
| `?features=` | config | no | Limits the server to some feature groups. Hyphens and underscores both work. Example: `https://mcp.posthog.com/mcp?features=flags,dashboards,insights` |
| `?tools=` | config | no | Limits it to named tools, on its own or combined with features. Example: `https://mcp.posthog.com/mcp?tools=dashboard-get,execute-sql` |
| `?mode= or x-posthog-mcp-mode` | config | no | cli 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-writes` | config | no | Replaces exec with exec-read and exec-write, so reads can be allowed while every write asks first. |
| `mcp-eu.posthog.com` | config | no | The address for PostHog Cloud EU accounts, so OAuth goes to the EU instance. |
| `POSTHOG_API_BASE_URL` | env | no | Points a server you run yourself at a self-hosted PostHog instance. |

### 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.

### 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

### 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.

### What are the alternatives to PostHog MCP?

| Server | What it does | Tools | Runs on | Licence | Stars |
| --- | --- | --- | --- | --- | --- |
| [PostHog MCP](https://mcpshelf.co/servers/posthog) | Ask PostHog questions in plain words and manage flags, experiments and dashboards. | exec (CLI mode) | Your computer or hosted | MIT | 40.5K |
| [Postgres MCP Pro](https://mcpshelf.co/servers/postgres-mcp-pro) | SQL, query plans, health checks and index advice for Postgres. | 9 | Your computer | MIT | 3.4K |
| [Supabase](https://mcpshelf.co/servers/supabase) | Manage Supabase projects, tables, migrations, logs and Edge Functions. | 29 | Hosted | Apache-2.0 | 3K |
| [Neon MCP Server](https://mcpshelf.co/servers/neon) | Neon Postgres from chat: projects, branches, SQL and migrations tested on a branch. | 65 | Hosted | MIT | 658 |
| [MongoDB MCP Server](https://mcpshelf.co/servers/mongodb) | Query, inspect and manage MongoDB databases and Atlas clusters, read-only if you like. | 20 | Your computer | Apache-2.0 | 1.2K |
| [Redis MCP Server](https://mcpshelf.co/servers/redis) | Redis's own server: keys, hashes, streams, JSON and vector search in plain English. | 53 | Your computer | MIT | 641 |

### 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.

Full docs on GitHub: https://github.com/PostHog/posthog

## Notes for agents

Fetch these instead of parsing the HTML page:

- llms.txt: https://mcpshelf.co/llms.txt
- llms-full.txt: https://mcpshelf.co/llms-full.txt
- ai.txt: https://mcpshelf.co/ai.txt
- Full catalog (.md): https://mcpshelf.co/catalog.md
- API spec: https://mcpshelf.co/openapi.json
- MCP server: https://mcpshelf.co/mcp
- MCP manifest: https://mcpshelf.co/.well-known/mcp.json
- Developer docs: https://mcpshelf.co/developers

MCP endpoint (Streamable HTTP, no key): https://mcpshelf.co/mcp. REST API: https://mcpshelf.co/api/v1.

