PostHog logo
Analytics & MarketingAuth: OAuthHosting: Official hosted

PostHog MCP Server

Connect AI agents to PostHog product analytics, feature flags, and error tracking over MCP.

Updated

What is PostHog MCP?

The PostHog MCP server is a Model Context Protocol server that lets AI agents and assistants interact with your PostHog product analytics in plain language — querying events and insights, running HogQL, managing feature flags and experiments, and triaging captured errors.

PostHog runs the server as an official, hosted endpoint at https://mcp.posthog.com/mcp. You connect over OAuth: when your client first calls the server, you log in to PostHog and authorize access, and the server automatically routes you to the correct data region (US or EU) based on the account you sign in with. There is nothing to deploy or host yourself.

Once connected, an MCP-compatible client — Claude, Claude Code, Cursor, VS Code, Zed, and others — can read and act on your PostHog data through the server's grouped toolset, so questions like "which feature flags are rolled out to 50%?" or "show me the top error groups this week" resolve without leaving the editor or chat.

Tools the PostHog MCP server exposes

ToolWhat it does
InsightsQuery analytics data and create, read, update, and manage insights, including HogQL queries.
DashboardsCreate, retrieve, and manage dashboards and add insights to them.
Feature flagsCreate, read, update, and delete feature flags programmatically.
Error trackingList and inspect captured error groups and their details.
ExperimentsManage PostHog experiments.
Organizations & projectsList and switch between organization and project contexts.
Docs searchSearch PostHog documentation from within the client.

Connect the PostHog MCP server

Claude Code

  1. 1

    Run the PostHog wizard

    In your terminal, run: npx @posthog/wizard@latest mcp add — it installs the hosted server (https://mcp.posthog.com/mcp) into Claude Code automatically.

  2. 2

    Authorize over OAuth

    When Claude Code first calls the server, a browser window opens to log in to PostHog and authorize access; your data region (US/EU) is detected from the account.

  3. 3

    Verify

    Ask Claude Code something like "list my PostHog feature flags" to confirm the tools are available.

Cursor

  1. 1

    Run the PostHog wizard

    Run npx @posthog/wizard@latest mcp add and select Cursor, or add the remote server https://mcp.posthog.com/mcp in Cursor's MCP settings.

  2. 2

    Authorize over OAuth

    On first use, complete the PostHog OAuth login in the browser to authorize Cursor; the server routes to your account's region.

  3. 3

    Verify

    Open the MCP panel and confirm the PostHog tools are listed, then prompt Cursor to query an insight or error group.

Sample use cases

Security & permissions

Authentication is OAuth. On first connection you log in to PostHog and authorize the client; the server then routes to your account's data region (US or EU). The agent acts with the permissions of the authorized PostHog account, so it can read and modify analytics resources (insights, dashboards, feature flags, experiments, error tracking) within that account's scope. Grant access only to clients you trust, and review the connected app under your PostHog organization settings.

Using PostHog MCP with Gamut

In Gamut, the PostHog MCP server is wired in as a tool an agent can call inside an automated, event- or schedule-triggered workflow — Gamut manages the OAuth connection so the agent can reach PostHog without manual login at run time. For example, a scheduled agent can pull weekly error groups and trending insights, summarize regressions, and post them to a chat channel; or an event-triggered agent can check a feature flag's rollout state before taking a downstream action. The agent uses PostHog strictly through the tools the server exposes, scoped to the connected account's permissions.

Frequently asked questions

Can the PostHog MCP agent manage feature flags?

Yes. The integration includes a feature flags tool that supports creating, reading, updating, and deleting flags programmatically. Your agent can toggle flags, update rollout percentages, and query flag evaluations.

Does the agent have access to individual user data?

PostHog's API can return event-level and user-level data depending on your queries. The MCP server passes through whatever PostHog's API returns. Use PostHog's data governance features and API key scoping to control access to PII.

Can the agent run HogQL queries?

Yes. The Insights tool supports HogQL — PostHog's SQL-like query language. Your agent can write arbitrary analytical queries against your event data, which is useful for ad-hoc analysis that doesn't fit predefined insight types.