摘要
让你的 AI 基于 PostHog 回答产品分析问题:对事件和用户运行只读 SQL(HogQL),计算趋势、漏斗和留存,读取已保存的洞察和看板,查找用户、群组、注释和实验,并管理洞察和功能开关。支持 PostHog Cloud(US 或 EU)或自托管实例,使用个人 API 密钥。
引导式设置
2 分钟将 PostHog 连接到 Microsoft Copilot
开始 AnythingMCP Cloud 免费试用,在引导式设置中连接 PostHog,再把你的 MCP URL 添加到 Microsoft Copilot。无需代码,也无需自行运行服务器。
无需信用卡 · 7 天试用 · 提供自托管方案
试试这样问
PostHog 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → PostHog、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
PostHog + Microsoft Copilot
让你的 AI 基于 PostHog 回答产品分析问题:对事件和用户运行只读 SQL(HogQL),计算趋势、漏斗和留存,读取已保存的洞察和看板,查找用户、群组、注释和实验,并管理洞察和功能开关。支持 PostHog Cloud(US 或 EU)或自托管实例,使用个人 API 密钥。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
POSTHOG_HOST, POSTHOG_PERSONAL_API_KEY
步骤 1 — 获取凭证
- 在 PostHog 中打开 Settings → User → Personal API keys(US Cloud:
https://us.posthog.com/settings/user-api-keys,EU Cloud:https://eu.posthog.com/settings/user-api-keys),点击 + Create a personal API key。 - 为密钥设置标签(例如 "AnythingMCP"),并选择 organization and project access:全部、某一个组织或指定项目。仅限指定项目的密钥无法列出组织或项目,但
posthog_get_current_user仍然可用,并会显示当前项目。 - 勾选以下权限范围:
user:read,organization:read,project:readquery:read,person:read,cohort:read,experiment:readinsight:read,insight:write,dashboard:readfeature_flag:read,feature_flag:writeannotation:read,annotation:write
- 立即复制密钥:PostHog 只显示一次。密钥以
phx_开头(以phc_开头的项目令牌在这里无效)。把它填入POSTHOG_PERSONAL_API_KEY,不要带 Bearer 字样。 - 将
POSTHOG_HOST设为你打开 PostHog 时使用的地址:US Cloud 用https://us.posthog.com,EU Cloud 用https://eu.posthog.com,自托管则填你自己实例的地址,末尾不要带斜杠或路径。数据接收地址us.i.posthog.com和eu.i.posthog.com会被拒绝,而且密钥只在创建它的云区域内有效。然后安装连接器。 - 先运行
posthog_get_current_user:它会显示该密钥属于哪个 PostHog 用户、当前项目以及组织下的项目。
只读配置:创建密钥时只勾选 :read 权限范围,并关闭 posthog_create_insight、posthog_update_insight、posthog_create_feature_flag、posthog_update_feature_flag 和 posthog_create_annotation。查询永远不会修改数据,因为 HogQL 只接受 SELECT。AI 能看到和修改的内容与密钥所属用户完全一致。
安装时默认关闭:posthog_delete_insight、posthog_delete_feature_flag 和 posthog_delete_annotation。PostHog 通过 API 从不彻底删除:这些工具只是把洞察、开关或注释标记为已删除,之后可以在 PostHog 应用中恢复。被删除的开关会被关闭,检查其 key 的代码将得到 false。
项目 ID:每个项目级工具都需要 project_id,即 PostHog URL 中的数字(/project/12345/...),也可以在 Settings → Project → General 中找到。@current 也可以使用,但它指的是用户在应用中最后打开的项目,可能随时变化:建议使用数字。其他项目可通过 posthog_list_organizations 和 posthog_list_projects 列出。
查询:posthog_run_hogql_query 对 events、persons、sessions 和 groups 运行一条 HogQL(PostHog 的 SQL)SELECT 语句;属性用 properties.$browser 或 person.properties.email 的方式读取。请始终按时间过滤(例如 WHERE timestamp >= now() - INTERVAL 7 DAY):不加过滤的扫描很慢,还会消耗读取预算。不加 LIMIT 时返回 100 行,加上后最多 50,000 行。OFFSET 会被拒绝,因此 AI 按 timestamp 或 id 分页。日期按项目时区解析,而不是 UTC。趋势、漏斗、留存、粘性、生命周期和路径分析使用 posthog_run_insight_query;转化率和留存率根据 count 值计算。查询接口用于即席分析,不适合批量导出。
洞察、看板和开关:posthog_get_insight 默认返回最近一次缓存的结果;refresh 设为 blocking 时会重新计算过期结果。posthog_get_dashboard 返回看板的卡片及其洞察。功能开关决定真实用户看到的内容:在创建或修改开关之前,AI 会向你展示开关的 key、active 和发布比例,并等待你确认。新开关最安全的做法是 active 设为 false 或发布比例设为 0。修改时会带上最近一次读取到的 version,以免覆盖他人的改动。
分页:列表类工具接受 limit 和 offset,返回 count、next(最后一页为 null)和 results。超过 200 KB 的响应会被截断。
速率限制:按组织计算,所有密钥和用户共享。普通读写为每分钟 480 次、每小时 4,800 次;用户查询和洞察计算等分析接口为每分钟 240 次、每小时 1,200 次。查询接口为每分钟 240 次、每小时 2,400 次,每个项目最多同时运行 3 个查询,并消耗每个项目的每小时读取预算(免费套餐更少)。超出限制时 PostHog 返回 429;预算用尽时返回 api_queries_budget_exceeded,但缓存的结果仍可使用。
常见错误:401 表示密钥错误、已删除或属于另一个云区域:请检查 POSTHOG_HOST。403 "API key missing required scope" 会指出需要添加的权限范围(密钥的权限范围之后可以修改);其他 403 表示密钥仅限其他项目或组织,或者组织不允许成员使用个人 API 密钥。404 "Project not found." 表示 project_id 错误或该用户无权查看。400 会指出无效字段,HogQL 查询还会附带解析器错误。开关返回 409 表示其 version 已过期:请重新读取该开关。
连接器不会发送事件或设置用户属性,不会删除用户,不读取会话回放或问卷,不创建或编辑看板、群组和实验,也不管理批量导出、成员和账单。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Microsoft Copilot 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Microsoft Copilot 通过在 Copilot Studio 中构建的智能体使用 MCP 服务器:把 AnythingMCP 作为工具添加到智能体,然后把智能体发布到 Microsoft 365 Copilot 和 Teams。Copilot Studio 从 Microsoft 的云端通过 Streamable HTTP 连接,AnythingMCP 支持这种方式。
- 在 Copilot Studio 中打开你的智能体(或新建一个),进入 Tools,选择 Add a tool → New tool → Model Context Protocol。
- 填写 Server name(例如
AnythingMCP)、说明连接器用途的 Server description,以及 Server URLhttps://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。Copilot Studio 根据描述决定何时调用该服务器。 - 身份验证选择 API key,把 Type 设为 Header,请求头名称填
X-API-Key,然后选择 Create。 - 在 Add tool 中选择 Create a new connection,粘贴 AnythingMCP 的 MCP API 密钥(MCP Servers → 你的服务器 → API keys),然后选择 Add to agent。
- 在智能体的 Test 窗格中试一试:提出需要用到
PostHog的工具的请求。 - 选择 Publish,然后进入 Channels → Microsoft 365 and Microsoft Teams,保持勾选 Make agent available in Microsoft Copilot,再选择 Add channel。See agent in Teams 会为你安装该智能体;在 Microsoft 365 Copilot 中输入 @ 并选择该智能体。
希望每个用户各自登录?请选择 OAuth 2.0 → Dynamic discovery 代替 API 密钥:每个用户会在智能体首次调用时登录 AnythingMCP。
自托管?请用你实例的公网 HTTPS 地址替换 https://cloud.anythingmcp.com。Copilot Studio 从 Microsoft 的云端连接,因此 localhost 无法使用。
可用工具
| Tool | What it does |
|---|---|
posthog_get_current_user | Get the user the personal API key belongs to: uuid, email and name, the current project (id, name, project_id, timezone), the current… |
posthog_list_organizations | List the organizations the user belongs to: id (a UUID), name, slug, membership_level, and each organization's projects |
posthog_list_projects | List the projects of an organization: id (the project_id every other tool takes), name, project_id, timezone, tags, is_demo and… |
posthog_get_project | Get one project's settings: name, timezone, week_start_day, base_currency, app_urls, test account filters, group types, whether events… |
posthog_run_hogql_query | Run one read-only HogQL (PostHog SQL) SELECT over events, persons, sessions, groups or warehouse tables and return columns, results (rows… |
posthog_run_insight_query | Run one of PostHog's insight calculations without saving it: TrendsQuery, FunnelsQuery, RetentionQuery, StickinessQuery, LifecycleQuery or… |
posthog_list_persons | List or search persons (identified users and anonymous visitors): id, uuid, name, distinct_ids, properties, created_at and last_seen_at.… |
posthog_get_person | Get one person by numeric id or UUID: name, distinct_ids, all person properties (email, initial UTM and referrer, geo), created_at and… |
posthog_list_insights | List saved insights (charts): id, short_id, name, description, query, tags, favorited, dashboard_tiles, created_by and last_modified_at |
posthog_get_insight | Get one insight by numeric id or 8-character short_id: name, description, query, result, columns, last_refresh, is_cached, the hogql it ran… |
posthog_create_insight | Save a new insight (chart) in the project from a query: a product analytics chart or a SQL insight |
posthog_update_insight | Change a saved insight: name, description, query, tags or favorited |
posthog_delete_insight | Delete a saved insight (PostHog marks it deleted; it disappears from every dashboard and can be restored in the app) |
posthog_list_dashboards | List dashboards: id, name, description, pinned, tags, created_by, created_at and last_viewed_at |
posthog_get_dashboard | Get one dashboard with its filters and tiles: each tile carries its insight (id, short_id, name, query and the last cached result) or a… |
posthog_list_feature_flags | List feature flags: id, key, name (the description), active, filters (release conditions with rollout_percentage, variants, payloads)… |
posthog_get_feature_flag | Get one feature flag by id: key, name, active, filters (release condition groups with properties and rollout_percentage, multivariate… |
posthog_create_feature_flag | Create a feature flag |
posthog_update_feature_flag | Change a feature flag: switch it on or off, change its rollout or targeting, rename its description, archive it or retag it |
posthog_delete_feature_flag | Delete a feature flag (PostHog marks it deleted and switches it off; code that checks the key then gets false) |
posthog_list_cohorts | List cohorts (saved groups of persons): id, name, description, count (persons in it), is_static, is_calculating, filters and created_at |
posthog_get_cohort | Get one cohort by id: name, description, its definition (filters or query), count of persons, whether it is static or behavioral… |
posthog_list_annotations | List annotations (notes on charts such as releases or incidents): id, content, date_marker, scope, the insight or dashboard they belong to… |
posthog_get_annotation | Get one annotation by id: content, date_marker, scope (project, organization, dashboard or insight), emoji, the insight or dashboard it is… |
posthog_create_annotation | Add an annotation, a note shown on charts at a point in time, e.g. a release, a campaign start or an incident |
posthog_delete_annotation | Delete an annotation (PostHog marks it deleted; it disappears from every chart and can be restored) |
posthog_list_experiments | List A/B test experiments: id, name, description, status, start_date, end_date, feature_flag_key, type, conclusion, archived and created_by |
posthog_get_experiment | Get one experiment by id: status, start and end dates, its feature flag and variants, metrics, parameters, exposure cohort, conclusion and… |
示例提示
- “上周每天有多少独立用户访问了我们的价格页面?他们用的是哪些浏览器?”
- “过去 30 天里,我们的注册漏斗从浏览价格页面到完成结账的转化率是多少?”
- “现在哪些功能开关处于开启状态?每个开关的发布比例是多少?”
- “在我们的主项目中添加一条今天的注释:春季活动已上线。”
FAQ
这适用于哪个 Copilot? 适用于工作中的 Microsoft 365 Copilot,通过 Copilot Studio 的智能体实现。面向个人账户的 Microsoft Copilot 应用无法添加自己的 MCP 服务器。
我需要什么? 一个可以使用 Copilot Studio 的工作账户(许可证或试用版),用于构建智能体。在 Microsoft 365 Copilot 或 Teams 中使用它的人需要拥有该智能体的访问权限:把它共享给他们,或请管理员为整个组织发布。如果你的组织对 Power Platform 连接器设置了数据策略,这些策略同样适用于 MCP 服务器。
智能体不调用工具。 检查请求头名称是否正好是 X-API-Key,密钥是否属于与 URL 相同的 MCP 服务器,并把 Server description 写得具体:Copilot Studio 根据它决定何时调用服务器。每次修改后重新发布智能体;在已打开的对话中输入 "start over" 即可使用新版本。
下一步
这份指南对你有帮助吗?