PostHog MCP server

Integrates with the PostHog analytics platform to list projects and create timestamped annotations for tracking significant events and milestones in analytics data.
Back to servers
Provider
PostHog
Release date
Mar 08, 2025
Language
Python
Stats
35 stars

The PostHog MCP Server enables seamless interaction with PostHog from Claude Desktop. This integration allows you to view projects, create annotations, and manage various PostHog features directly through simple prompts in Claude Desktop.

Prerequisites

  • Python 3.10 or higher
  • uv package manager
  • PostHog API Key with annotation:write and project:read scopes from your project settings

Installation

Step 1: Clone the repository

# Using SSH
git clone [email protected]:PostHog/posthog-mcp.git

# Or using HTTPS
git clone https://github.com/PostHog/posthog-mcp.git

cd posthog-mcp

Step 2: Set up Python environment

uv venv
source .venv/bin/activate

# Install dependencies
uv pip install .

Step 3: Configure API key

Create a .env file in the project root with your PostHog API key:

PERSONAL_API_KEY=phx_your_posthog_api_key_here

Claude Desktop Integration

Setting up the MCP server

  1. Install Claude Desktop
  2. Open Claude Desktop settings and click "Edit Config" (or edit the config file directly)
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. Add the PostHog MCP server configuration:
{
  "mcpServers": {
    "posthog": {
      "command": "/path/to/uv",
      "args": [
        "--directory",
        "/path/to/your/posthog-mcp",
        "run",
        "posthog_mcp"
      ]
    }
  }
}

Note: Replace /path/to/uv with the actual path (find with which uv command) and /path/to/your/posthog-mcp with the full path to the cloned repository.

Using PostHog Features in Claude

After successful setup, you'll see a hammer 🔨 icon in Claude Desktop, indicating the MCP server is ready to use.

Viewing PostHog Projects

Simply ask Claude:

List my PostHog projects

Working with Insights

To access PostHog insights, try:

List my PostHog insights

Or search for specific insights:

Search for revenue insights in my PostHog

Creating Annotations

Create annotations on your projects by specifying the project ID:

Create a PostHog annotation in project 53497 saying 'Deployed v1.2.3'

To add an annotation with a specific date:

Create a PostHog annotation in project 53497 for March 20th saying 'Started new marketing campaign'

Searching Documentation

You can also use the integration to search for PostHog documentation:

How can I do reverse proxy in NextJS in PostHog?

Troubleshooting

If you encounter issues with the MCP server:

  • Restart Claude Desktop if the hammer icon doesn't appear
  • Check logs at:
    • macOS: ~/Library/Logs/Claude/mcp*.log
    • Windows: %APPDATA%\Claude\logs
  • Verify your PostHog API key has the correct permissions
  • Ensure all paths in claude_desktop_config.json are absolute paths

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later