Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to the Posthog MCP server

Vendor MCP
Open markdown

The Posthog MCP connector routes your AI agent's tool calls to Posthog's own MCP server through Scalekit. Each user signs in to Posthog once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 200 tools.

Tools
200
What they doRead · write · destructive
108 · 69 · 23108 read69 write23 destructive
Users sign in with
OAuth app
Scalekit's or your own

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Posthog MCP connection

    In AgentKit > Connections, create a Posthog MCP connection. The name you give it is the connection_name your code passes. See Configure connections.

    Scalekit credentials are available for Posthog MCP server, so you don't need to register an OAuth app.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'posthogmcp'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Posthog MCP:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'posthogmcp_actions_get_all',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user signs in once. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • posthogmcp_action_getGet a specific action by ID.Read-only

    Action Get

    Get a specific action by ID. Returns the action configuration including all steps and their trigger conditions.

    Inputs

    idnumberrequired
    A unique integer value identifying this action.
  • posthogmcp_actions_get_allGet all actions in the project.Read-only

    Actions Get All

    Get all actions in the project. Actions are reusable event definitions that can combine multiple trigger conditions (page views, clicks, form submissions) into a single trackable event for use in insights and funnels. Supports pagination with limit and offset parameters. Note: Search/filtering by name is not supported on this endpoint.

    Inputs

    limitnumber
    Number of results to return per page.
    offsetnumber
    The initial index from which to return the results.
  • posthogmcp_activity_log_listList recent activity log entries for the project.Read-only

    Activity Log List

    List recent activity log entries for the project. Shows who did what and when — feature flag changes, dashboard edits, experiment launches, etc. Supports filtering by scope, user, and date range.

    Inputs

    item_idstring
    Filter by the ID of the affected resource.
    pagenumber
    Page number for pagination. When provided, uses page-based pagination ordered by most recent first.
    page_sizenumber
    Number of results per page (default: 100, max: 1000). Only used with page-based pagination.default 10
    scopestring
    Filter by a single activity scope, e.g. "FeatureFlag", "Insight", "Dashboard", "Experiment". * `Cohort` - Cohort * `FeatureFlag` - FeatureFlag * `Person` - Person * `Group` - Group * `Insight` - Insight * `Plugin` - Plugin * `PluginConfig` - PluginConfig * `HogFunction` - HogFunction * `HogFlow` - HogFlow * `DataManagement` - DataManagement * `EventDefinition` - EventDefinition * `PropertyDefinition` - PropertyDefinition * `Notebook` - Notebook * `Endpoint` - Endpoint * `EndpointVersion` - EndpointVersion * `Dashboard` - Dashboard * `Replay` - Replay * `Experiment` - Experiment * `ExperimentHoldout` - ExperimentHoldout * `ExperimentSavedMetric` - ExperimentSavedMetric * `Survey` - Survey * `EarlyAccessFeature` - EarlyAccessFeature * `SessionRecordingPlaylist` - SessionRecordingPlaylist * `Comment` - Comment * `Team` - Team * `Project` - Project * `ErrorTrackingIssue` - ErrorTrackingIssue * `DataWarehouseSavedQuery` - DataWarehouseSavedQuery * `Organization` - Organization * `OrganizationDomain` - OrganizationDomain * `OrganizationMembership` - OrganizationMembership * `Role` - Role * `UserGroup` - UserGroup * `BatchExport` - BatchExport * `BatchImport` - BatchImport * `Integration` - Integration * `Annotation` - Annotation * `Tag` - Tag * `TaggedItem` - TaggedItem * `Subscription` - Subscription * `PersonalAPIKey` - PersonalAPIKey * `ProjectSecretAPIKey` - ProjectSecretAPIKey * `User` - User * `Action` - Action * `AlertConfiguration` - AlertConfiguration * `Threshold` - Threshold * `AlertSubscription` - AlertSubscription * `ExternalDataSource` - ExternalDataSource * `ExternalDataSchema` - ExternalDataSchema * `LLMTrace` - LLMTrace * `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset * `CustomerProfileConfig` - CustomerProfileConfig * `Log` - Log * `LogsAlertConfiguration` - LogsAlertConfiguration * `ProductTour` - ProductTour * `Ticket` - Ticketone of CohortFeatureFlagPersonGroupInsightPluginPluginConfigHogFunctionHogFlowDataManagementEventDefinitionPropertyDefinitionNotebookEndpointEndpointVersionDashboardReplayExperimentExperimentHoldoutExperimentSavedMetricSurveyEarlyAccessFeatureSessionRecordingPlaylistCommentTeamProjectErrorTrackingIssueDataWarehouseSavedQueryOrganizationOrganizationDomainOrganizationMembershipRoleUserGroupBatchExportBatchImportIntegrationAnnotationTagTaggedItemSubscriptionPersonalAPIKeyProjectSecretAPIKeyUserActionAlertConfigurationThresholdAlertSubscriptionExternalDataSourceExternalDataSchemaLLMTraceWebAnalyticsFilterPresetCustomerProfileConfigLogLogsAlertConfigurationProductTourTicket
    scopesarray
    Filter by multiple activity scopes, comma-separated. Values must be valid ActivityScope enum values. E.g. "FeatureFlag,Insight".
    userstring
    Filter by user UUID who performed the action.
  • posthogmcp_advanced_activity_logs_filtersGet the available filter options for activity logs — scopes, activity types, and users that have logged activity.Read-only

    Advanced Activity Logs Filters

    Get the available filter options for activity logs — scopes, activity types, and users that have logged activity. Useful for building filter UIs or understanding what kinds of activity are tracked.

    Inputs

    This tool takes no inputs.

  • posthogmcp_advanced_activity_logs_listList activity log entries with advanced filtering, sorting, and field-level diffs.Read-only

    Advanced Activity Logs List

    List activity log entries with advanced filtering, sorting, and field-level diffs. Supports filtering by scope, activity type, user, date range, and search text.

    Inputs

    activitiesarray
    No description.
    clientsarray
    No description.
    detail_filtersstring
    No description.
    end_datestring
    No description.
    hogql_filterstring
    No description.
    is_systemstring
    No description.
    item_idsarray
    No description.
    pagenumber
    Page number for pagination. When provided, uses page-based pagination ordered by most recent first.
    page_sizenumber
    Number of results per page (default: 100, max: 1000). Only used with page-based pagination.default 10
    scopesarray
    No description.
    search_textstring
    No description.
    start_datestring
    No description.
    usersarray
    No description.
    was_impersonatedstring
    No description.
  • posthogmcp_alert_getGet a specific alert by ID.Read-only

    Alert Get

    Get a specific alert by ID. Returns the full alert configuration including check results, threshold settings, detector_config (for anomaly detection alerts), and subscribed users. Check results include anomaly_scores, triggered_points, and triggered_dates for detector-based alerts. By default returns the last 5 checks. Use checks_date_from and checks_date_to (e.g. '-24h', '-7d') to get checks within a time window, and checks_limit to control the maximum returned (default 5, max 500). When date filters are provided without checks_limit, up to 500 checks are returned. Check history is retained for 14 days.

    Inputs

    idstringrequired
    A UUID string identifying this alert configuration.
    checks_date_fromstring
    Relative date string for the start of the check history window (e.g. '-24h', '-7d', '-14d'). Returns checks created after this time. Max retention is 14 days.
    checks_date_tostring
    Relative date string for the end of the check history window (e.g. '-1h', '-1d'). Defaults to now if not specified.
    checks_limitnumber
    Maximum number of check results to return (default 5, max 500). Applied after date filtering.
  • posthogmcp_alert_simulateRun an anomaly detector on an insight's historical data without creating any alert or check records.Read-only

    Alert Simulate

    Run an anomaly detector on an insight's historical data without creating any alert or check records. Use this to preview how a detector configuration would perform before saving it as an alert. Requires an insight ID and a detector_config object with a type (zscore, mad, iqr, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca, or ensemble). Optionally specify date_from (e.g. '-48h', '-30d') to control how far back to simulate, and series_index to pick which series to analyze. Returns data values, anomaly scores per point, triggered indices and dates, and for ensemble detectors, per-sub-detector score breakdowns.

    Inputs

    detector_configstringrequired
    Detector configuration to simulate.
    insightnumberrequired
    Insight ID to simulate the detector on.
    date_fromstring
    Relative date string for how far back to simulate (e.g. '-24h', '-30d', '-4w'). If not provided, uses the detector's minimum required samples.
    series_indexnumber
    Zero-based index of the series to analyze.default 0
  • posthogmcp_alerts_listList all insight alerts in the project.Read-only

    Alerts List

    List all insight alerts in the project. Returns alerts with their current state, threshold or detector configuration, timing information, and firing check history. Supports filtering by insight ID via query parameter. Alerts can use either threshold-based conditions (absolute_value, relative_increase, relative_decrease) or anomaly detection via detector_config (zscore, mad, iqr, isolation_forest, knn, etc.).

    Inputs

    limitnumber
    Number of results to return per page.
    offsetnumber
    The initial index from which to return the results.

Workflows

Execute a tool

Use this connector when you want an agent to work with PostHog data and configuration.

  • List and search feature flags with posthogmcp_feature_flag_get_all.
  • Run trend, funnel, path, or HogQL queries using posthogmcp_query_run.
  • Create A/B tests via posthogmcp_experiment_create with custom metrics and variant splits.
  • Retrieve survey response data with posthogmcp_survey_stats after creating surveys using posthogmcp_survey_create.
  • Discover available events with posthogmcp_event_definitions_list before building queries or funnels.
tool_response = actions.execute_tool(
tool_name="posthogmcp_feature_flag_get_all",
connection_name='posthogmcp',
identifier='user_123',
tool_input={},
)
print("Feature flags:", tool_response)