PostHog MCP for Zed
Contents
The PostHog MCP server enables Zed to directly interact with your PostHog data – managing feature flags, querying analytics, investigating errors, and more.
Server URL
| Region | URL |
|---|---|
| US (default) | https://mcp.posthog.com/mcp |
| EU | https://mcp-eu.posthog.com/mcp |
Quick install
The PostHog Wizard can install the MCP server directly into Zed:
Manual setup
- Open Zed and update
settings.jsonwith the following configuration:
- Save the configuration file
- The PostHog MCP server will be available
When you first use the MCP server, you'll be prompted to log in to PostHog to authenticate.
Be mindful of prompt injection – LLMs can be tricked into following untrusted commands, so always review tool calls before executing them.
Using an API key instead of OAuth?
If your MCP client doesn't support OAuth, you can authenticate manually:
- Create a personal API key using the MCP Server preset (this scopes access to a specific project)
- Add the
Authorization: Bearer YOUR_API_KEYheader to your MCP configuration
Example for Cursor (add to .cursor/mcp.json):
Pinning to a specific organization or project?
If you're building a programmatic integration or want to restrict the MCP session to a specific organization or project, you can pin the context using headers or query parameters.
When you pin the context, the switch-organization and switch-project tools are automatically excluded from the available tool list:
- When
projectIdis provided: bothswitch-organizationandswitch-projectare excluded - When only
organizationIdis provided: onlyswitch-organizationis excluded
Headers:
x-posthog-organization-id- Pin to a specific organizationx-posthog-project-id- Pin to a specific project
Query parameters:
organization_id- Pin to a specific organizationproject_id- Pin to a specific project
Example for Cursor (add to .cursor/mcp.json):
Filtering available tools by feature?
You can limit which tools are available by adding a features query parameter to the MCP URL. If no features are specified, all tools are available. When features are specified, only tools matching those features are exposed.
Available features:
| Feature | Description |
|---|---|
workspace | Organization and project management |
actions | Action definitions |
activity_logs | Activity log viewing |
alerts | Alert management |
annotations | Annotation management |
cohorts | Cohort management |
dashboards | Dashboard creation and management |
data_schema | Data schema exploration |
data_warehouse | Data warehouse management |
debug | Debug and diagnostic tools |
docs | PostHog documentation search |
early_access_features | Early access feature management |
error_tracking | Error monitoring and debugging |
events | Event and property definitions |
experiments | A/B testing experiments |
flags | Feature flag management |
hog_functions | CDP function management |
hog_function_templates | CDP function template browsing |
insights | Analytics insights |
llm_analytics | LLM analytics evaluations |
prompts | LLM prompt management |
logs | Log querying |
notebooks | Notebook management |
persons | Person and group management |
reverse_proxy | Reverse proxy record management |
search | Entity search across the project |
sql | SQL query execution |
surveys | Survey management |
workflows | Workflow management |
Note: Hyphens and underscores are treated as equivalent in feature names (e.g.,
error-trackinganderror_trackingboth work).
Example for Cursor (add to .cursor/mcp.json):
Available tools
Tools trigger actions on behalf of the user based on the goals and information already in the context of the LLM.
Here's a list of tools we provide:
Actions
| Tool | Purpose |
|---|---|
action-create | Create action |
action-delete | Delete action |
action-get | Get action |
action-update | Update action |
actions-get-all | Get all actions |
Activity logs
| Tool | Purpose |
|---|---|
activity-logs-list | List activity logs |
Alerts
| Tool | Purpose |
|---|---|
alert-create | Create alert |
alert-delete | Delete alert |
alert-get | Get alert |
alert-simulate | Simulate detector on insight |
alert-update | Update alert |
alerts-list | List alerts |
Annotations
| Tool | Purpose |
|---|---|
annotation-create | Create annotation |
annotation-delete | Delete annotation |
annotation-retrieve | Retrieve annotation |
annotations-list | List annotations |
annotations-partial-update | Update annotation |
Cohorts
| Tool | Purpose |
|---|---|
cohorts-add-persons-to-static-cohort-partial-update | Add persons to static cohort |
cohorts-create | Create cohort |
cohorts-list | List all cohorts |
cohorts-partial-update | Update cohort |
cohorts-retrieve | Get cohort |
cohorts-rm-person-from-static-cohort-partial-update | Remove person from static cohort |
Dashboards
| Tool | Purpose |
|---|---|
dashboard-create | Create dashboard |
dashboard-delete | Delete dashboard |
dashboard-get | Get dashboard |
dashboard-reorder-tiles | Reorder dashboard tiles |
dashboard-update | Update dashboard |
dashboards-get-all | Get all dashboards |
Data schema
| Tool | Purpose |
|---|---|
read-data-schema | Explore the user's events, actions, properties, and property values. |
read-data-warehouse-schema | Read core data warehouse schemas and table lists. |
Data warehouse
| Tool | Purpose |
|---|---|
view-create | Create saved query |
view-delete | Delete saved query |
view-get | Get saved query |
view-list | List saved queries |
view-materialize | Materialize saved query |
view-run | Run saved query |
view-run-history | Get run history |
view-unmaterialize | Revert materialization |
view-update | Update saved query |
Debug
| Tool | Purpose |
|---|---|
debug-mcp-ui-apps | Debug tool for testing MCP Apps SDK. |
Documentation
| Tool | Purpose |
|---|---|
docs-search | Search the PostHog documentation for information. |
Early access features
| Tool | Purpose |
|---|---|
early-access-feature-create | Create early access feature |
early-access-feature-destroy | Delete early access feature |
early-access-feature-list | List early access features |
early-access-feature-partial-update | Update early access feature |
early-access-feature-retrieve | Get early access feature |
Error tracking
| Tool | Purpose |
|---|---|
error-details | Get the details of an error in the project. |
error-tracking-issues-list | List error tracking issues |
error-tracking-issues-partial-update | Update error tracking issue |
error-tracking-issues-retrieve | Get error tracking issue |
list-errors | List errors in the project. |
update-issue-status | Update the status of an error tracking issue. |
Events & properties
| Tool | Purpose |
|---|---|
event-definition-update | Update an event definition's metadata. |
event-definitions-list | List all event definitions in the project with optional filtering. |
properties-list | Get properties for events or persons. |
Experiments
| Tool | Purpose |
|---|---|
experiment-create | Create A/B test experiment with guided metric and feature flag setup |
experiment-delete | Delete an experiment by ID. |
experiment-get | Get details of a specific experiment. |
experiment-get-all | Get all experiments in the project. |
experiment-results-get | Get comprehensive experiment results including metrics and exposure data. |
experiment-update | Update an existing experiment with lifecycle management and restart capability. |
Feature flags
| Tool | Purpose |
|---|---|
create-feature-flag | Create feature flag |
delete-feature-flag | Delete feature flag |
feature-flag-get-all | Get all feature flags |
feature-flag-get-definition | Get feature flag definition |
feature-flags-activity-retrieve | Get feature flag activity log |
feature-flags-copy-flags-create | Copy feature flag across projects |
feature-flags-dependent-flags-retrieve | Get dependent feature flags |
feature-flags-evaluation-reasons-retrieve | Get feature flag evaluation reasons |
feature-flags-status-retrieve | Get feature flag status |
feature-flags-user-blast-radius-create | Get user blast radius |
update-feature-flag | Update feature flag |
Function templates
| Tool | Purpose |
|---|---|
cdp-function-templates-list | List function templates |
cdp-function-templates-retrieve | Get function template |
Functions
| Tool | Purpose |
|---|---|
cdp-functions-create | Create function |
cdp-functions-delete | Delete function |
cdp-functions-invocations-create | Test-invoke function |
cdp-functions-list | List functions |
cdp-functions-partial-update | Update function |
cdp-functions-rearrange-partial-update | Reorder transformation execution |
cdp-functions-retrieve | Get function |
Insights & analytics
| Tool | Purpose |
|---|---|
insight-create-from-query | Save a query as an insight. |
insight-delete | Delete an insight by ID. |
insight-get | Get a specific insight by ID. |
insight-query | Execute a query on an existing insight to get its results/data. |
insight-update | Update an existing insight by ID. |
insights-get-all | Get all insights in the project with optional filtering. |
query-generate-hogql-from-question | Queries project's PostHog data based on a provided natural language question. |
query-run | Run a trend, funnel, paths or HogQL query. |
LLM analytics
| Tool | Purpose |
|---|---|
evaluation-create | Create a new evaluation. |
evaluation-delete | Delete an evaluation. |
evaluation-get | Get a specific evaluation by ID. |
evaluation-run | Run an evaluation on a specific event. |
evaluation-update | Update an evaluation. |
evaluations-get | List LLM analytics evaluations. |
get-llm-total-costs-for-project | Fetches the total LLM daily costs for each model for a project over a given number of days. |
Logs
| Tool | Purpose |
|---|---|
logs-list-attribute-values | Get values for a log attribute. |
logs-list-attributes | List available log attributes. |
logs-query | Search and query logs in the project. |
Notebooks
| Tool | Purpose |
|---|---|
notebooks-create | Create notebook |
notebooks-destroy | Delete notebook |
notebooks-list | List notebooks |
notebooks-partial-update | Update notebook |
notebooks-retrieve | Get notebook |
Organization & project management
| Tool | Purpose |
|---|---|
organization-details-get | Get the details of the active organization. |
organizations-get | Get the organizations the user has access to. |
projects-get | Fetches projects that the user has access to in the current organization. |
property-definitions | Get event and property definitions for the project. |
switch-organization | Change the active organization from the default organization. |
switch-project | Change the active project from the default project. |
Persons
| Tool | Purpose |
|---|---|
persons-bulk-delete | Bulk delete persons |
persons-cohorts-retrieve | Get person cohorts |
persons-list | List persons |
persons-property-delete | Delete person property |
persons-property-set | Set person property |
persons-retrieve | Get person |
persons-values-retrieve | Get person property values |
Prompts
| Tool | Purpose |
|---|---|
prompt-create | Create prompt |
prompt-duplicate | Duplicate prompt |
prompt-get | Get prompt |
prompt-list | List prompts |
prompt-update | Update prompt |
Query wrappers
| Tool | Purpose |
|---|---|
query-funnel | Run a funnel query |
query-retention | Run a retention query |
query-traces-list | List LLM traces |
query-trends | Run a trends query |
Reverse proxy
| Tool | Purpose |
|---|---|
proxy-create | Create reverse proxy |
proxy-delete | Delete reverse proxy |
proxy-get | Get reverse proxy details |
proxy-list | List reverse proxies |
proxy-retry | Retry reverse proxy provisioning |
Search
| Tool | Purpose |
|---|---|
entity-search | Search for entities by name or description. |
SQL
| Tool | Purpose |
|---|---|
execute-sql | Execute an SQL query. |
Surveys
| Tool | Purpose |
|---|---|
survey-create | Creates a new survey in the project. |
survey-delete | Delete a survey by ID. |
survey-get | Get a specific survey by ID. |
survey-stats | Get response statistics for a specific survey. |
survey-update | Update an existing survey by ID. |
surveys-get-all | Get all surveys in the project with optional filtering. |
surveys-global-stats | Get aggregated response statistics across all surveys. |
Workflows
| Tool | Purpose |
|---|---|
workflows-get | Get workflow |
workflows-list | List workflows |
Example prompts
Here are some examples of what you can ask your AI agent to do with the PostHog MCP server:
Feature flag management
Prompt: "Create a feature flag called 'new-checkout-flow' that's enabled for 20% of users"
The agent will use the create-feature-flag tool to create the flag with a 20% rollout and return the configuration including the key, rollout percentage, and a link to the flag in PostHog.
Multivariate feature flags
Prompt: "Create a multivariate feature flag called 'homepage-hero-test' with three variants: control at 34%, variant_a at 33%, and variant_b at 33%"
The agent will use the create-feature-flag tool with a multivariate configuration to create the flag with multiple variants. Variant rollout percentages must be integers that sum to 100.
Analytics queries
Prompt: "How many unique users signed up in the last 7 days, broken down by day?"
The agent will use the query-run tool to execute a trends query and return daily signup counts.
Path analysis
Prompt: "What are the most common paths users take after signing up?"
The agent will use the query-run tool with a PathsQuery to analyze user journeys, returning the flow of events users follow after signup.
Prompt: "Show me the navigation paths from the pricing page to checkout"
The agent will execute a paths query with startPoint set to the pricing page and endPoint set to checkout, revealing the most common routes users take.
SQL and HogQL queries
Your AI agent can execute complex HogQL queries to analyze both system data and analytics data in PostHog.
Prompt: "Query my feature flags to find all flags that are rolled out to less than 50% of users"
The agent will use SQL to query the system.feature_flags table and return flags filtered by rollout percentage.
Prompt: "Write a HogQL query to find users who triggered the signup event but didn't complete onboarding in the last 30 days"
The agent will construct and execute a HogQL query against the events table, using subqueries to find users who signed up but are missing the onboarding completion event.
Prompt: "What cohorts contain users who made a purchase in the last week?"
The agent will query system.cohorts and cross-reference with purchase events to identify relevant cohorts.
A/B test creation
Prompt: "Create an A/B test for our pricing page that measures conversion to checkout"
The agent will use experiment-create to set up an experiment with control/test variants and configure a funnel metric measuring pricing page to checkout conversion.
Error investigation
Prompt: "What are the top 5 errors in my project this week?"
The agent will use the list-errors tool to fetch error groups sorted by occurrence count and return details including affected user counts.
Log investigation
Prompt: "Show me error logs from the payments service in the last hour"
The agent will use logs-query to search for logs filtered by severity level and service name, returning log entries with timestamps, messages, and trace information.
Prompt management
Prompt: "List all prompts stored in my project"
The agent will use the prompt-list tool to retrieve all team prompts and return a summary with names, versions, and timestamps.
Prompt: "Create a prompt called 'code-reviewer' with instructions for reviewing pull requests"
The agent will use the prompt-create tool to create a new prompt with the specified name and content, making it available for use across all MCP-connected agents in your team.
Prompt: "Get the latest version of my 'support-assistant' prompt"
The agent will use the prompt-get tool to retrieve the full prompt content by name. You can also request a specific version if needed.
Prompt: "Update the 'onboarding-guide' prompt to include a section about feature flags"
The agent will use the prompt-update tool to publish a new version of the prompt with the updated content. The update includes conflict detection to prevent overwriting changes made by others.
Prompts and resources
The MCP server provides resources, including framework-specific documentation and example code, to help agents build great PostHog integrations. You can try these yourself using the posthog:posthog-setup prompt, available via a slash command in your agent. Just hit the / key.
Currently we support Next.js, with more frameworks in progress.
Privacy and support
- Privacy Policy: posthog.com/privacy
- Terms of Service: posthog.com/terms
- Support: posthog.com/questions or in-app support
The MCP server acts as a proxy to your PostHog instance. It does not store your analytics data – all queries are executed against your PostHog project and results are returned directly to your AI client.