Posthog Mcp Server

io.github.friendlygeorge由 GitHub 账号 friendlygeorge 发布v1.0.0更新于 Oct 24, 2026

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

已验证STDIO仅桌面效率与工作流数据与分析

概览

AI 生成的概览

让助手查询 PostHog 产品分析数据,包括事件、用户、洞察、仪表盘、功能开关、群组和实验。

可以做什么
将 PostHog REST API(v1)封装为 MCP 工具。读取类工具包括 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 和 get_project_info。助手可借此获取事件与用户数据、运行已保存的洞察、查看某用户的功能开关状态,以及检查实验结果。
适用场景
适合希望在对话中直接获得 PostHog 产品分析答案的场景,例如最近事件、活跃用户、仪表盘状态、功能开关发布比例、群组人数或 A/B 测试结果,无需切换到 PostHog 界面。
运行要求
以 stdio 方式在本地运行,通常通过 npx posthog-mcp-server 启动,因此需要 Node.js。需要 PostHog 个人 API 密钥,放在 POSTHOG_API_KEY;可选 POSTHOG_HOST(默认 POSTHOG_PROJECT,若项目为空则需在每次调用时指定。需要能访问 PostHog 实例的网络。
安装前请注意
该服务器会在客户端配置中保存 PostHog 个人 API 密钥(POSTHOG_API_KEY),建议仅授予读取权限。查询会把分析数据(含用户级明细)发送给助手及其模型提供商。文档列出的工具为只读,但若密钥权限更广,助手可访问的范围也会扩大。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Posthog Mcp Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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

来源:README.md,提交 fbae87e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分