# PostHog MCP

> PostHog connects product analytics and feature management directly into your AI agent. Use this server to list insights, inspect user properties, track events, and manage features flags—all from a single conversation with your client.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** product-analytics, feature-flags, user-behavior, event-tracking, funnel-analysis, retention-metrics

## Description

You're hooking your **PostHog** project up to your AI agent so you can run product analytics and feature management straight through conversation. You don't need to jump between dashboards or write complex queries; you just talk to your client, and it handles the data retrieval.

When you need to dig into user behavior, you start by calling `list_persons` to get a full roster of unique identifiers across the project. This gives you a list of every person who's interacted with the product. From there, if you know an ID, you use `get_person` to pull up all their associated properties and behavior metrics. That lets you see exactly what that specific user did—it’s like having a perfect audit trail on demand.

To check what users were doing moment-to-moment, you can list the most recent system events using `list_events`. This gives you an immediate overview of activity across the board. If you find an event ID and need the full story, calling `get_event` pulls every specific detail tied to that single occurrence. It's how you audit data ingestion or verify a user action.

For deep product analysis, you’ve got tools for everything. You can list all saved analytics insights using `list_insights`, which shows you the high-level trends already identified in your project. Need the juicy details? Calling `get_insight` pulls specific metadata for that insight—that's where you find funnel data and retention metrics, making sure your conclusions are backed by hard numbers.

When managing product features, you can list every single feature flag defined in the project via `list_feature_flags`, which shows its current configuration state. If you need to know what actions users take—like clicking 'checkout' or 'save profile'—you use `list_actions` to get a full catalog of user-defined events available for tracking.

You can also check out the structure of your data by retrieving all existing project dashboards with `list_dashboards`. If you're running tests, calling `list_experiments` gives you a list of every active or completed product experiment. Finally, if you need to know what kinds of systems are tracking things, `list_actions` provides that full catalog.

This setup lets your AI client act like it’s sitting right next to you in the analytics department, giving you immediate access to user profiles, activity logs, feature status, and saved insights without ever leaving the chat window.

## Tools

### get_event
Gets specific details for an event by its ID.

### get_insight
Retrieves detailed metadata for a specific saved insight.

### get_person
Fetches all properties and details for one identified person/user.

### list_actions
Lists every defined user action available in the project.

### list_dashboards
Retrieves a list of all existing project dashboards.

### list_events
Lists the most recent project events captured by your system.

### list_experiments
Retrieves a list of all active and past product experiments.

### list_feature_flags
Lists every feature flag defined in the project, along with its status.

### list_insights
Retrieves a list of all saved analytics insights for the project.

### list_persons
Lists a collection of identified persons and unique user IDs.

## Prompt Examples

**Prompt:** 
```
List all saved insights in our PostHog project.
```

**Response:** 
```
I've retrieved 12 saved insights. Some of the most recent ones are 'Daily Active Users', 'Signup Funnel', and 'Feature Adoption Trend'.
```

**Prompt:** 
```
Check the status of all feature flags.
```

**Response:** 
```
You have 8 feature flags. 5 are currently active (e.g., 'new-onboarding-flow', 'beta-search') and 3 are disabled.
```

**Prompt:** 
```
List the last 5 persons identified in our project.
```

**Response:** 
```
I've fetched the latest identified users. Here are the 5 most recent persons, including their distinct IDs and key properties like email and signup date.
```

## Capabilities

### Check user activity logs
List, retrieve, and audit recent system events that happened in the PostHog project.

### Get specific feature details
Retrieve metadata for saved product insights, including funnels and retention data.

### Investigate individual user profiles
Look up properties and behavior metrics for a distinct identified person/user.

### List all defined system actions
Retrieve the full catalog of user-defined actions available in your project.

### Examine feature flag status
Get a list of every feature flag and its current configuration state.

## Use Cases

### Debugging a broken checkout flow
A user notices the checkout button isn't working. Instead of manually checking logs, they ask their agent to run `list_events` and filter by 'checkout_failure'. The agent returns the last five relevant events, showing exactly which step failed and for which person ID.

