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.

21.4 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 data_warehouse
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product data_warehouse
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: Data warehouse
feature: data_warehouse
url_prefix: /sql
ui_apps: {}
tools:
    managed-warehouse-metric-history-get:
        operation: data_warehouse_managed_warehouse_monitoring_timeseries_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Get managed warehouse metric history
        description: >
            Get one operational metric over a trailing time window for the active project's managed warehouse. Available
            metrics cover query rate and errors, query duration, active sessions, worker acquisition, storage size, and
            worker crashes. The response includes units and labeled series. These values are not billing totals.
        feature_flag: data-warehouse-scene
    managed-warehouse-monitoring-get:
        operation: data_warehouse_managed_warehouse_monitoring_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Get managed warehouse monitoring
        description: >
            Get current workers, allocated resources, active sessions, running queries, queued connections, capacity
            limits, and response coverage for the active project's managed warehouse. Use this to inspect current
            capacity and workload. These values describe operational activity, not invoiced usage.
        feature_flag: data-warehouse-scene
    managed-warehouse-trino-metric-history-get:
        operation: data_warehouse_managed_warehouse_trino_monitoring_timeseries_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Get managed warehouse Trino metric history
        description: >
            Get one operational metric over a trailing time window for the active project's managed warehouse when it
            runs on Trino. Available metrics cover queries in flight by state, query rate and errors, query duration,
            queue time, data scanned, CPU time, and storage size. The response includes units and labeled series. These
            values are not billing totals.
        feature_flag: managed-warehouse-trino-query
    managed-warehouse-trino-monitoring-get:
        operation: data_warehouse_managed_warehouse_trino_monitoring_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Get managed warehouse Trino monitoring
        description: >
            Get current Trino query activity for the active project's managed warehouse: queries in flight, running,
            queued, and blocked counts, concurrency and queue limits, and the in-flight queries with literal values
            removed from their SQL. Use this to inspect current workload. When `available` is false the live data could
            not be read, so the totals do not mean the warehouse is idle. These values describe operational activity,
            not invoiced usage.
        feature_flag: managed-warehouse-trino-query
    saved-query-column-annotations-create:
        operation: saved_query_column_annotations_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        title: Add a view column description
        description: >
            Add or replace a semantic description for a data-modelling view (saved query) or one of its columns. Use
            this ONLY for views — rows where table_type = 'view' in system.information_schema.tables. For
            imported/physical warehouse tables (table_type = 'data_warehouse') use warehouse-column-annotations-create
            instead. Core PostHog tables (events, persons, groups, sessions; table_type = 'posthog') cannot be
            described. Provide the saved_query id, the column_name (empty string for a view-level description), and the
            description. Agents may use this text to work out how to use the data, so state the meaning, units, and
            allowed values. The annotation is recorded as user-edited, which prevents automatic enrichment from
            overwriting it. Calling this again for the same column replaces the existing description.
        param_overrides:
            column_name:
                description: Column to describe. Use an empty string to describe the view itself.
    saved-query-column-annotations-list:
        operation: saved_query_column_annotations_list
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        list: true
        title: List view column descriptions
        description: >
            List semantic descriptions of data-modelling views (saved queries) and their columns. Use this for views
            (table_type = 'view' in system.information_schema.tables); for physical warehouse tables use
            warehouse-column-annotations-list. Pass ?saved_query_id=<uuid> to scope to one view. Each entry has the
            column_name (empty string = view-level description), the description, and its source (ai_generated or
            user_edited). Use this to see what a view's columns mean before writing SQL against it.
    sql-variables-create:
        operation: insight_variables_create
        enabled: true
        scopes:
            - insight_variable:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Create SQL variable
        description: >
            Create a reusable SQL variable for HogQL queries. Provide a human-readable name and type. The code_name is
            generated from the name and is referenced in SQL as {variables.code_name}. For List variables, provide
            values as the allowed options.
    sql-variables-delete:
        operation: insight_variables_destroy
        enabled: true
        scopes:
            - insight_variable:write
        annotations:
            readOnly: false
            destructive: true
            idempotent: true
        title: Delete SQL variable
        description: >
            Delete a SQL variable by ID. Queries that reference this variable by code_name may stop working after
            deletion.
    sql-variables-update:
        operation: insight_variables_partial_update
        enabled: true
        scopes:
            - insight_variable:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        title: Update SQL variable
        description: >
            Update an existing SQL variable by ID. You can change the name, type, default_value, or allowed values for
            List variables. If the name changes, check the response for the current code_name before writing queries
            that reference it.
    view-check-incremental:
        operation: warehouse_saved_queries_check_incremental_create
        enabled: true
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Check incremental refresh
        description: >
            Check whether a view's HogQL query can refresh incrementally, without running it. Pass the query from
            view-get. Returns key_candidates, the date, datetime and number columns that can be the incremental key, and
            unique_key_candidates, the columns a unique key can use. Pass incremental_key and unique_key to check a
            specific choice: blockers then says why it cannot work. Use it before accepting a materialize suggestion
            with keys the person chose.
    view-create:
        operation: warehouse_saved_queries_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        enrich_url: ?open_view={id}
        title: Create saved query
        description: |
            Create a new data warehouse saved query (view). If a view with the same name already exists, it will be
            updated instead (upsert behavior). The query must be valid HogQL. After creation, the view can be referenced
            by name in other HogQL queries.

            Always set a specific `description`. Agents may use it to decide when to use this data and how to query it,
            so state what one row represents, what the view includes or leaves out, and when to use it. For example:
            "One row per paid order, without test orders or refunds. Use it for revenue reports." Per-column
            descriptions are set via the saved-query column annotation tools.

            Put the HogQL in `query`:

            ```json
            { "name": "example", "query": { "kind": "HogQLQuery", "query": "SELECT 1" } }
            ```
        exclude_params:
            - deleted
            - edited_history_id
            - soft_update
            - is_materialized
            - origin
            - status
            - latest_error
            - created_by
            - created_at
            - columns
            - last_run_at
            - managed_viewset_kind
            - latest_history_id
        param_overrides:
            name:
                description:
                    Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing table
                    names.
    view-delete:
        operation: warehouse_saved_queries_destroy
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: true
            idempotent: false
        title: Delete saved query
        description: >
            Delete a data warehouse saved query (view) by ID. This is a soft delete — the view is marked as deleted and
            will no longer appear in lists or be queryable in HogQL. Any materialization schedule is also removed.
            Cannot delete views that have downstream dependencies or views from managed viewsets.
    view-get:
        operation: warehouse_saved_queries_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?open_view={id}
        title: Get saved query
        description: >
            Get a specific data warehouse saved query (view) by ID. Returns the full view definition including the HogQL
            query, column schema, materialization status, sync frequency, and run history metadata. Also returns the
            view's semantic `description` and a `description` on each entry of `columns` when set — use this to see what
            a view and its columns mean.
        hooks: dataWarehouse/viewGetHooks
    view-list:
        operation: warehouse_saved_queries_list
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?open_view={id}
        list: true
        title: List saved queries
        description: >
            List all data warehouse saved queries (views) in the project. Returns each view's name, materialization
            status, sync frequency, column schema, latest error, and last run timestamp. Each view also includes its
            semantic `description` and a `description` on each entry of `columns` when set. Use this to discover
            available views and what they mean before querying them in HogQL.
    view-materialize:
        operation: warehouse_saved_queries_materialize_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?open_view={params.id}
        title: Materialize saved query
        description: >
            Enable materialization for a saved query. This creates a physical table from the view's query and sets up a
            sync schedule to keep it refreshed, daily unless `sync_frequency` asks for another cadence. A cadence is
            rejected when the view's lineage cannot support it: no more often than its sources deliver new data, and no
            less often than a downstream view or endpoint needs. Materialized views are faster to query but use storage.
            Use 'view-unmaterialize' to undo. Rate limited.
    view-resume:
        operation: warehouse_saved_queries_resume_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?open_view={params.id}
        title: Resume suspended materialization
        description: >
            Resume a saved query whose materialization was suspended after repeated failures. Scheduled runs skip a
            suspended view and everything downstream of it until it is resumed. Set engine to 'clickhouse' or 'trino' to
            resume only that engine; omit it to resume all. The view runs again at its next scheduled run; use
            'view-run' to run it now. Returns resumed=false when the view was not suspended. Check the 'suspended' field
            from 'view-get' to see which engines are suspended and why.
    view-run:
        operation: warehouse_saved_queries_run_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?open_view={params.id}
        title: Run saved query
        description: >
            Trigger a manual materialization run for a saved query. By default, this refreshes only the selected view.
            Set direction to upstream to also run all dependencies. Set direction to downstream to also run all
            dependents. Both options include the selected view and run the views in dependency order. Do not set
            full_refresh when you set direction. A run fails with a rate limit error when every view it would build ran
            recently, and the error says how long to wait. Use 'view-run-history' to check each view's status.
    view-run-history:
        operation: warehouse_saved_queries_run_history_retrieve
        enabled: true
        scopes:
            - warehouse_view:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?open_view={params.id}
        title: Get run history
        description: >
            Get the 5 most recent materialization run statuses for a saved query. Each entry includes the run status and
            timestamp. Use this to monitor whether materialization is running successfully.
    view-unmaterialize:
        operation: warehouse_saved_queries_revert_materialization_create
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?open_view={params.id}
        title: Revert materialization
        description: |
            Undo materialization for a saved query. Deletes the materialized table and removes the sync schedule,
            reverting the view back to a virtual query that runs on each access. The view definition itself is
            preserved. Rate limited.

            Send the view ID, name, and query:

            ```json
            { "id": "<id>", "name": "example", "query": { "kind": "HogQLQuery", "query": "SELECT 1" } }
            ```
    view-update:
        operation: warehouse_saved_queries_partial_update
        enabled: true
        scopes:
            - warehouse_view:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        enrich_url: ?open_view={id}
        title: Update saved query
        description: >
            Update an existing data warehouse saved query (view). Can change the name, HogQL query, sync frequency, or
            `description`. Agents may use `description` to decide when to use this data and how to query it, so update
            it whenever the meaning of the view changes, and state what one row represents, what the view includes or
            leaves out, and when to use it. An empty string clears it; per-column descriptions are set via the
            saved-query column annotation tools. Changing the query triggers column re-inference and sets the status to
            'modified'. Use sync_frequency to control materialization schedule: '15min' (the fastest cadence), '30min',
            '1hour', '6hour', '12hour', '24hour', '7day', '30day', or 'never' to pause scheduled materialization.
            IMPORTANT: when updating the query field, you must first retrieve the view to get its latest_history_id,
            then pass that value as edited_history_id for conflict detection.
        exclude_params:
            - deleted
            - soft_update
            - is_materialized
            - origin
            - status
            - latest_error
            - created_by
            - created_at
            - columns
            - last_run_at
            - managed_viewset_kind
            - latest_history_id
        param_overrides:
            name:
                description:
                    Unique name for the view. Used as the table name in HogQL queries. Must not conflict with existing table
                    names.
            edited_history_id:
                description:
                    Required when updating the query field. Get this from latest_history_id on the retrieve response. Used for
                    optimistic concurrency control.
    warehouse-column-annotations-create:
        operation: warehouse_column_annotations_create
        enabled: true
        scopes:
            - warehouse_table:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Add a warehouse column description
        description: >
            Add a semantic description for a data warehouse table or column. Provide the table id, the column_name
            (empty string for a table-level description), and the description. The new annotation is recorded as
            user-edited, which prevents automatic enrichment from overwriting it.
        param_overrides:
            column_name:
                description: Column to describe. Use an empty string to describe the table itself.
    warehouse-column-annotations-list:
        operation: warehouse_column_annotations_list
        enabled: true
        scopes:
            - warehouse_table:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        list: true
        title: List warehouse column descriptions
        description: >
            List semantic descriptions of data warehouse tables and columns. Pass ?table_id=<uuid> to scope to one
            table. Each entry has the column_name (empty string = table-level description), the description, and its
            source (canonical from the source's API documentation, ai_generated, or user_edited). Use this to see what
            the imported data means before writing SQL against it.
    warehouse-column-annotations-partial-update:
        operation: warehouse_column_annotations_partial_update
        enabled: true
        scopes:
            - warehouse_table:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        title: Edit a warehouse column description
        description: >
            Update the description of an existing warehouse table or column annotation by its id. The annotation is
            marked user-edited, so automatic enrichment will no longer overwrite it.
    warehouse-tables-refresh-schema-create:
        operation: warehouse_tables_refresh_schema_create
        enabled: true
        scopes:
            - warehouse_table:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        title: Refresh table schema from source
        description: >
            Re-introspect a self-managed (manually linked) data warehouse table's schema from its underlying source
            files and overwrite its stored column list. Use this when the source schema has evolved (e.g. new columns
            added to the underlying Delta/Parquet/CSV files) but HogQL queries still fail to resolve the new columns —
            PostHog serves a cached column snapshot until the table is refreshed. Does not apply to tables managed by an
            external data source sync (those refresh on their own schedule); for those, trigger a sync instead.