﻿# Model Context Protocol (MCP) - Docs

Copy page

# Model Context Protocol (MCP) - Docs

The PostHog [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) 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 Desktop](/desktop.md), Claude Code, Claude Desktop, Cursor, Codex, VS Code, Windsurf, and Zed.

> Connecting to the MCP server and calling its MCP tools is free, but some MCP tools use LLMs internally and may be billed as PostHog AI spend. These AI-powered MCP tools are only available when [AI data processing is enabled](/docs/posthog-ai/allow-access.md) in your organization settings.

## Get started in 30 seconds

The fastest way to setup the MCP is the [PostHog Wizard](https://github.com/PostHog/wizard), which installs the MCP server directly into **PostHog Desktop**, **Cursor**, **Claude Code**, **Claude Desktop**, **Codex**, **VS Code**, and **Zed**:

### Install the PostHog MCP

[Learn more](/docs/model-context-protocol.md)

```
npx @posthog/wizard mcp add
```

Supports Next.js, React, Python, and 22 more

Claude

Cursor

VS Code

Windsurf

Codex

Zed

Lovable

Replit

v0

Using something else? Pick your client to set it up manually:

### Code editors

-   [PostHog Desktop](/docs/posthog-desktop.md)

-   [Claude Code](/docs/model-context-protocol/claude-code.md)

-   [Claude Desktop](/docs/model-context-protocol/claude-desktop.md)

-   [Codex](/docs/model-context-protocol/codex.md)

-   [Cursor](/docs/model-context-protocol/cursor.md)

-   [VS Code](/docs/model-context-protocol/vscode.md)

-   [Windsurf](/docs/model-context-protocol/windsurf.md)

-   [Zed](/docs/model-context-protocol/zed.md)

### Platforms

-   [Lovable](/docs/integrations/lovable.md)

-   [Replit](/docs/integrations/replit.md)

-   [v0](/docs/integrations/v0.md)

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?

Using Claude Code to debug and fix errors via the PostHog MCP server

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. You can also run governed metrics from your [semantic layer](/docs/semantic-layer.md) (alpha), so every agent session answers "what's our MRR?" with the same canonical definition.

**[Browse all use cases →](/docs/model-context-protocol/use-cases.md)**

## Go deeper

-   **[Use cases](/docs/model-context-protocol/use-cases.md)** – 20+ example prompts and multi-step recipes for the most useful MCP workflows
-   **[MCP tools reference](/docs/model-context-protocol/tools.md)** – every MCP tool the server exposes, grouped by category
-   **[FAQ and advanced setup](/docs/model-context-protocol/faq.md)** – auth, scoping, filtering, safety, and other operational details

## Next steps

-   [PostHog CLI](/docs/cli.md): Use PostHog from your terminal, coding agents, scripts, and CI/CD pipelines
-   [PostHog AI plugin](https://github.com/PostHog/ai-plugin): Install PostHog as a plugin for Claude Code, Codex, Cursor, and Gemini CLI
-   [Lovable integration](/docs/integrations/lovable.md): Set up PostHog in your Lovable project
-   [Replit integration](/docs/integrations/replit.md): Set up PostHog with Replit Agent
-   [v0 integration](/docs/integrations/v0.md): Set up PostHog with v0 and the Vercel Flags SDK
-   [PostHog MCP server on GitHub](https://github.com/PostHog/posthog/tree/master/services/mcp): The source for the MCP server
-   [PostHog VS Code extension](/docs/vscode-extension.md): Inline analytics, flag management, and session replay links in your editor
-   [Model Context Protocol](https://modelcontextprotocol.io/introduction): Learn more about the MCP specification
-   [MCP: machine/copy paste](/blog/machine-copy-paste-mcp-intro.md): What exactly is MCP again?

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be bet