### Checking a new feature's rollout status
The PM needs to know if the beta team has access to the new dashboard. They run `list_feature_flags` and check the 'new-dashboard-access' flag. The agent confirms it's active for the 'beta' segment, solving the problem instantly.

### Investigating a high churn rate
The data team suspects users are dropping off after signup. They ask their agent to `list_insights` and focus on 'Signup Funnel'. The returned metadata highlights a drop-off at the payment screen, guiding the next engineering sprint.

### Validating user identification
A developer is debugging an API call for a specific client. They use `list_persons` to find the correct unique ID and then pass that ID into `get_person`, retrieving all associated properties (email, signup date) needed for validation.

## Benefits

- Check flag status instantly. Instead of navigating the UI to see if a feature is on or off, just ask your agent using `list_feature_flags`. You get the current config state immediately.
- Audit user actions without leaving your terminal. If you suspect data gaps, call `list_events` to pull the most recent event logs and verify everything was captured correctly.
- Understand individual users deeply. Don't just look at group totals; use `get_person` to fetch specific properties for an identified user ID. This pinpoints unique behavior patterns.
- Track product hypotheses efficiently. Call `list_experiments` to see a full history of tests run, letting you compare results from past A/B tests against current goals.
- Get quick access to known funnels. Use `list_insights` to retrieve names and basic metadata for saved analytics insights like 'Signup Funnel' or 'Daily Active Users'.

## How It Works

The bottom line is, you analyze product data directly from your agent without leaving your current workflow or opening the PostHog dashboard.

1. Subscribe to the server, then enter your PostHog Personal API Key and Project ID.
2. If needed (e.g., for EU instances), provide the specific PostHog Host address.
3. Ask your AI client a question—like 'What's the status of the checkout flag?' — and get an immediate answer.

## Frequently Asked Questions

**How do I check if a feature flag is active using list_feature_flags?**
You ask your agent to run `list_feature_flags`. The response will give you the name of the flag and its current configuration status (e.g., 'active', 'disabled'), letting you know exactly who can access it.

**Can I use get_person to find a user's email address?**
Yes, `get_person` retrieves all properties associated with an identified person. You simply ask for the details of the person ID, and the agent will return key properties like their email or signup date.

**What is list_events used for in debugging?**
Use `list_events` to check data ingestion. If a user reports an issue, calling this tool retrieves the most recent events captured by your project, letting you verify if the action even registered.

**Does list_insights show me all my funnels?**
No, `list_insights` lists saved insights (funnel definitions, trend charts). You must then prompt the agent to retrieve details for a specific insight name using `get_insight`.

**When I use list_persons, what specific parameters should I pass to filter for a single person by their unique ID?**
You must provide the distinct user ID in the query parameters. If you include other criteria like email or signup date without the ID, the search returns a list of matches instead of the full record.

**If I call get_event with an incorrect Event ID, what error response should my AI client expect?**
The system will return a 404 Not Found status code and include a specific message stating that the requested event identifier does not exist in your PostHog project.

**How do I handle pagination or rate limits when listing many items using list_experiments?**
The tool supports standard cursor-based pagination. If you need more results than the default batch size, you must pass the `next_cursor` token received in the previous successful response.

**Using list_actions, how does PostHog distinguish between a user action and a general event?**
A defined 'Action' is an explicit, recognized event type that you set up within PostHog for consistent tracking. A raw 'Event' is any data point recorded by the user without prior formal definition.

**Where do I find my Project ID?**
You can find your Project ID in PostHog under **Project Settings**. It is a numeric ID usually found at the top of the settings page.

**Does this support PostHog EU instances?**
Yes! Use the optional `POSTHOG_HOST` credential and set it to `https://eu.posthog.com`. By default, it uses the US host (`https://app.posthog.com`).

**Can I see individual user properties?**
Absolutely. Use the `get_person` tool with a Person ID to retrieve all properties, tags, and identification metadata for a specific user.