Skip to content

About

Official PostHog MCP integration for Prime Agent: talks to PostHog's own MCP server (mcp.posthog.com) with a project-scoped personal API key, giving the agent analytics, funnels, path/user-flow analysis, trends, dashboards, and session replay out of the box (MIT).

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

posthog-mcp

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      │        │  └──────────────────────────┘ │
└──────────────────────────────┘        └──────────────────────────────┘

Why the official server

  • 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 exec tool (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.

Install

  1. Create the skill package (SKILL.md, src/posthog/) under the agent's skills directory (e.g. ~/.agents/skills/posthog), symlinked to this repo, and pip install -e the package into the agent kernel.

  2. 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.

  3. Store it in the host's auth.json as mcp:posthog: {"type": "api_key", "key": "phx_your_key_here"} and map the server in settings.json mcpServers: "posthog": {"type": "http", "url": "https://mcp.posthog.com/mcp"}.

  4. Test from the agent kernel:

    from posthog import posthog, auth_status
    auth_status()                                  # {'enabled': True, ...}
    await posthog.call_tool("exec", {"command": "tools"})

Usage

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}"})

Development

  • tests/test_skill.py — standalone repo checks (structure, pure MIT license, metadata, no credentials in the tree) plus runtime checks when rlm is available.
  • Run with: python -m unittest discover -s tests

License

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.

About

Official PostHog MCP integration for Prime Agent: talks to PostHog's own MCP server (mcp.posthog.com) with a project-scoped personal API key, giving the agent analytics, funnels, path/user-flow analysis, trends, dashboards, and session replay out of the box (MIT).

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages