PostHog MCP: setup, tools, and where it actually helps
You opened Claude Desktop, ran the posthog mcp command, and now an LLM is reading your product analytics the same way a teammate would. That quiet handoff is the whole point of the PostHog MCP server: it lets an AI client pull feature flags, events, and dashboards out of PostHog and answer questions about them in plain English. This guide walks through what it unlocks, how to install it in Claude and Codex, and the edges where the integration frays — so you can decide if the PostHog MCP server belongs in your stack.
What the PostHog MCP integration unlocks
The PostHog MCP server is a thin wrapper around PostHog's APIs, exposed through Anthropic's Model Context Protocol. Once an MCP-aware client connects, it can list the available tools, ask for them, and feed the responses back to the model. In practice, this means a developer or PM sitting in Claude (or any other MCP host) can ask "how many users hit the checkout funnel yesterday?" and watch the assistant call a tool, retrieve data, and answer — no copy-pasting JSON, no dashboard hopping.
Concrete workflows the server enables:
- Funnel and retention queries from chat. The assistant lists the most recent events, counts unique users by property, and reports conversion rates. Useful for sanity-checking what a dashboard shows.
- Feature flag inspection and toggling. Read flag state, list rollouts, and (with the right scope) flip a flag on or off without logging into PostHog's UI.
- Cohort definition on the fly. Build ad-hoc cohorts from event properties and immediately use them in queries, all from a single prompt.
- Error and session replay lookups. Fetch recent exceptions or replay URLs tied to a specific user or session ID — handy when triaging a bug report.
- Documentation and SDK exploration. The server exposes PostHog docs as a tool, so the model can pull the correct method signature instead of hallucinating one.
None of this is magic on its own — PostHog's REST and query APIs already do the work. The MCP server just packages them as tools the model can call. The unlock is conversational access, not new data.
Prerequisites and supported plans on both sides
Before you install, check two things: which PostHog plan you're on, and which MCP host you want to drive.
- PostHog plan. The MCP server sits inside PostHog Cloud and PostHog OSS self-hosted. There is no gated MCP-specific tier; you need either a Cloud account at any paid tier (Hobby and above) or a self-hosted instance reachable from the client. Free Cloud works too, with the standard usage caps applied to underlying API calls.
- Region and data residency. PostHog Cloud ships in US and EU regions. The MCP server must point at the same region your project lives in. A mismatch returns authentication errors, not a useful message.
- MCP client support. Claude Desktop is the canonical demo target and the simplest install path. Claude API users can wire it through the SDK. Codex CLI exposes MCP servers through its config layer, and Open WebUI's connector works with a small amount of plumbing.
- API scopes. The server uses a personal API key, not an OAuth app, by default. Keys live under Settings → Personal API Keys in PostHog. Treat them like a password — scope them to the project you want to expose.
- Connectivity. The client must reach PostHog's API over HTTPS. Many MCP hosts run the server as a local process that proxies requests outbound; nothing inbound needs to be open.
Pro tip: Generate one API key per MCP client, label it (e.g. claude-desktop-macbook), and revoke it the day you stop using that client. A leaked key gives full project read/write.
Step-by-step setup
The canonical install lives in the PostHog GitHub repo under plugins/mcp. The PostHog MCP docs mirror those instructions. Total time: roughly five minutes on a clean machine.
- Generate a personal API key. In PostHog, open Settings → Personal API Keys, click Create personal API key, give it a label, and pick All access (read-only is enough if you only want analytics). Copy the key — it is shown once.
- Locate your client's MCP config. For Claude Desktop, this is
~/.config/claude-desktop/claude_desktop_config.jsonon Linux,~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS, and%APPDATA%\Claude\claude_desktop_config.jsonon Windows. Codex CLI uses~/.codex/config.toml. - Add the PostHog server entry. Paste a block of the shape below, replacing the values for your environment. The
envkeys accept either a Cloud project key or a self-hosted host string.{ "mcpServers": { "posthog": { "command": "npx", "args": ["-y", "@posthog/mcp-server"], "env": { "POSTHOG_API_KEY": "phx_xxx", "POSTHOG_HOST": "https://us.i.posthog.com" } } } } - Restart the client. Claude Desktop only reads MCP config on launch. Close it fully — including the tray icon — and reopen.
- Verify the tool list. Open the chat, and ask: "What PostHog tools do you have access to?" The model should respond with the list of MCP tools it can now call. If the response is empty, jump to the Limits, edge cases, and known gotchas section.
- Run a smoke query. Ask: "How many distinct users triggered the
checkout_completedevent in the last 7 days?" The model should call the events tool, return a number, and cite the run. That ends the install.
No OAuth consent screen is involved when you use a personal API key. If you self-host and want SSO-scoped access instead, the PostHog MCP docs describe a per-user OAuth variant that triggers a browser consent flow on first connect.
The joint workflow in action
Picture this: a PM drops a Slack message — "did the new onboarding nudge actually move the activation metric?" You do not need to log into PostHog. You open Claude Desktop, the PostHog MCP server is wired up, and you ask the model to compare last week's activation rate against the prior two-week baseline, segmented by whether the user saw the nudge.
- The client calls the
list_eventstool to confirm the event names exist. - It calls the trend query tool with a date range and a property filter for
seen_nudge=true. - It repeats the query with
seen_nudge=falseas the property filter. - It returns a short write-up with the delta, plus the SQL it actually ran, so you can paste it into a saved insight later.
Latency in this path is dominated by PostHog's query engine, not the MCP transport. Expect two to ten seconds per tool call on Cloud, occasionally longer for cohort queries that hit large fact tables. Self-hosted latency tracks whatever your ClickHouse or Postgres backend delivers. Each tool call round-trips through the model's context, so a verbose answer costs more input tokens than a chart screenshot ever would — keep that in mind for cost modelling.
Limits, edge cases, and known gotchas
The PostHog MCP server is a young integration and a handful of rough edges show up in real use:
- Rate limits follow the underlying API. PostHog's REST endpoints have per-project rate caps. A chat session that loops through 50 funnels in a row can hit them; the model rarely retries gracefully.
- Long SQL queries time out. Some MCP hosts cap tool call duration at ~30 seconds. HogQL aggregations across high-cardinality properties sometimes exceed that and return a truncated result.
- Token expiry is silent. Personal API keys never expire automatically, but if you rotate your password you may invalidate the active session. The model reports a generic auth error, not "token expired".
- Pagination is not always transparent. Some tools return only the first page of results. If you ask for "all events last week" and get back 100, ask explicitly for pagination or a count summary instead of trusting the list.
- Feature flag writes are immediate. The server exposes flag toggles. Treat that capability with respect — flipping a production flag from a chat client is a single prompt away.
- Self-hosted auth headers differ. If you run PostHog OSS, the host string is your own URL and some clients need an extra
POSTHOG_PROJECT_IDenv var baked in. Skipping it leads to "project not found" errors that look like bugs in the server.
Common questions
Does PostHog have an MCP server?
Yes. PostHog ships an officially maintained MCP server on GitHub. It works with any MCP-compatible client — Claude Desktop is the most documented host, but Codex CLI, Open WebUI, and custom clients can connect to the same transport.
Is the PostHog MCP server free?
The server code is open source and free to install. You still pay for whatever PostHog plan your project sits on (free tier works for low-volume use) and for any tokens your LLM client consumes answering queries. There is no separate MCP licence fee.
Can I use the PostHog MCP server with Codex CLI?
Yes. Codex CLI reads MCP server entries from ~/.codex/config.toml. The same @posthog/mcp-server package works; you point POSTHOG_HOST at either the US or EU Cloud region, or at your self-hosted URL, and the tools appear in the model the same way they do in Claude Desktop.
What tools does the PostHog MCP server expose?
Typical tool set: list and inspect events, run HogQL/trend queries, list feature flags and their rollout state, fetch persons and their properties, read session replays by URL, list dashboards, and search PostHog's own docs. Exact names shift with each server release, so verify against your installed version.
How do I install the PostHog MCP server on Claude Desktop?
Add the JSON config block above to your platform-specific claude_desktop_config.json, set the POSTHOG_API_KEY and POSTHOG_HOST environment values, restart Claude Desktop, and ask the assistant to list its PostHog tools to confirm.
Where are the official PostHog MCP docs?
PostHog hosts them at posthog.com/docs/mcp. The GitHub README in posthog/posthog/plugins/mcp carries the same setup instructions plus the changelog.
Is there an analytics-only mode for the PostHog MCP server?
You can scope behaviour with the API key. A read-only key restricts the assistant to query tools and skips flag toggles or person mutations. That mode is the safest default for shared chat clients.
Once the server is wired in, the day-to-day experience is a chat thread that already knows your product. If you sell software that touches PostHog data — or are building AI tools that integrate with it — browse the PPToGo product catalogue for related tooling and creator shops already shipping in that space.