analytics
PostHog MCP, CLI, and Lua Integration for AI Agents
PostHog integration docs for AI agents: MCP gateway setup, PostHog CLI commands, Lua API reference, credentials, and function schemas.
15 functions 11 read 4 write API token auth
PostHog for agents
Credentials can be configured manually in web or CLI hosts.
Use this integration from Lua code mode, the headless integrations CLI, or the KosmoKrator MCP gateway. The same package metadata powers all three surfaces.
Machine-Readable Metadata
- integration_slug
posthog- route_slug
posthog- package
posthog- auth_strategy
api_tokenAPI token- cli_setup_supported
true- cli_runtime_supported
true- mcp_gateway_supported
true- lua_supported
true- supports_multi_account
true
Quick Links
Lua APIAgent-facing namespace and function reference. PostHog CLIHeadless setup and direct function calls. PostHog MCPMCP gateway setup for external clients. Submit feedbackReport missing tools, auth problems, wrong docs, or runtime issues. ContributeAdd tools or improve metadata in the integrations repo.
PostHog MCP Client Matrix
Use these pages when a specific agent client or framework needs copy-pasteable MCP setup for PostHog.
Claude Code PostHog MCP setup for Claude Code. Cursor PostHog MCP setup for Cursor. Codex PostHog MCP setup for Codex. OpenAI Agents PostHog MCP setup for OpenAI Agents SDK. Claude Agent SDK PostHog MCP setup for Claude Agent SDK. Vercel AI SDK PostHog MCP setup for Vercel AI SDK. LangChain PostHog MCP setup for LangChain. LangGraph PostHog MCP setup for LangGraph. CrewAI PostHog MCP setup for CrewAI. MCP clients PostHog MCP setup for Generic MCP Clients.
PostHog CLI Matrix
Use these pages for direct PostHog CLI workflows in scripts, CI, cron, and agent wrappers.
CI PostHog CLI for CI. Cron Jobs PostHog CLI for cron jobs. Shell Scripts PostHog CLI for shell scripts. Headless Automation PostHog CLI for headless automation. Coding Agents PostHog CLI for coding agents.
Function Catalog
| Function | Type | Parameters | Description |
|---|---|---|---|
posthog.posthog_capture_event | Write write | 4 | Send (capture) a custom event to PostHog for a specific user. The event will appear in the PostHog events stream and can be used in insights and funnels. |
posthog.posthog_list_events | Read read | 7 | List events from PostHog with optional filtering by event name, user, date range, and pagination. |
posthog.posthog_get_event | Read read | 1 | Get details of a specific PostHog event by its unique ID, including all event properties and metadata. |
posthog.posthog_list_persons | Read read | 3 | List persons (users) from PostHog. Optionally search by name, email, or distinct ID to find specific users. |
posthog.posthog_get_person | Read read | 1 | Get details of a specific PostHog person (user) by their unique ID, including properties and event history metadata. |
posthog.posthog_list_feature_flags | Read read | 2 | List all feature flags in the PostHog project, including their status, rollout percentages, and filter conditions. |
posthog.posthog_get_feature_flag | Read read | 1 | Get details of a specific PostHog feature flag by its ID, including rollout configuration and filter conditions. |
posthog.posthog_create_feature_flag | Write write | 5 | Create a new feature flag in PostHog with a name, key, and optional rollout configuration. |
posthog.posthog_update_feature_flag | Write write | 4 | Update an existing PostHog feature flag — change its active state, filters, or rollout percentage. |
posthog.posthog_delete_feature_flag | Write write | 1 | Delete a feature flag from PostHog. This action is permanent and cannot be undone. |
posthog.posthog_list_insights | Read read | 3 | List saved insights in the PostHog project. Optionally filter by insight type (e.g., TRENDS, FUNNELS, RETENTION, PATHS). |
posthog.posthog_get_insight | Read read | 1 | Get details of a specific PostHog insight by its ID, including its query configuration and cached results. |
posthog.posthog_list_dashboards | Read read | 2 | List dashboards in the PostHog project. Dashboards contain collections of insights organized for monitoring. |
posthog.posthog_get_dashboard | Read read | 1 | Get details of a specific PostHog dashboard by its ID, including its layout and contained insights. |
posthog.posthog_list_cohorts | Read read | 2 | List cohorts in the PostHog project. Cohorts are dynamic groups of users defined by behavioral or property conditions. |