Model Context Protocol (MCP)
Contents
The PostHog Model Context Protocol (MCP) server is a free, hosted endpoint that lets your AI agent use PostHog – with just plain text questions your agents can ship a feature flag from a prompt, dig into a stack trace without leaving your editor, run a HogQL query through Claude, triage a support ticket, set up a CDP destination, and much more.
It works with any MCP-compatible client, including PostHog Code, Claude Code, Claude Desktop, Cursor, Codex, VS Code, Windsurf, and Zed.
Get started in 30 seconds
The fastest way to setup the MCP is the PostHog Wizard, which installs the MCP server directly into PostHog Code, Cursor, Claude Code, Claude Desktop, Codex, VS Code, and Zed:
Using something else? Pick your client to set it up manually:
Code editors
Platforms
The server URL is https://mcp.posthog.com/mcp. The PostHog authentication server automatically routes you to the correct data region (US or EU) based on the account you log in with.
What can you do with the PostHog MCP?
Once connected, your agent can read and write across PostHog's products. Here's a taste – triaging errors from inside your editor instead of context-switching to a browser:
"What are the top 5 errors in my project this week?" – Returns error groups ranked by occurrence with affected user counts.
"Show me the full stack trace for the most recent crash, then propose a fix." – Pulls the stack trace, error message, and metadata so the agent can suggest code changes.
"Mark this issue as resolved and assign all future TypeErrors to the backend team." – Updates issue status and creates an assignment rule in one go.
There's a lot more – analytics queries, feature flag and experiment management, SQL, CDP destinations, support ticket triage, and multi-step recipes that chain it all together.
Go deeper
- Use cases – 20+ example prompts and multi-step recipes for the most useful MCP workflows
- Tools reference – every tool the MCP server exposes, grouped by category
- FAQ and advanced setup – auth, scoping, filtering, safety, and other operational details
Next steps
- PostHog AI plugin: Install PostHog as a plugin for Claude Code, Codex, Cursor, and Gemini CLI
- Lovable integration: Set up PostHog in your Lovable project
- Replit integration: Set up PostHog with Replit Agent
- v0 integration: Set up PostHog with v0 and the Vercel Flags SDK
- PostHog MCP server on GitHub: The source for the MCP server
- PostHog VS Code extension: Inline analytics, flag management, and session replay links in your editor
- Model Context Protocol: Learn more about the MCP specification
- MCP: machine/copy paste: What exactly is MCP again?