---
title: "PostHog MCP"
type: "MCP Server"
slug: "posthog"
icon: "analytics"
category: "Product Analytics"
tags: ["PostHog", "Analytics", "Feature Flags", "Experiments", "Error Tracking", "HogQL"]
installs: "0"
author: "PostHog"
authorInitial: "P"
lastUpdated: "2026-04-07"
popularity: "5.0/5"
reviewCount: "New"
platformTags: ["Hosted", "Official"]
installLabel: "mcp.json"
installCredentials:
  - key: POSTHOG_PERSONAL_API_KEY
    label: "PostHog Personal API Key"
    placeholder: "<POSTHOG_PERSONAL_API_KEY>"
    description: "Create a personal API key using PostHog's MCP Server preset. This scopes access to a specific PostHog project."
    secret: true
securityBadges:
  - label: "Auth"
    status: "Personal API Key or OAuth"
  - label: "Deployment"
    status: "Hosted Remote MCP"
---

Official hosted PostHog MCP access for analytics, feature flags, experiments, error tracking, dashboards, logs, SQL/HogQL, and docs search.

## When to Use

Use this MCP when your agent needs to work directly with a PostHog project without leaving your AI workspace.

- Query product analytics, funnels, paths, retention, and HogQL/SQL results
- Create, inspect, or update feature flags, experiments, dashboards, notebooks, and surveys
- Investigate error tracking issues, logs, and recent project activity
- Search PostHog documentation from the MCP itself
- Manage project-scoped PostHog resources through one authenticated connection

## Prerequisites

- A **PostHog personal API key** created with the **MCP Server preset**
- Access to the PostHog project you want the MCP to use

To create the API key:

- Open PostHog and create a **Personal API Key**
- Choose the **MCP Server preset**
- Copy the generated `phx_...` key into `POSTHOG_PERSONAL_API_KEY`

## Installation

PostHog's MCP server is hosted by PostHog, so there is nothing to install locally besides having `npx` available. Add the following MCP configuration to your AI tool:

```json
{
  "mcpServers": {
    "posthog": {
      "url": "https://mcp.posthog.com/mcp",
      "headers": {
        "Authorization": "Bearer <POSTHOG_PERSONAL_API_KEY>"
      }
    }
  }
}
```

Useful endpoint variants and options:

- **EU region:** replace `https://mcp.posthog.com/mcp` with `https://mcp-eu.posthog.com/mcp`
- **Feature filtering:** append query params like `?features=flags,dashboards` or `?tools=dashboard-get,execute-sql`
- **Pin to a specific org/project:** add headers `x-posthog-organization-id` and/or `x-posthog-project-id`
- **Self-hosted PostHog:** run the server on your own infrastructure and point the MCP URL at that endpoint

## Example Prompts

> "How many unique users signed up in the last 7 days, broken down by day?"

> "Create a feature flag called `new-checkout-flow` and roll it out to 20% of users."

> "Show me the top 5 errors in this PostHog project this week."

> "List my dashboards and notebooks related to onboarding."

> "Search PostHog docs for how to configure experiments with feature flags."

## Troubleshooting

| Error | Likely Cause | Fix |
| --- | --- | --- |
| `npx` not found | Node.js is not installed or not on `PATH` | Install Node.js 18+ and confirm `npx --version` works |
| `401 Unauthorized` | API key is invalid, expired, or missing the right preset/scope | Recreate the key using the **MCP Server preset** in PostHog |
| Empty or unexpected project data | The key is scoped to a different project | Create/use a key for the correct project, or pin the right project header |
| EU workspace cannot authenticate correctly | Using the US endpoint for an EU project | Switch the MCP URL to `https://mcp-eu.posthog.com/mcp` |
| Too many tools exposed | The default endpoint exposes all tools | Add `features=` or `tools=` query params to narrow the surface area |

## Security Notes

- The PostHog MCP server is a hosted proxy to your PostHog instance; it does not store your analytics data permanently.
- Session state such as active organization/project may be cached temporarily by PostHog's hosted infrastructure.
- Use the **EU endpoint** for EU projects if regional routing matters for your environment.
- Treat your `phx_...` personal API key like a secret and rotate it if it is exposed.
