How to Get Started with PostHog MCP Server

Discover how to install PostHog MCP Server on Cline in VS Code/Cursor, automate analytics with natural language, and see why PostHog outshines Google Analytics!

Ashley Goolam

Ashley Goolam

30 June 2025

How to Get Started with PostHog MCP Server

Ready to supercharge your data game with AI? The PostHog MCP Server lets you manage PostHog analytics—like creating annotations or querying user trends—using natural language in tools like Cline or Cursor. I got it up and running in only a few minutes, and it’s a total game-changer! In this tutorial, we’ll install the PostHog MCP Server on Cline in VS Code and Cursor, explore its killer features, and see why PostHog beats Google Analytics for open-source analytics. Let’s dive into the PostHog MCP Server magic!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

What is PostHog MCP Server?

The PostHog MCP Server is an open-source Model Context Protocol (MCP) server that connects AI assistants (like Cline or Cursor) to PostHog’s analytics platform via natural language commands. It enables tasks like creating annotations, managing projects, querying insights, and toggling feature flags—all without touching PostHog’s UI. Key features include:

It is a “must-have” for analytics automation, with 34+ GitHub stars showing community love. Ready to try it? Let’s go

official website

Why Use PostHog MCP Server?

The PostHog MCP Server simplifies analytics workflows with AI-driven automation. Here’s why it rocks:

Compared to Google Analytics, PostHog shines with its open-source transparency, self-hosting flexibility, and all-in-one product suite (analytics, session replay, feature flags). Google Analytics often requires third-party integrations and lacks PostHog’s privacy focus, making the PostHog MCP Server a developer-friendly alternative for modern teams.

I used it to annotate a product launch in seconds—way faster than clicking through dashboards!

How to Install and Use PostHog MCP Server: Step-by-Step Guide

Let’s install the PostHog MCP Server on Cline in VS Code and Cursor, then test it with examples. You’ll need Python, a PostHog API key, and an IDE. No analytics guru status required—follow along!

1. Prerequisites

2. Clone the PostHog MCP Repository

Open your terminal and clone the repo:

git clone https://github.com/PostHog/mcp.git
cd mcp

This pulls a ~5MB project. Took me a few seconds on Wi-Fi.

3. Install PostHog MCP Server with Cline in VS Code

uv venv
source .venv/bin/activate  # macOS/Linux
.venv\Scripts\activate  # Windows
uv pip install .
echo "PERSONAL_API_KEY=your-personal-api-key" > .env

Replace your-personal-api-key with your PostHog API key (which you can acquire from their official website).

install cline
Install the PostHog MCP Server using uv and configure it with my API key.

Cline runs uv run posthog_mcp and updates ~/.aws/amazonq/mcp.json:

{
  "mcpServers": {
    "posthog": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp", "run", "posthog_mcp"],
      "env": {
        "PERSONAL_API_KEY": "your-personal-api-key"
      }
    }
  }
}

Replace /path/to/mcp with your repo path (e.g., /home/user/mcp).

The mcp server can also be found on cline's mcp marketplace. Simply head over there and search for "PostHog", then click install.

install psthog mcp server

Cline will automaticaly perform the installation for you

mcp servers icon

4. Install PostHog MCP Server with Cursor

cursor mcp servers
{
  "mcpServers": {
    "posthog": {
      "command": "/path/to/uv",
      "args": ["--directory", "/path/to/mcp", "run", "posthog_mcp"],
      "env": {
        "PERSONAL_API_KEY": "your-personal-api-key"
      }
    }
  }
}

Find uv path with which uv (macOS/Linux) or where uv (Windows).

5. Test PostHog MCP Server Features

Create a PostHog annotation in project 53497 for March 20th, 2025, with the description 'Launched new user onboarding flow' using the PostHog MCP Server.

The server calls PostHog’s API, adding the annotation. Check app.posthog.com to confirm.

Show the trend of user sign-ups in project 98765 over the last 30 days using 
the PostHog MCP Server.

The server fetches structured data (e.g., JSON with sign-up trends). Example output:

{
  "insight": "user_signups",
  "project_id": 98765,
  "data": [
    {"date": "2025-06-01", "count": 120},
    {"date": "2025-06-02", "count": 135}
  ]
}

I ran this and got clean data in ~5 seconds—super slick

6. Containerized Setup (Optional)

docker

For a Docker setup:

docker run -i --rm -e PERSONAL_API_KEY=your-personal-api-key ghcr.io/metorial/mcp-container--posthog--posthog-mcp--posthog-mcp posthog-mcp

Add to Cline/Cursor’s mcp.json:

{
  "mcpServers": {
    "posthog": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "ghcr.io/metorial/mcp-container--posthog--posthog-mcp--posthog-mcp", "posthog-mcp"],
      "env": {
        "PERSONAL_API_KEY": "your-personal-api-key"
      }
    }
  }
}

Restart and verify as above. Docker’s cleanup (--rm) saved me disk space

7. Troubleshoot Common Issues

Why PostHog Beats Google Analytics

PostHog’s PostHog MCP Server integrates with its platform, which outshines Google Analytics in:

I switched a side project to PostHog and loved the privacy and feature flag control—no Google Analytics bloat!

Customizing and Extending PostHog MCP Server

Level up your setup:

Generate a Python snippet to toggle feature flag 'new-ui' in project 12345
using the PostHog MCP Server.

Why PostHog MCP Server is a Dev Must-Have

The PostHog MCP Server makes analytics automation feel like chatting with a data guru. Its natural language interface and PostHog’s open-source edge beat Google Analytics for privacy-conscious teams. Setup can be finicky (API key woes!), but the PostHog docs and community are lifesavers.

Ready to rock the PostHog MCP Server? Fire up Cline or Cursor, query those insights, and share your analytics wins—I’m stoked to see your setup shine!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

Apigee vs Kong: Comprehensive Guide to Choosing the Right API Gateway

Apigee vs Kong: Comprehensive Guide to Choosing the Right API Gateway

Choosing the right API gateway can shape your app’s performance, security, and scalability. This guide breaks down Apigee vs Kong—comparing features, use cases, developer experience, and when to use each. Plus, see how Apidog fits in to streamline your API workflow from design to deployment.

1 August 2025

Web Services vs Microservices: What's the Difference

Web Services vs Microservices: What's the Difference

Explore the key differences between web services and microservices. Learn when to use each architecture, real-world examples, and how Apidog simplifies API management across both styles. Get insights and a free tool to streamline your API strategy today!

1 August 2025

Google Cloud API Gateway vs Apigee: Hands-On Guide

Google Cloud API Gateway vs Apigee: Hands-On Guide

An in-depth comparison of Google Cloud API Gateway vs Apigee. Learn when to use each, how Apidog helps you work smarter, and what makes a great API stack.

1 August 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs