Ready to automate your analytics workflow and gain deeper insights using AI? The PostHog MCP Server lets you control PostHog analytics directly from your IDE—using natural language commands in tools like Cline and Cursor. In this guide, you’ll learn how to install and use PostHog MCP Server, discover its powerful features, and see why open-source PostHog is a smart alternative to Google Analytics for privacy-minded developer teams.
💡 Looking for an API testing platform that creates beautiful API Documentation and streamlines developer collaboration for maximum productivity? Apidog brings it all together—replacing Postman at a much more affordable price.
What Is PostHog MCP Server?
The PostHog MCP Server is an open-source Model Context Protocol (MCP) server, designed to bridge AI-powered IDE plugins like Cline or Cursor with your PostHog analytics instance. By translating natural language instructions into analytics operations, it eliminates the need to navigate complex dashboards.
Core capabilities include:
- Project Management: List and manage PostHog projects from your IDE.
- Annotations: Instantly add timestamped notes for releases or incidents.
- Insights Queries: Analyze user behavior and trends with simple prompts.
- Feature Flags: Dynamically control feature rollout and test toggles.
- Error Tracking: Debug analytics issues directly within your workflow.
With over 30 GitHub stars and growing community support, PostHog MCP Server is quickly becoming essential for automated analytics.
Why Developers Use PostHog MCP Server
PostHog MCP Server empowers engineering teams to:
- Streamline Analytics: Manage analytics tasks using natural language, speeding up workflows.
- Integrate Seamlessly: Compatible with Claude Desktop, VS Code, Cursor, and more.
- Stay Open Source: Customize and self-host for full control and transparency.
- Prioritize Privacy: Unlike Google Analytics, PostHog offers robust self-hosting to keep your data private.
Example:
Instead of clicking through dashboards, instantly annotate a product launch or pull user sign-up trends—all from your IDE.
Step-by-Step: Installing and Using PostHog MCP Server
Follow these steps to get started with PostHog MCP Server in Cline (VS Code) and Cursor.
1. Prerequisites
- Python: Version 3.8+ (
python3 --version) - uv: Python package manager (
pip install uv) - VS Code or Cursor: Latest version, with Cline extension for VS Code
- PostHog API Key: Generate from app.posthog.com/settings
- Docker: (Optional) For containerized setup (
docker --version) - Disk space: ~500MB
2. Clone the PostHog MCP Server Repository
Open your terminal and run:
git clone https://github.com/PostHog/mcp.git
cd mcp
3. Install & Configure in VS Code with Cline
Set up the environment and connect your PostHog API.
uv venv
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
uv pip install .
Create a .env file with your API key:
echo "PERSONAL_API_KEY=your-personal-api-key" > .env
In VS Code:
- Install the Cline extension (Ctrl+Shift+X, search “Cline”).
- Open the Cline chat panel (Ctrl+Shift+P, “Cline: Open Chat”).

Add the MCP Server via prompt in Cline:
Install the PostHog MCP Server using uv and configure it with my API key.
Cline will run the server and update your config:
{
"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 local repo path.
Or, find PostHog MCP in Cline’s marketplace and click install.

Cline will automatically perform the installation.
Verify by running /tools in Cline’s chat. You should see tools like create_annotation and list_projects.

4. Set Up in Cursor
- Repeat the clone and virtual environment setup from Step 2.
- In Cursor, go to Settings > Tools & Integrations > MCP Tools > Add a Custom MCP Server.
- Add your server config to
.cursor/mcp.json:

{
"mcpServers": {
"posthog": {
"command": "/path/to/uv",
"args": ["--directory", "/path/to/mcp", "run", "posthog_mcp"],
"env": {
"PERSONAL_API_KEY": "your-personal-api-key"
}
}
}
}
Find your uv path with which uv (macOS/Linux) or where uv (Windows).
Restart Cursor and verify by prompting:
List available PostHog MCP Server tools.
5. Practical Examples: Using PostHog MCP Server
-
Create an Annotation:
In Cline/VS Code or Cursor, prompt:Create a PostHog annotation in project 53497 for March 20th, 2025, with the description 'Launched new user onboarding flow' using the PostHog MCP Server.
Check your annotation in PostHog’s dashboard.
-
Query Insights:
Prompt:Show the trend of user sign-ups in project 98765 over the last 30 days using the PostHog MCP Server.
Example output:
{ "insight": "user_signups", "project_id": 98765, "data": [ {"date": "2025-06-01", "count": 120}, {"date": "2025-06-02", "count": 135} ] }
6. Optional: Containerized (Docker) Setup

Run the MCP server in Docker:
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 this configuration to your Cline/Cursor 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 --rm flag keeps your system clean.
7. Troubleshooting Common Issues
-
No Hammer Icon in UI:
- Check logs:
~/Library/Logs/Claude/mcp*.log(macOS) or%APPDATA%\Claude\logs(Windows). - Ensure paths in
mcp.jsonare absolute.
- Check logs:
-
API Key Errors:
- Double-check permissions at app.posthog.com/settings.
- Use environment variables for sensitive info.
-
Server Not Running:
- Run
uv run posthog_mcpmanually to check for errors. - Confirm Python 3.8+ and dependencies are installed.
- Run
-
Need Help?
- Visit github.com/PostHog/mcp or search developer forums.
PostHog vs. Google Analytics: Developer Perspective
Why do technical teams choose PostHog over Google Analytics?
- Open Source: Self-hosted, customizable, and free from vendor lock-in.
- Privacy: Full control—no forced data sharing with third parties.
- All-in-One Suite: Analytics, session replay, feature flags, and experiments in a single platform.
- Automation: Natural language analytics via MCP Server—no more manual dashboard work.
- Vibrant Community: 1,500+ GitHub stars and active support channels.
If your team values privacy, automation, and extensibility, PostHog MCP Server is a strong fit.
Customizing and Extending PostHog MCP Server
You can tailor PostHog MCP Server to your needs:
-
Custom Tools: Add tools (e.g., custom SQL insights) via github.com/PostHog/mcp.
-
Multi-Project Queries: Easily list and manage all projects in your org.
-
Feature Flags: Generate code snippets for flag toggling:
Generate a Python snippet to toggle feature flag 'new-ui' in project 12345 using the PostHog MCP Server.
-
Contribute: Submit pull requests and improvements to benefit the PostHog community.
Why PostHog MCP Server Belongs in Your Dev Toolkit
The PostHog MCP Server brings analytics automation into your IDE, letting you interact with data as naturally as chatting with a teammate. With open-source flexibility and privacy-first design, it outperforms Google Analytics for modern developer teams.
For API developers and engineering leads, automating analytics tasks is just the start. Tools like Apidog further enhance your workflow—offering beautiful API documentation, integrated team collaboration, and seamless API test management—all at a lower cost than Postman.



