Posthog Mcp Server

io.github.friendlygeorgePublished by GitHub account friendlygeorgev1.0.0Updated Oct 24, 2026

MCP server for PostHog — product analytics for AI assistants. Query events, persons, insights, da...

Overview

AI-generated overview

Lets an assistant query PostHog product analytics — events, persons, insights, dashboards, feature flags, cohorts, and experiments.

What you can do
Wraps the PostHog REST API (v1) as MCP tools. Read-oriented tools include list_events, get_person, list_persons, list_dashboards, get_dashboard, execute_insight, list_feature_flags, evaluate_feature_flag, list_cohorts, list_experiments, get_experiment, list_actions, and get_project_info. It lets an assistant pull event and person data, run saved insights, check flag state for a user, and inspect experiment results.
When to use it
Useful when you want an assistant to answer product-analytics questions from PostHog in chat, such as recent events, active users, dashboard status, feature-flag rollout, cohort sizes, or A/B test results, without switching to the PostHog UI.
Requirements
Runs locally over stdio, typically via npx posthog-mcp-server, so Node.js is needed. Requires a PostHog personal API key in POSTHOG_API_KEY, and optionally POSTHOG_HOST (default and POSTHOG_PROJECT; if the project is empty it must be given per call. Network access to the PostHog instance is required.
Before you install
The server holds a PostHog personal API key (POSTHOG_API_KEY) in the client configuration; create it with read access only. Queries send analytics data, including person-level details, to the assistant and its model provider. The documented tools are read-only, but a broader-scoped key would widen what the assistant can reach.

Installation

In SourceWeft

  1. Open Posthog Mcp Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

PostHog MCP Server

Connect AI assistants to PostHog — query events, persons, insights, dashboards, feature flags, cohorts, and experiments through the Model Context Protocol.

Works with Claude Desktop, Cursor, Windsurf, Cline, Continue, and any MCP-compatible client.

Features

ToolDescription
list_eventsQuery events with filters (event name, person, date range, properties)
get_personGet a person (user) by distinct_id — properties, creation date, event count
list_personsSearch and list persons with pagination
list_dashboardsList all dashboards — names, tags, widget counts
get_dashboardGet a specific dashboard with its insights and widgets
execute_insightExecute a saved insight (trend, funnel, etc.) and get results
list_feature_flagsList all feature flags — key, active status, rollout percentage
evaluate_feature_flagEvaluate a flag for a specific user and get variant value
list_cohortsList cohorts — name, type (dynamic/static/SQL), person count
list_experimentsList A/B tests — name, status, feature flag, dates
get_experimentGet experiment results with variant data and statistical significance
list_actionsList custom event actions/definitions
get_project_infoGet project name, ID, settings, and data region

Quick Start

1. Get a PostHog API Key

Go to PostHog → Settings → Personal API Keys and create a key with read access.

Or visit: https://your-instance.posthog.com/settings/user-api-keys

2. Configure your MCP client

Claude Desktop — add to claude_desktop_config.json:

json
{  "mcpServers": {    "posthog": {      "command": "npx",      "args": ["-y", "posthog-mcp-server"],      "env": {        "POSTHOG_API_KEY": "phx_YOUR_API_KEY_HERE",        "POSTHOG_HOST": "https://us.i.posthog.com",        "POSTHOG_PROJECT": "YOUR_PROJECT_ID"      }    }  }}

Cursor — add to MCP settings (.cursor/mcp.json):

json
{  "mcpServers": {    "posthog": {      "command": "npx",      "args": ["-y", "posthog-mcp-server"],      "env": {        "POSTHOG_API_KEY": "phx_YOUR_API_KEY_HERE",        "POSTHOG_HOST": "https://us.i.posthog.com",        "POSTHOG_PROJECT": "YOUR_PROJECT_ID"      }    }  }}

3. Run manually (for testing)

bash
# Clone and buildgit clone https://github.com/friendlygeorge/posthog-mcp-server.gitcd posthog-mcp-servernpm installnpm run build
# RunPOSTHOG_API_KEY=phx_... POSTHOG_PROJECT=12345 node dist/index.js

Environment Variables

VariableRequiredDefaultDescription
POSTHOG_API_KEY✅—Your PostHog personal API key (phx_...)
POSTHOG_HOST❌https://us.i.posthog.comPostHog instance URL (use https://eu.i.posthog.com for EU)
POSTHOG_PROJECT❌""Default project ID. If empty, must be specified per-call.

Self-hosted PostHog

If you run PostHog on your own infrastructure, set POSTHOG_HOST to your instance URL:

POSTHOG_HOST=https://posthog.yourcompany.com

Example Queries

Once configured, ask your AI assistant:

  • "Show me the last 20 pageview events"
  • "Who are the most active users this week?"
  • "What's the status of our signup conversion experiment?"
  • "Is the new-checkout-flow feature flag enabled for user abc123?"
  • "Show me all active dashboards"
  • "Execute insight 42 and show me the trend"
  • "List all feature flags that are currently active"
  • "How many people are in the 'Power Users' cohort?"

API Reference

This server wraps the PostHog REST API (v1). Full documentation:

Development

bash
npm installnpm run dev     # Build and runnpm run build   # Build onlynpm start       # Run built output

License

MIT © Nova

Source: README.md at commit fbae87e

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v1.0.0LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts