KosmoKrator

analytics

PostHog CLI for Coding Agents

Use the PostHog CLI for coding agents with headless JSON commands, schema discovery, credentials, and permission controls.

15 functions 11 read 4 write API token auth

PostHog CLI for Coding Agents

Let coding agents discover schemas and execute integration functions through CLI commands or MCP.

Use this pattern when another coding agent needs exact commands and schema discovery. The PostHog CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.

Command Shape

# PostHog CLI for Coding Agents
kosmokrator integrations:configure posthog --set api_token="$POSTHOG_API_TOKEN" --enable --read allow --write ask --json
kosmo integrations:call posthog.posthog_capture_event '{"event":"example_event","distinct_id":"example_distinct_id","properties":"example_properties","timestamp":"example_timestamp"}' --json

Discovery Before Execution

Agents and scripts can inspect PostHog docs and schemas before choosing a function.

kosmo integrations:docs posthog --json
kosmo integrations:docs posthog.posthog_capture_event --json
kosmo integrations:schema posthog.posthog_capture_event --json
kosmo integrations:search "PostHog" --json
kosmo integrations:list --json

Useful PostHog CLI Functions

FunctionTypeParametersDescription
posthog.posthog_capture_event Write event, distinct_id, properties, timestamp 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 limit, offset, event, distinct_id, person_id, after, before List events from PostHog with optional filtering by event name, user, date range, and pagination.
posthog.posthog_get_event Read event_id Get details of a specific PostHog event by its unique ID, including all event properties and metadata.
posthog.posthog_list_persons Read limit, offset, search List persons (users) from PostHog. Optionally search by name, email, or distinct ID to find specific users.
posthog.posthog_get_person Read person_id Get details of a specific PostHog person (user) by their unique ID, including properties and event history metadata.
posthog.posthog_list_feature_flags Read limit, offset List all feature flags in the PostHog project, including their status, rollout percentages, and filter conditions.
posthog.posthog_get_feature_flag Read flag_id Get details of a specific PostHog feature flag by its ID, including rollout configuration and filter conditions.
posthog.posthog_create_feature_flag Write name, key, active, filters, rollout_percentage Create a new feature flag in PostHog with a name, key, and optional rollout configuration.
posthog.posthog_update_feature_flag Write flag_id, active, filters, rollout_percentage Update an existing PostHog feature flag — change its active state, filters, or rollout percentage.
posthog.posthog_delete_feature_flag Write flag_id Delete a feature flag from PostHog. This action is permanent and cannot be undone.
posthog.posthog_list_insights Read limit, offset, type List saved insights in the PostHog project. Optionally filter by insight type (e.g., TRENDS, FUNNELS, RETENTION, PATHS).
posthog.posthog_get_insight Read insight_id Get details of a specific PostHog insight by its ID, including its query configuration and cached results.
posthog.posthog_list_dashboards Read limit, offset List dashboards in the PostHog project. Dashboards contain collections of insights organized for monitoring.
posthog.posthog_get_dashboard Read dashboard_id Get details of a specific PostHog dashboard by its ID, including its layout and contained insights.
posthog.posthog_list_cohorts Read limit, offset List cohorts in the PostHog project. Cohorts are dynamic groups of users defined by behavioral or property conditions.

Automation Notes

Related PostHog CLI Pages