Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

13.6 KB
Raw Blame
# MCP tool definitions. Tools are opt-in: an operation is exposed only when it has an entry here.
# List operations without an entry: pnpm --filter=@posthog/mcp run scaffold-yaml -- --candidates --product alerts
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product alerts
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: Alerts
feature: alerts
url_prefix: /alerts
ui_apps: {}
tools:
    alert-create:
        operation: alerts_create
        enabled: true
        scopes:
            - alert:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        enrich_url: ?alert_type=insights&alert_id={id}
        title: Create alert
        description: >
            Create a new alert on an insight. Alerts can use either threshold-based conditions or anomaly detection. For
            threshold alerts: set condition (absolute_value, relative_increase, relative_decrease) and threshold
            configuration with bounds — at least one of lower or upper is required (omit detector_config). For anomaly
            detection: set detector_config with a detector type (zscore, mad, iqr, threshold, copod, ecod, hbos,
            isolation_forest, knn, lof, ocsvm, pca) and parameters like threshold (sensitivity 0-1, default 0.9) and
            window size. Ensemble detectors combine 2+ sub-detectors with AND/OR logic. The llm detector type asks an AI
            model whether the latest point is anomalous, given its history, and fires when the model says yes. Its only
            field is optional instructions (plain text describing what counts as unusual, up to 2000 characters). The
            history it reads follows the insight interval, and it also sees the points that its earlier checks fired on,
            so instructions can refer to earlier alerts. It cannot be an ensemble member, cannot use preprocessing,
            cannot run on the real_time cadence, is not available on breakdown insights, is capped per project, and is
            only available where the AI detector is enabled for the organization. Every scheduled check of an llm alert
            uses the organization's AI credits. Always send detector_config.type explicitly: a config with no type is
            read as a z-score detector, and any llm-only field you sent with it is dropped without an error. Requires an
            insight ID and at least one subscribed user.

            The config type must match the insight kind. Trends insights: TrendsAlertConfig (series_index,
            check_ongoing_interval). SQL/HogQL insights: HogQLAlertConfig — column picks which result column to evaluate
            (defaults to the single numeric column), evaluation is required and selects how rows are read: 'last_row'
            (query ordered oldest->newest, the last row is the current value), 'first_row' (query ordered
            newest->oldest, the first row is the current value — pair with a LIMIT, and it is unaffected by result
            truncation), or 'any_row' (every row is checked and the alert fires if any value breaches; absolute_value
            condition only). label_column names the evaluated row(s) in breach messages in every evaluation mode
            (defaults to the first non-evaluated column). Label values appear in delivered notifications — avoid label
            columns containing PII. Funnel insights: FunnelsAlertConfig — funnel_step picks the step to monitor (null
            for the overall last step), metric is 'conversion_from_start' or 'conversion_from_previous', and
            check_ongoing_interval (historical-trend funnels: also evaluate the current in-progress period). Steps
            funnels support only absolute_value conditions; historical-trend funnels also support
            relative_increase/relative_decrease. Anomaly detection (detector_config) is supported for trends and SQL
            insights (not funnels).

            calculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or
            monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise
            add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before
            creating the alert.

            To set the check time, pass schedule_start_time with a local HH:MM time. Updates take effect after the
            current next_check_at, so they cannot increase the alert check frequency.

            Note: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then
            call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see
            the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe
            (cdp-functions-list filtered by alert id, limit=1000), and the exact filters/inputs shape to pass.
        exclude_params:
            - state
            - last_notified_at
            - last_checked_at
            - next_check_at
            - last_value
    alert-delete:
        operation: alerts_destroy
        enabled: true
        scopes:
            - alert:write
        annotations:
            readOnly: false
            destructive: true
            idempotent: true
        title: Delete alert
        description: >
            Delete an alert by ID. This permanently removes the alert and all its check history. Subscribed users will
            no longer receive notifications.
    alert-destinations-create:
        operation: alerts_destinations_create
        enabled: true
        scopes:
            - alert:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Send an alert to Slack
        description: >
            Post this insight alert to a Slack channel as well as emailing its subscribed users. The Slack workspace
            must already be connected to the project — list the workspaces and their channels with
            integrations-channels-retrieve. An alert can have up to 5 destinations. The returned hog_function_ids
            identify the destination; pass them to alert-destinations-delete to remove it.
        param_overrides:
            type:
                description: Destination type. Slack is the only type this tool creates.
            slack_workspace_id:
                description: Integration ID of the connected Slack workspace.
            slack_channel_id:
                description: Slack channel ID to post in, for example C0123456789.
            slack_channel_name:
                description: Optional channel name shown on the destination.
        response:
            include:
                - hog_function_ids
    alert-destinations-delete:
        operation: alerts_destinations_delete_create
        enabled: true
        scopes:
            - alert:write
        annotations:
            readOnly: false
            destructive: true
            idempotent: true
        title: Stop sending an alert to Slack
        description: >
            Remove a destination from an insight alert by passing the hog_function_ids that alert-destinations-create
            returned. The alert keeps its email recipients.
    alert-get:
        operation: alerts_retrieve
        enabled: true
        scopes:
            - alert:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?alert_type=insights&alert_id={id}
        title: Get alert
        description: >
            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.
    alert-simulate:
        operation: alerts_simulate_create
        enabled: true
        scopes:
            - alert:read
            - insight:read
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Simulate detector on insight
        description: >
            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. Pass either the
            numeric insight ID or its saved short ID. Omit detector_config to use the default daily z-score detector
            (threshold 0.95, window 90, first-difference preprocessing). To choose another detector, pass
            detector_config with a type (zscore, mad, iqr, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca,
            ensemble, or llm). Always send the type explicitly: a config with no type is read as a z-score detector, and
            any llm-only field you sent with it is dropped without an error. A statistical detector only reads, so
            alert:read and insight:read are enough for it. The llm type makes one real model call per simulation, so
            that type also needs the alert:write scope. Each llm simulation uses the organization's AI credits, is rate
            limited per project, and takes the same instructions as an llm alert. It runs one live check of the latest
            point, not a scan of the history: it returns the verdict (the latest point in triggered_indices when it
            fires), the model's rationale and kind, and null scores. Pass alert with a saved alert's ID to give the
            model the points that alert's earlier checks fired on. 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.
    alert-update:
        operation: alerts_partial_update
        enabled: true
        scopes:
            - alert:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?alert_type=insights&alert_id={id}
        title: Update alert
        description: >
            Update an existing alert by ID. Can update name, threshold, condition, config, detector_config, subscribed
            users, enabled state, calculation_interval, and weekend skipping. calculation_interval sets how often the
            alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or
            Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. Set detector_config to switch
            to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode
            (threshold mode requires at least one of lower or upper in threshold.configuration.bounds). A
            detector_config of type llm (AI judgment of the latest point, with optional instructions) follows the same
            rules as on create: no real_time cadence, no breakdown insights, and a per-project cap on enabled llm alerts
            that also applies when re-enabling one. For SQL-insight alerts the config is HogQLAlertConfig (column,
            evaluation 'last_row'/'first_row'/'any_row', label_column). Pass schedule_start_time with a local HH:MM time
            to change later checks. The current next_check_at stays unchanged, so an update cannot increase the alert
            check frequency. To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To
            unsnooze, set snoozed_until to null.

            Note: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel
            with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on
            cdp-functions-create; to change or remove one of those, find it via cdp-functions-list
            (type=internal_destination, limit=1000) by matching filters.properties value against this alert's id, then
            use cdp-functions-partial-update or cdp-functions-delete.
        exclude_params:
            - state
            - last_notified_at
            - last_checked_at
            - next_check_at
            - last_value
    alerts-list:
        operation: alerts_list
        enabled: true
        scopes:
            - alert:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?alert_type=insights&alert_id={id}
        list: true
        title: List alerts
        description: >
            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
            (`insight_id`), fuzzy name search (`search`), and creator (`created_by` user UUID). 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.).