# PostHog MCP for AI Agents AI Agent Connect

> PostHog lets you manage product analytics and feature flags directly through your AI agent. You can query event data, inspect user cohorts, toggle flags, and create timeline annotations without leaving your workspace. It turns your AI into a product operations assistant that understands your user behavior and deployment history.

## Overview
- **Category:** loved-by-devs
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_8VcsMkOZnGEFbUxwKe3mMQLdbs42FUTalA4xKqKJ/ai-agent-connect
- **Tags:** product-analytics, feature-flags, session-replay, experimentation, user-cohorts, event-tracking

## Description

PostHog lets you manage product analytics and feature flags directly through your AI agent. Instead of switching between your code editor and a browser to check a rollout status, you can just ask your agent for the details. This Connector connects your account so you can pull up specific user profiles to see exactly what they clicked on, check the status of a feature flag in production, or see which cohorts are currently active. It takes the friction out of data exploration and keeps your product operations moving. When you need to know why a metric spiked, you can have your agent look for annotations or recent event types to find the culprit. It works like having a dedicated product analyst who lives inside your chat window. By using Vinkius to host this connection, you get a reliable way to keep your analytics and feature management in sync with your actual work. You stop hunting for IDs and start making decisions based on the data you need, right when you need it. You can manage your entire product lifecycle through a simple conversation, whether you're auditing rollout percentages or reviewing cohort definitions for a new launch. It's about getting the answers you need without the UI overhead.

## Tools

### list_cohorts
View all behavioral cohorts and their filter definitions. This helps you see who is in your target groups.

### list_events
Browse through recent events and filter them by type. This is great for inspecting event properties.

### list_feature_flags
List every flag in your project. Use this to audit your coverage and active rollouts.

### create_annotation
Add a note to your insights graphs to mark a deployment or launch. This helps you see why metrics changed in the past.

### create_feature_flag
Create a new flag with a unique key and name. You can also set rollout percentages and filters.

### delete_feature_flag
Permanently remove a flag and its data using its ID. This action is irreversible.

### get_feature_flag
Get the full details of a specific flag. Use this to check its status and configuration.

### get_person
Look up a specific user profile by their distinct ID. You'll see their properties and activity timeline.

### get_user
View your current account details and permissions. Use this to verify your API key is active.

### list_annotations
List all the markers you've placed on your timeline graphs. This shows deployments and launches.

### list_persons
See a list of users tracked in your account. You can also filter by creation date or activity.

### list_projects
List all the analytics projects in your organization. This shows your different workspaces.

### update_feature_flag
Update the name, description, or status of a flag. Only the fields you provide will change.

## Prompt Examples

**Prompt:** 
```
Which feature flags are currently active and what are their rollout percentages?
```

**Response:** 
```
I've pulled the current status for your flags:

| Flag Key | Name | Status | Rollout |
| :--- | :--- | :--- | :--- |
| `new-checkout` | New Checkout Flow | **Active** | 80% |
| `dark-mode` | Dark Mode | **Active** | 100% |
| `ai-suggestions` | AI Suggestions | **Active** | 25% |
| `beta-dashboard` | Beta Dashboard | **Active** | 50% |
| `export-v2` | Export v2 | **Active** | 100% |

There are also 3 flags currently disabled: `legacy-search`, `old-onboarding`, and `deprecated-api`.
```

**Prompt:** 
```
Create an annotation for today's deployment of version 3.2.0.
```

**Response:** 
```
Done! I've created an annotation **'Deployed v3.2.0'** pinned to today's date. This will show up on your insights graphs so you can easily see how it impacted your metrics.
```

**Prompt:** 
```
Can you show me the profile for user 'user_12345'?
```

**Response:** 
```
Here is the profile for **user_12345**:

*   **Email:** jane@example.com
*   **Signed Up:** 3 months ago
*   **Last Active:** 2 hours ago
*   **Properties:** 
    *   Plan: `premium`
    *   Company: `Acme Inc`
    *   Role: `admin`

**Activity Summary:**
They've triggered **847 events** total, including 120 pageviews and 45 purchases.
```

