PostHog MCP server
PostHog's official MCP server: query product analytics, manage feature flags and experiments, run HogQL, and triage errors from your editor.
The PostHog MCP server is PostHog's official, hosted integration that lets an AI agent read and write across the PostHog product suite using plain language. Instead of clicking through the PostHog app, an agent can answer analytics questions, build and update insights and dashboards, ship and toggle feature flags, set up and read A/B test experiments, create and analyze surveys, inspect event and property definitions, look at error-tracking issues, and run ad-hoc HogQL queries against your project's data. It can even generate HogQL from a natural-language question and pull LLM-usage cost breakdowns, making it a fast feedback loop for both shipping features and understanding how they perform.
The canonical deployment is the hosted remote endpoint at https://mcp.posthog.com/mcp (with an SSE variant at /sse for clients that need it). Authentication is a personal API key passed as an Authorization: Bearer header, and the auth server automatically routes you to the correct data region (US or EU) for your account. Clients with native streamable-HTTP support connect to the URL directly; others bridge through npx mcp-remote, passing the bearer header via the POSTHOG_AUTH_HEADER environment variable. The simplest path is the official installer, npx @posthog/wizard@latest mcp add, which wires the server into Cursor, Claude, Claude Code, VS Code, or Zed for you. Scope the personal API key to exactly the products you want the agent to touch.
Quick install
Copy-paste configs are provided for all 8 supported clients. Pick your client below.
Add to ~/.claude.json
{
"mcpServers": {
"posthog": {
"type": "http",
"url": "https://mcp.posthog.com/mcp",
"headers": {
"Authorization": "Bearer <POSTHOG_AUTH_HEADER>"
}
}
}
}claude mcp add --transport http posthog https://mcp.posthog.com/mcpAvailable tools
| Tool | Description |
|---|---|
| dashboards-get-all | Get all dashboards in the project with optional filtering. |
| dashboard-get | Get a specific dashboard by ID, including the insights on it. |
| dashboard-create | Create a new dashboard in the project. |
| dashboard-update | Update an existing dashboard by ID. |
| dashboard-delete | Delete a dashboard by ID. |
| add-insight-to-dashboard | Add an existing insight to a dashboard. |
| insights-get-all | Get all insights in the project with optional filtering. |
| insight-get | Get a specific insight by ID. |
| insight-create-from-query | Save a query as an insight. |
| insight-update | Update an existing insight by ID. |
| insight-delete | Delete an insight by ID. |
| insight-query | Execute a query on an existing insight to get its results/data. |
| query-run | Run a trend, funnel, or HogQL query. |
| query-generate-hogql-from-question | Query the project's PostHog data from a natural-language question by generating HogQL. |
| feature-flag-get-all | Get all feature flags in the project. |
| feature-flag-get-definition | Get the definition of a feature flag. |
| create-feature-flag | Create a new feature flag in the project. |
| update-feature-flag | Update a feature flag in the project. |
| delete-feature-flag | Delete a feature flag in the project. |
| experiment-get-all | Get all experiments in the project. |
| experiment-get | Get details of a specific experiment. |
| experiment-create | Create an A/B test experiment with guided metric and feature-flag setup. |
| experiment-update | Update an existing experiment, including lifecycle management and restart. |
| experiment-delete | Delete an experiment by ID. |
| experiment-results-get | Get comprehensive experiment results, including metrics and exposure data. |
| survey-create | Create a new survey in the project. |
| survey-get | Get a specific survey by ID. |
| surveys-get-all | Get all surveys in the project with optional filtering. |
| survey-update | Update an existing survey by ID. |
| survey-delete | Delete a survey by ID. |
| survey-stats | Get response statistics for a specific survey. |
| surveys-global-stats | Get aggregated response statistics across all surveys. |
| list-errors | List errors in the project. |
| error-details | Get the details of an error in the project. |
| event-definitions-list | List all event definitions in the project with optional filtering. |
| property-definitions | Get event and property definitions for the project. |
| properties-list | Get properties for events or persons. |
| get-llm-total-costs-for-project | Fetch the total LLM daily costs for each model for a project over a given number of days. |
| docs-search | Search the PostHog documentation for information. |
| organizations-get | Get the organizations the user has access to. |
| organization-details-get | Get the details of the active organization. |
| switch-organization | Change the active organization from the default organization. |
| projects-get | Fetch the projects the user has access to in the current organization. |
| switch-project | Change the active project from the default project. |
Required configuration
- POSTHOG_AUTH_HEADERRequired
The string 'Bearer <your-personal-api-key>' used to authenticate to the remote endpoint when bridging through mcp-remote.
What you can do with it
Answer product questions without leaving your editor
Ask the agent how a metric is trending; it generates HogQL from your question, runs the query against your project, and can save the result as a reusable insight or pin it to a dashboard.
Ship and manage feature flags and experiments
Create a feature flag from a prompt, launch an A/B test with guided metric setup, then read the experiment results and exposure data back — all through the MCP tools rather than the PostHog UI.
FAQ
- Is it free?
- Yes. The MCP server is free and open source, and you only need a PostHog account with a personal API key. Underlying PostHog usage is governed by your own plan (PostHog has a generous free tier with monthly event and feature allowances).
- Does it support remote/OAuth?
- The canonical deployment is the remote endpoint at https://mcp.posthog.com/mcp (with an /sse variant). It authenticates with a personal API key sent as an Authorization: Bearer header rather than a full OAuth flow, and automatically routes you to the correct US or EU data region. Clients without native HTTP support bridge through npx mcp-remote.