Official PostHog MCP integration for Prime Agent. The agent talks to PostHog's own MCP server — the same one used by Claude, Cursor, and other MCP clients — so querying analytics, funnels, paths (user flow), trends, dashboards, and session replay works out of the box, no self-hosted proxy, no bridge, no API keys in config.
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ Prime Agent kernel │ │ PostHog (official, remote) │
│ ┌────────────────────────┐ │ Bearer │ ┌──────────────────────────┐ │
│ │ from posthog import │ │ phx_… │ │ mcp.posthog.com/mcp │ │
│ │ posthog │ │ │ │ analytics · funnels │ │
│ │ await posthog.call_…() │──┼───────▶│ │ paths · trends · replay │ │
│ └────────────────────────┘ │ │ │ dashboards · projects │ │
│ auth.json: mcp:posthog │ │ └──────────────────────────┘ │
└──────────────────────────────┘ └──────────────────────────────┘
- PostHog-reviewed tools — hundreds of commands covering product and web
analytics, funnels, path (user flow) analysis, trends, dashboards,
experiments, feature flags, surveys, session replay, error tracking, SQL
queries, and project management, served through a single token-optimized
exectool (CLI mode). - Project-scoped by default — a personal API key created with the MCP
Server preset and scoped to one project limits blast radius; the key lives
in the host's
auth.json(same store as the Vercel and Supabase skills). - Nothing self-hosted — the skill is a thin streamable-HTTP MCP client; all platform functionality is provided by PostHog.
-
Create the skill package (
SKILL.md,src/posthog/) under the agent's skills directory (e.g.~/.agents/skills/posthog), symlinked to this repo, andpip install -ethe package into the agent kernel. -
Create a PostHog account, verify the email, and create a personal API key with the MCP Server preset, scoped to the project the agent manages.
-
Store it in the host's
auth.jsonasmcp:posthog:{"type": "api_key", "key": "phx_your_key_here"}and map the server insettings.jsonmcpServers:"posthog": {"type": "http", "url": "https://mcp.posthog.com/mcp"}. -
Test from the agent kernel:
from posthog import posthog, auth_status auth_status() # {'enabled': True, ...} await posthog.call_tool("exec", {"command": "tools"})
The official server ships a single token-optimized exec tool (CLI mode):
| Command | Purpose |
|---|---|
tools |
List every available command (insight-query, execute-sql, dashboards-*, session-recording-*, ...) |
search <query> |
Find the right command for a task |
info <tool> |
Describe a command |
schema <tool> [field_path] |
JSON input schema of a command |
call [--json] [--confirm] <tool> <json_input> |
Invoke a command (side-effecting commands require --confirm) |
Example — query pageview trends for the last 30 days:
import json
args = json.dumps({
"kind": "trends",
"interval": "day",
"date_from": "-30d",
"series": [{"kind": "events", "event": "$pageview"}],
})
out = await posthog.call_tool("exec", {"command": f"call --json insight-query {args}"})tests/test_skill.py— standalone repo checks (structure, pure MIT license, metadata, no credentials in the tree) plus runtime checks whenrlmis available.- Run with:
python -m unittest discover -s tests
MIT. PostHog is a trademark of PostHog, Inc.; this project is an independent, community integration and is not affiliated with, endorsed by, or sponsored by PostHog, Inc. See NOTICE.