PostHog MCP Server – Product Analytics for AI Agents
PostHog provides a hosted Model Context Protocol server for connecting MCP-compatible AI agents to PostHog projects. Agents can use it to query analytics, work with feature flags and experiments, inspect errors and logs, manage dashboards and insights, and access other PostHog product workflows according to the authenticated user's permissions and configured tool scope.
Overview
PostHog's MCP server is a hosted Model Context Protocol endpoint for using PostHog from AI coding agents and desktop AI clients. It connects an authenticated agent session to PostHog products such as product analytics, feature flags, experiments, error tracking, logs, surveys, dashboards, SQL, CDP, and documentation search. The main value is that an agent can answer product and operational questions with live PostHog data instead of relying on screenshots, copied query results, or static knowledge.
What the MCP server enables
The hosted server exposes function-calling tools across PostHog's product surface. Verified workflows include running analytics queries, generating or executing HogQL, creating and updating insights, managing dashboards, creating and managing feature flags, inspecting error groups and stack traces, querying logs, exploring schemas, and searching PostHog documentation. PostHog documents stable tool names and supports scoping by tool name or feature category so a session can be limited to a smaller surface area.
When to use it
Use this MCP server when an AI agent needs product context while building, debugging, or analyzing software. Practical examples include asking whether a new checkout flow is performing better than last week, creating a funnel or trend insight, checking top events by volume, investigating a spike in errors, reviewing stack traces before proposing a code fix, or creating and scheduling a feature flag from the editor.
Connection and authentication
The hosted MCP endpoint is https://mcp.posthog.com/mcp. PostHog recommends OAuth for clients that support it, and the PostHog authentication server routes users to the correct US or EU data region based on the account they log in with. For clients that do not support OAuth, PostHog documents personal API key authentication using the Authorization: Bearer header with a personal API key created using the MCP Server preset. The context can also be pinned to a specific organization or project with headers or query parameters.
Key considerations
The server is hosted and works with MCP-compatible clients such as Claude Code, Claude Desktop, Cursor, Codex, VS Code, Windsurf, Zed, and others. Connecting to and calling the MCP server is free, but normal PostHog usage and billing still applies to the underlying data queried, and some AI-powered tools require AI data processing to be enabled. Because agents may perform write actions, users should review tool calls, restrict available tools with features or tools query parameters, and pin sessions to an organization or project where appropriate. PostHog also warns users to be mindful of prompt injection when allowing an agent to execute tool calls.
Supported Transports
streamable_http
URL: https://mcp.posthog.com/mcp
Frequently Asked Questions
- When should an AI agent use the PostHog MCP server?
- Use it when an agent needs live PostHog context while building, debugging, or analyzing a product, such as querying trends, funnels, retention, HogQL, error groups, logs, dashboards, or feature flag state from an MCP-compatible editor or assistant.
- What does the PostHog MCP server add to an AI agent's capabilities?
- It gives the agent authenticated access to PostHog tools for product analytics, feature flags, experiments, error tracking, logs, surveys, SQL, CDP workflows, dashboards, insights, documentation search, and related project context instead of relying on copied reports or static model knowledge.
- What can the AI agent access or manage through PostHog MCP?
- Depending on permissions and tool scope, the agent can run analytics queries, generate or execute HogQL, create and update insights and dashboards, manage feature flags and experiments, inspect and update error tracking workflows, query logs, explore schemas, manage surveys, and search PostHog documentation.
- How is authentication configured for the PostHog MCP server?
- OAuth is the recommended authentication method and works with PostHog's wizard and OAuth-capable MCP clients. For clients without OAuth support, PostHog documents personal API key authentication with the `Authorization: Bearer` header using a personal API key created with the MCP Server preset. Organization and project scoping can be pinned with documented headers or query parameters.
- Which transport should be used for the PostHog MCP server?
- Use the hosted Streamable HTTP endpoint at `https://mcp.posthog.com/mcp`. PostHog documents this hosted endpoint for MCP-compatible clients and provides a wizard command, `npx @posthog/wizard mcp add`, to install it into supported clients. This YAML includes the documented API-key header form for non-OAuth configurations.