## Capabilities

### Toggle feature flags
Change the status or rollout percentage of your flags instantly.

### Inspect user activity
Pull up a specific user's profile to see their properties and activity timeline.

### Audit project cohorts
Review all behavioral cohorts and the filters that define them.

### Manage timeline markers
Create and list annotations to mark deployments and launches on your graphs.

### Query event data
Browse through recent events and filter them by type or specific properties.

### Verify account access
Check your current user permissions and project list to ensure your connection is active.

## Use Cases

### Emergency flag toggle
A developer notices a bug in production and asks their agent to use update_feature_flag to disable a feature immediately.

### User behavior deep dive
A support lead asks the agent to pull a profile using get_person to see what actions a specific user took before a crash.

### Launch audit
A PM asks the agent to list_annotations to see which deployments occurred during a recent drop in conversion rates.

### Cohort verification
An analyst asks the agent to list_cohorts to check if the correct filter logic is applied to the beta test group.

## Benefits

- Stop hunting through dashboards to check if a flag is live. Use list_feature_flags to see everything at once.
- Get instant context on user behavior. Use get_person to see a specific user's history in seconds.
- Keep your timeline clean. Use create_annotation to mark launches so you know why metrics moved.
- Manage cohorts without the UI. Use list_cohorts to review filter definitions while you're coding.
- Quickly debug event data. Use list_events to see exactly what properties were sent during a specific action.

## How It Works

The bottom line is you get a direct line to your product data without the UI overhead.

1. Subscribe to the PostHog MCP on Vinkius.
2. Enter your PostHog Personal API Key in the configuration.
3. Ask your AI client to check flag statuses, list events, or find users.

## Frequently Asked Questions

**How can I use PostHog with my AI agent?**
You can connect your PostHog account to your AI agent using this Connector. Once connected, you can ask your agent to perform tasks like checking flags, listing events, or looking up user profiles using plain English.

**Can I toggle feature flags using the PostHog MCP?**
Yes, you can. Your agent can update the status and rollout percentages of your flags directly, which helps you manage releases without leaving your current workspace.

**How do I see user activity using PostHog?**
You can ask your agent to pull a specific user's profile. It will return their properties, sign-up date, and a timeline of their recent activity.

**Can the PostHog MCP create annotations?**
Yes, it can. You can tell your agent to create an annotation for a specific event, like a deployment or a launch, to mark it on your timeline graphs.

**Is it safe to delete flags with the PostHog MCP?**
Yes, you can delete flags using the Connector, but be careful. This action is permanent and will remove all associated targeting conditions and experiment data.

**How do I check my project cohorts?**
You can ask your agent to list your cohorts. It will show you the names, descriptions, and the filter definitions for all your behavioral groups.

**How do I create a PostHog Personal API Key?**
Log in to [**PostHog**](https://app.posthog.com), click your profile icon > **Personal API keys**, then **+ Create a Personal API Key**. Give it a label, select the required scopes and copy the key immediately — it won't be shown again after page refresh.

**Can I toggle feature flags via the agent?**
Yes! Use `create_feature_flag` to add new flags, `update_feature_flag` to modify existing ones (name, description, enabled status), and `delete_feature_flag` to remove them. You'll need the numeric flag ID from `list_feature_flags` for update and delete operations.

**What's the difference between events and persons?**
**Events** are actions that happen in your product (pageviews, button clicks, purchases). **Persons** are the users who perform those actions, identified by distinct_id. Events are linked to persons, so you can see what actions a specific user has taken. Use `list_events` to browse activity and `get_person` to see a user's profile.

**Can I use this with a self-hosted PostHog instance?**
Yes! The tools default to `https://app.posthog.com` for the US cloud, but you can set the `host` parameter to your self-hosted instance URL (e.g. `https://posthog.yourcompany.com`). EU cloud users should set the host to `https://eu.posthog.com`.