# posthog-mcp-server

**Category:** 📊 Data Platforms  
**Repository:** https://github.com/friendlygeorge/posthog-mcp-server  
**GitHub Stars:** 0  
**npm Downloads (last month):** 250  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/posthog-mcp-server-2

## Description
MCP server for PostHog — product analytics for AI assistants. Query events, persons, insights, da...

## Tools
Capabilities this server exposes over MCP:

- **list_events** — Query events from PostHog. Filter by event name, person, date range, and properties. Returns recent events matching your criteria.
- **get_person** — Get a PostHog person (user) by their distinct_id. Returns person properties, creation date, and event count.
- **list_persons** — List PostHog persons (users). Search by name or distinct_id, with pagination.
- **list_dashboards** — List all PostHog dashboards in the project. Returns dashboard names, IDs, and widget counts.
- **get_dashboard** — Get a specific PostHog dashboard by ID, including its insights and widgets.
- **execute_insight** — Execute a saved PostHog insight by ID and return the results. Use list_dashboards to find insight IDs, or pass a raw insight definition.
- **list_feature_flags** — List all PostHog feature flags in the project. Shows name, key, active status, and rollout percentage.
- **evaluate_feature_flag** — Evaluate a feature flag for a specific user. Returns whether the flag is enabled and its variant value.
- **list_cohorts** — List all PostHog cohorts in the project. Shows name, type, person count, and creation date.
- **list_experiments** — List all PostHog experiments (A/B tests) in the project. Shows name, status, and key results.
- **get_experiment** — Get detailed results for a specific PostHog experiment, including variants, metrics, and statistical significance.
- **list_actions** — List PostHog event actions (custom event definitions). Shows name, steps, and creation date.
- **get_project_info** — Get basic information about the PostHog project — name, ID, created date, and available features.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "posthog-mcp-server": {
    "command": "npx",
    "args": ["-y","posthog-mcp-server"],
    "env": {
      "POSTHOG_API_KEY": "",
      "POSTHOG_HOST": "",
      "POSTHOG_PROJECT": ""
    }
  }
}
```

**Requires environment variables:** `POSTHOG_API_KEY`, `POSTHOG_HOST`, `POSTHOG_PROJECT` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What posthog-mcp-server MCP server does

posthog-mcp-server MCP server gives MCP-compatible AI clients access to selected PostHog project data. Its tools cover event queries, user records, dashboards, saved insights, feature flags, cohorts, experiments, actions, and project settings. The server is intended for analysis and inspection: the documented capabilities retrieve data, execute saved insights, and evaluate feature flags for specific users.

Event queries can be filtered by event name, person, date range, and properties. Person tools support lookup by `distinct_id` as well as paginated searches. Dashboard and insight tools expose dashboard structure, widgets, and results from saved trends, funnels, and other insight types. Experiment tools return test metadata and result information, including variant data and statistical significance.

## How it works

The server wraps PostHog REST API v1 and presents its operations as MCP tools. An MCP client starts the server as a Node process, commonly with `npx -y posthog-mcp-server`, and supplies configuration through environment variables. The assistant can then call the available tools using natural-language requests that map to PostHog queries and lookups.

The available tool groups include:

- Events and people: `list_events`, `get_person`, and `list_persons`
- Analytics assets: `list_dashboards`, `get_dashboard`, and `execute_insight`
- Product controls: `list_feature_flags` and `evaluate_feature_flag`
- Segmentation and testing: `list_cohorts`, `list_experiments`, and `get_experiment`
- Project metadata: `list_actions` and `get_project_info`

## Setup and configuration

Create a PostHog personal API key with read access under PostHog settings. Add the server to the MCP client's configuration with the `npx` command and an `env` object. `POSTHOG_API_KEY` is required and should contain the personal key. `POSTHOG_HOST` defaults to `https://us.i.posthog.com`; use `https://eu.i.posthog.com` for the EU region or set it to the URL of a self-hosted PostHog instance.

`POSTHOG_PROJECT` is optional. When set, it supplies the default project ID for calls. When omitted or empty, the project must be provided for each call. For local testing, clone the repository, run `npm install`, build with `npm run build`, and start `node dist/index.js` with the required environment variables.

## Tools and capabilities

The server can list active or available feature flags and evaluate a flag for a named user, returning its variant value. It can list cohorts with their type and person count, inspect experiment status and dates, and retrieve experiment results. Dashboard responses include names, tags, widget counts, and the insights or widgets belonging to a selected dashboard. Project information includes the project name, ID, settings, and data region.

## Limitations and notes

The documented API key setup uses read access, and the listed tools focus on retrieval, analysis, execution of saved insights, and flag evaluation rather than creating or updating PostHog resources. A default project is not mandatory, but calls need project context when `POSTHOG_PROJECT` is unset. The host must match the relevant PostHog cloud region or self-hosted deployment. The server depends on an MCP-compatible client and the PostHog REST API.

_Full upstream README: https://allmcps.com/mcp/posthog-mcp-server-2/readme_

