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.

feat(engineering-analytics): gate all surfaces on rollout flag, add insights skill (#69245)

Paul D'Ambra49be0a44b79c
diff --git a/frontend/src/scenes/settings/user/personalAPIKeysLogic.tsx b/frontend/src/scenes/settings/user/personalAPIKeysLogic.tsx
index e5711cd3602b..4c3a98194ebe 100644
--- a/frontend/src/scenes/settings/user/personalAPIKeysLogic.tsx
+++ b/frontend/src/scenes/settings/user/personalAPIKeysLogic.tsx
@@ -180,6 +180,11 @@ export const personalAPIKeysLogic = kea<personalAPIKeysLogicType>([
scopes = scopes.filter((scope) => scope.key !== 'agents')
}
+ // Hide engineering analytics scope unless the product's rollout flag is enabled
+ if (!featureFlags[FEATURE_FLAGS.ENGINEERING_ANALYTICS]) {
+ scopes = scopes.filter((scope) => scope.key !== 'engineering_analytics')
+ }
+
// Hide approvals scope unless the org has the APPROVALS feature
if (!hasAvailableFeature(AvailableFeature.APPROVALS)) {
scopes = scopes.filter((scope) => scope.key !== 'approvals')
diff --git a/products/engineering_analytics/backend/presentation/views.py b/products/engineering_analytics/backend/presentation/views.py
index 5c528b473e29..3148bf85d712 100644
--- a/products/engineering_analytics/backend/presentation/views.py
+++ b/products/engineering_analytics/backend/presentation/views.py
@@ -20,6 +20,7 @@ from rest_framework.response import Response
from posthog.api.mixins import TypedRequest, validated_request
from posthog.api.routing import TeamAndOrgViewSetMixin
+from posthog.permissions import PostHogFeatureFlagPermission
from products.engineering_analytics.backend.facade import api
from products.engineering_analytics.backend.facade.contracts import (
@@ -129,6 +130,9 @@ class EngineeringAnalyticsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSe
"""PR and CI lifecycle analytics over the GitHub warehouse data."""
scope_object = "engineering_analytics"
+ # Same rollout flag as the UI scene and the MCP tools, so the product is gated end to end.
+ permission_classes = [PostHogFeatureFlagPermission]
+ posthog_feature_flag = "engineering-analytics"
scope_object_read_actions = [
"sources",
"ci_cards",
diff --git a/products/engineering_analytics/backend/tests/conftest.py b/products/engineering_analytics/backend/tests/conftest.py
index ae3f00200968..bbd7fc327e44 100644
--- a/products/engineering_analytics/backend/tests/conftest.py
+++ b/products/engineering_analytics/backend/tests/conftest.py
@@ -1,8 +1,22 @@
import pytest
+from unittest.mock import patch
from posthog.models.scoping import team_scope
+def _only_engineering_analytics_flag(flag_key: str, *args: object, **kwargs: object) -> bool:
+ # Enable just the engineering-analytics rollout flag; leave every other flag at its
+ # default (off) so tests don't silently mask unrelated flag-gated behavior.
+ return flag_key == "engineering-analytics"
+
+
[email protected](autouse=True)
+def _enable_engineering_analytics_flag():
+ # The viewset is gated on PostHogFeatureFlagPermission; without this every endpoint test 403s.
+ with patch("posthoganalytics.feature_enabled", side_effect=_only_engineering_analytics_flag):
+ yield
+
+
@pytest.fixture(autouse=True)
def _set_team_scope(request):
if request.node.get_closest_marker("django_db") is None:
diff --git a/products/engineering_analytics/backend/tests/test_presentation.py b/products/engineering_analytics/backend/tests/test_presentation.py
index 9c70f90f8bcd..4e48712c3f37 100644
--- a/products/engineering_analytics/backend/tests/test_presentation.py
+++ b/products/engineering_analytics/backend/tests/test_presentation.py
@@ -392,3 +392,12 @@ class TestEngineeringAnalyticsAPI(APIBaseTest):
response = self.client.get(self._url(action))
assert response.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN)
+
+ def test_requires_rollout_feature_flag(self) -> None:
+ # The whole viewset is gated on the engineering-analytics rollout flag (which the
+ # conftest fixture enables); with the flag off, every endpoint must 403.
+ with mock.patch("posthoganalytics.feature_enabled", return_value=False):
+ response = self.client.get(self._url("sources"))
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert "engineering-analytics" in response.json()["detail"]
diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yaml
index 085e50f2a398..924b509001b5 100644
--- a/products/engineering_analytics/mcp/tools.yaml
+++ b/products/engineering_analytics/mcp/tools.yaml
@@ -34,6 +34,7 @@ tools:
pushes' failures are included too. logs_available is false when CI hasn't failed, the logs aged out of the
short Logs retention, or a fork PR has no run association to resolve. Use pr-runs or workflow-jobs for the
run/job metadata behind these logs.
+ feature_flag: engineering-analytics
engineering-analytics-flaky-tests:
operation: engineering_analytics_flaky_tests
enabled: true
@@ -55,6 +56,7 @@ tools:
failed_pr_count catches. xfailed_count > 0 means the test is already quarantined but still failing. nodeid
is a best-effort reconstruction (no '.py' suffix, the file/class boundary folded into '/'), so convert
before using it as a pytest selector.
+ feature_flag: engineering-analytics
engineering-analytics-job-aggregates:
operation: engineering_analytics_job_aggregates
enabled: false
@@ -79,6 +81,7 @@ tools:
job-level source isn't synced yet — every figure is then zero/null, so check it before trusting a $0.00.
estimated_cost_usd is null (not zero) when nothing was costable, and unsettled_jobs counts billable jobs
still running that are left out of the estimate.
+ feature_flag: engineering-analytics
engineering-analytics-pr-runs:
operation: engineering_analytics_pr_runs
enabled: false
@@ -112,7 +115,11 @@ tools:
The team's connected GitHub data warehouse sources, oldest first, each with its id, repo (owner/name), and
table prefix. Call this first when a team may have more than one GitHub source, then pass a chosen id as
source_id to the pull-requests, workflow-health, ci-cards, or pr-lifecycle tools to read that specific
- source. With a single source you can skip it — the other tools default to the oldest connected source.
+ source. With a single source you can skip it — the other tools default to the oldest connected source. The
+ prefix also names the underlying warehouse tables (prefix + github_pull_requests / github_workflow_runs /
+ github_workflow_jobs), which you can query directly with SQL or save as SQL insights and subscriptions when
+ the named tools don't fit (timestamps land as strings; parse with parseDateTimeBestEffort).
+ feature_flag: engineering-analytics
engineering-analytics-workflow-jobs:
operation: engineering_analytics_workflow_jobs
enabled: true
@@ -131,6 +138,7 @@ tools:
latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free
GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced
yet.
+ feature_flag: engineering-analytics
engineering-analytics-workflow-run:
operation: engineering_analytics_workflow_run
enabled: false
@@ -154,6 +162,7 @@ tools:
estimated_cost_usd. Use this for "which runner tier drives this workflow's CI bill" and to spot oversized
runners. Billable self-hosted Linux tiers carry a cost; github-hosted and non-Linux rows are null. Returns
an empty list when the job-level source isn't synced yet.
+ feature_flag: engineering-analytics
engineering-analytics-workflow-runs:
operation: engineering_analytics_workflow_runs
enabled: false
@@ -172,6 +181,7 @@ tools:
ordered events — opened, CI started, CI finished, and merged or closed. Use this to answer "where is this PR
stuck and what happened to it". metric_quality is "partial" — it covers CI events only; review and comment
events are not yet available. For aggregate questions use the pull-requests and workflow-health tools.
+ feature_flag: engineering-analytics
pull-requests:
operation: engineering_analytics_pull_requests
enabled: true
@@ -196,6 +206,7 @@ tools:
description: >
Recency floor for merged/closed PRs — relative ('-30d', '-8w') or ISO8601. Open PRs are always
included regardless of age. Defaults to -30d.
+ feature_flag: engineering-analytics
workflow-health:
operation: engineering_analytics_workflow_health
enabled: true
@@ -217,4 +228,5 @@ tools:
description: Window start — relative ('-24h', '-7d') or ISO8601. Defaults to -24h.
date_to:
description: Window end — relative or ISO8601. Defaults to now.
+ feature_flag: engineering-analytics
url_prefix: /engineering-analytics/workflows
diff --git a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md
index f73fcd6f5fd1..6714369e974c 100644
--- a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md
+++ b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md
@@ -105,3 +105,12 @@ CI before merging."
- Don't infer reviews, approvals, per-check counts, or deploys — that data isn't ingested yet.
- Don't turn per-author buckets into a leaderboard — they're for finding stuck work, not ranking people.
- Don't reach for these tools to fetch raw PR contents or diffs — they surface pipeline signal, not the PR thread.
+
+## Persisting an answer
+
+These tools are ad-hoc reads; they cannot be saved as an insight or subscribed to. When the user wants the same
+numbers as a saved insight, a dashboard tile, or a scheduled email/Slack delivery, switch to the
+`turning-engineering-analytics-into-insights` skill: the underlying warehouse tables
+(`<prefix>github_pull_requests` / `<prefix>github_workflow_runs`, prefix from `engineering-analytics-sources`)
+are directly queryable with HogQL, and that skill carries the curated column semantics plus the
+insight-create / subscriptions-create workflow.
diff --git a/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/SKILL.md b/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/SKILL.md
new file mode 100644
index 000000000000..3464b0de5c20
--- /dev/null
+++ b/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/SKILL.md
@@ -0,0 +1,95 @@
+---
+name: turning-engineering-analytics-into-insights
+description: >
+ Converts engineering analytics (PR / CI) data into saved PostHog insights, dashboards, and subscriptions, and
+ explains what data the product reads so it can be queried directly with SQL. The engineering analytics dashboard
+ and MCP tools run curated HogQL privately over per-team GitHub warehouse tables; this skill teaches discovering
+ those tables via engineering-analytics-sources, replicating the curated column semantics in HogQL, saving the
+ query with insight-create, and scheduling delivery with subscriptions-create. Use when asked to "save this as an
+ insight", "put CI health / merge times on a dashboard", "email me PR throughput weekly", "subscribe to these
+ numbers", "alert on CI success rate", or "what data/tables does engineering analytics read". For ad-hoc CI and
+ merge questions use diagnosing-ci-and-merge-bottlenecks instead.
+---
+
+# Turning engineering analytics into insights and subscriptions
+
+The engineering analytics dashboard and MCP tools (`pull-requests`, `workflow-health`, `pr-lifecycle`, …)
+run curated HogQL privately: nothing in the UI or the tool output names the underlying tables,
+and the endpoints cannot themselves be saved as insights or subscribed to.
+The data, however, lives in ordinary team-scoped sources you can query yourself:
+
+| What the product shows | Where the data actually lives | Can it back an insight? |
+| ------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------- |
+| PR list, merge times, CI status, workflow health | Data warehouse tables `<prefix>github_pull_requests`, `<prefix>github_workflow_runs` | **Yes** (SQL insight over the tables) |
+| Job durations, runner tiers, CI cost | `<prefix>github_workflow_jobs` (optional; plus a cost model in product code) | Partially (durations yes, cost no) |
+| CI failure logs for a PR | Logs product (`service_name = 'github-ci-logs'`), short retention | No (use the MCP tool ad hoc) |
+| Flaky test leaderboard | CI trace spans + ranking logic in product code | No (use the MCP tool ad hoc) |
+
+So the job splits cleanly:
+warehouse-backed metrics become SQL insights (then dashboards, then subscriptions);
+everything computed by product logic stays on the MCP tools, delivered recurringly via an AI subscription if needed.
+
+## Step 1: discover the team's tables
+
+Warehouse table names carry a user-chosen prefix, so never hardcode them.
+Call the `engineering-analytics-sources` MCP tool: each connected GitHub source returns its `id`, `repo`, and `prefix`.
+The tables are `<prefix>github_pull_requests`, `<prefix>github_workflow_runs`, and (when the job-level sync is enabled) `<prefix>github_workflow_jobs`;
+an empty prefix means the plain `github_*` names.
+With multiple sources, ask which repo the user means; each source is one repo.
+
+## Step 2: write HogQL that carries the curated semantics
+
+The raw tables land GitHub's JSON verbatim, so a naive `SELECT` gets the domain rules wrong.
+Copy the base subqueries from [references/hogql-recipes.md](references/hogql-recipes.md) (they mirror the product's own curated builders) and follow these rules:
+
+- **Timestamps are strings.** Always `parseDateTimeBestEffort(created_at)` etc. before comparing or diffing.
+- **Nested JSON is Nullable.** `ifNull(...)`-unwrap before `JSONExtractArrayRaw` / `splitByChar`: ClickHouse rejects an Array inside a Nullable.
+- **CI ↔ PR attribution is by PR number** (the run's `pull_requests` association), never by head SHA: the PR snapshot keeps only the current head, so a SHA join silently drops every push but the latest. head SHA is only for a PR's _current_ CI status (latest run per `(head_sha, workflow_name)`).
+- **Bot detection**: `author_handle LIKE '%[bot]' OR author_handle IN ('dependabot', 'github-actions', 'posthog-bot', 'renovate')`. Exclude bots and drafts from throughput / merge-time metrics by default.
+- **Honest names.** `merged_at - created_at` is `open_to_merge_seconds` (it fuses draft and review time); never label an insight "cycle time" or "review time".
+- **Conclusions can be stale.** The runs sync watermarks on `created_at`; a run that completes late can show a stale conclusion. Compute rates over `status = 'completed'` rows only.
+
+Test the query with the `execute-sql` MCP tool (or the SQL editor) before saving anything.
+
+## Step 3: save it as an insight
+
+Use `insight-create` with a SQL insight:
+
+```json
+{
+ "name": "Weekly PR open→merge time (hours)",
+ "query": {
+ "kind": "DataVisualizationNode",
+ "source": { "kind": "HogQLQuery", "query": "<tested SQL>" }
+ }
+}
+```
+
+`display` (a `ChartDisplayType`, e.g. `ActionsLineGraph`) and `chartSettings` (`xAxis` / `yAxis` columns) turn the table into a chart;
+when unsure, save it and let the user pick the visualization in the UI, linking the returned insight URL.
+Bake a relative window into the SQL (`>= now() - INTERVAL 90 DAY`);
+note that a hard-coded date filter means dashboard date overrides won't apply to this tile.
+Bundle several insights with `dashboard-create`.
+
+## Step 4: subscribe
+
+With the insight (or dashboard) saved, this is standard subscription territory: follow the `managing-subscriptions` skill for the `subscriptions-create` payload, channels, frequency, and AI-summary options.
+
+For "notify me when X" (a condition, not a schedule): alerts require a trends insight, so a SQL insight can't be alerted today.
+Offer a scheduled subscription instead, or a threshold check inside a prompt-kind AI subscription.
+
+## What NOT to rebuild in SQL
+
+CI **cost** (runner-tier price ladder), the **flaky-test ranking**, and **failure-log thinning** are product logic, not table columns;
+hand-rolled SQL versions will silently drift from what the dashboard shows.
+For a recurring report on those, create a prompt-kind AI subscription (see the `creating-ai-subscription` skill) whose prompt asks for the relevant engineering analytics reading each period,
+or just call the MCP tools (`engineering-analytics-pr-cost`, `engineering-analytics-flaky-tests`, `engineering-analytics-ci-failure-logs`) ad hoc.
+
+## Caveats to carry into every insight
+
+Name these in the insight description so future readers inherit them:
+`open_to_merge_seconds` is coarse (draft + review fused);
+CI conclusions can lag until the run's webhook settles;
+reviews, approvals, and deploys are not in the data yet;
+bots and drafts are excluded (or not: say which).
+And never build per-author leaderboards or cross-author rankings; per-developer surveillance is an explicit product non-goal.
diff --git a/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/references/hogql-recipes.md b/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/references/hogql-recipes.md
new file mode 100644
index 000000000000..5a3ee3babc7b
--- /dev/null
+++ b/products/engineering_analytics/skills/turning-engineering-analytics-into-insights/references/hogql-recipes.md
@@ -0,0 +1,168 @@
+# HogQL recipes over the GitHub warehouse tables
+
+These base subqueries mirror the product's curated builders
+(`products/engineering_analytics/backend/logic/views/`), so an insight built on them matches what the dashboard and MCP tools report.
+Replace `github_pull_requests` / `github_workflow_runs` with the team's real table names from `engineering-analytics-sources` (`prefix` + `github_<endpoint>`).
+
+## The PR base
+
+```sql
+SELECT
+ number,
+ title,
+ author_handle,
+ (author_handle LIKE '%[bot]'
+ OR author_handle IN ('dependabot', 'github-actions', 'posthog-bot', 'renovate')) AS is_bot,
+ arrayElement(repo_parts, 1) AS repo_owner,
+ arrayElement(repo_parts, 2) AS repo_name,
+ if(merged_at IS NOT NULL, 'merged', raw_state) AS state,
+ is_draft,
+ created_at,
+ merged_at,
+ closed_at,
+ head_sha,
+ if(merged_at IS NOT NULL, dateDiff('second', created_at, merged_at), NULL) AS open_to_merge_seconds
+FROM (
+ SELECT
+ number,
+ title,
+ state AS raw_state,
+ coalesce(draft, false) AS is_draft,
+ ifNull(JSONExtractString(user, 'login'), '') AS author_handle,
+ splitByChar('/', ifNull(JSONExtractString(base, 'repo', 'full_name'), '')) AS repo_parts,
+ JSONExtractString(head, 'sha') AS head_sha,
+ parseDateTimeBestEffort(created_at) AS created_at,
+ parseDateTimeBestEffort(merged_at) AS merged_at,
+ parseDateTimeBestEffort(closed_at) AS closed_at
+ FROM github_pull_requests
+)
+```
+
+The two-layer shape is required: the inner `SELECT` parses string timestamps and `ifNull`-unwraps Nullable JSON;
+the outer derives state, repo identity, and durations.
+Collapsing the layers hits ClickHouse's Array-inside-Nullable rejection and same-`SELECT` alias limits.
+
+## The workflow-runs base
+
+```sql
+SELECT
+ workflow_name,
+ head_sha,
+ head_branch,
+ status,
+ conclusion,
+ run_started_at,
+ run_attempt,
+ pr_number,
+ if(status = 'completed', dateDiff('second', run_started_at, updated_at), NULL) AS duration_seconds,
+ arrayElement(repo_parts, 1) AS repo_owner,
+ arrayElement(repo_parts, 2) AS repo_name
+FROM (
+ SELECT
+ name AS workflow_name,
+ head_sha,
+ head_branch,
+ status,
+ conclusion,
+ run_attempt,
+ JSONExtractInt(arrayElement(JSONExtractArrayRaw(ifNull(pull_requests, '[]')), 1), 'number') AS pr_number,
+ splitByChar('/', ifNull(JSONExtractString(repository, 'full_name'), '')) AS repo_parts,
+ parseDateTimeBestEffort(run_started_at) AS run_started_at,
+ parseDateTimeBestEffort(updated_at) AS updated_at
+ FROM github_workflow_runs
+)
+```
+
+`pr_number` is the first entry of the run's `pull_requests` association, or `0` when there is none (fork PRs, pushes with no open PR); filter `pr_number > 0` before attributing runs to PRs.
+This association, not `head_sha`, is how the product links CI to a PR across all its pushes.
+
+## Recipe: weekly open→merge time trend
+
+```sql
+WITH prs AS (<PR base>)
+SELECT
+ toStartOfWeek(merged_at) AS week,
+ median(open_to_merge_seconds) / 3600 AS p50_hours,
+ quantile(0.95)(open_to_merge_seconds) / 3600 AS p95_hours,
+ count() AS merged_prs
+FROM prs
+WHERE merged_at >= now() - INTERVAL 90 DAY
+ AND NOT is_bot
+ AND NOT is_draft
+GROUP BY week
+ORDER BY week
+```
+
+Report p50 and p95 side by side; they move independently. This is "open to merge", not cycle time.
+
+## Recipe: weekly CI success rate and p95 duration per workflow
+
+```sql
+WITH runs AS (<workflow-runs base>)
+SELECT
+ toStartOfWeek(run_started_at) AS week,
+ workflow_name,
+ count() AS runs,
+ countIf(conclusion = 'success') / count() AS success_rate,
+ quantile(0.95)(duration_seconds) AS p95_seconds
+FROM runs
+WHERE status = 'completed'
+ AND run_started_at >= now() - INTERVAL 60 DAY
+GROUP BY week, workflow_name
+HAVING runs >= 5
+ORDER BY week, runs DESC
+```
+
+Completed runs only: in-flight and stale-conclusion rows would poison the rate.
+For a single-workflow tile, add `AND workflow_name = 'CI'` and drop the group.
+
+## Recipe: PR throughput per week
+
+```sql
+WITH prs AS (<PR base>)
+SELECT
+ toStartOfWeek(created_at) AS week,
+ countIf(state = 'merged') AS merged,
+ countIf(state = 'closed') AS closed_unmerged
+FROM prs
+WHERE created_at >= now() - INTERVAL 90 DAY
+ AND NOT is_bot
+ AND NOT is_draft
+GROUP BY week
+ORDER BY week
+```
+
+## Recipe: open PRs with failing CI right now
+
+A PR's current CI status is the latest completed run per `(head_sha, workflow_name)`; this is the one place head SHA is the correct key:
+
+```sql
+WITH prs AS (<PR base>),
+runs AS (<workflow-runs base>),
+ci AS (
+ SELECT
+ head_sha,
+ countIf(s = 'completed' AND c IN ('failure', 'timed_out')) AS failing
+ FROM (
+ SELECT head_sha, workflow_name,
+ argMax(status, run_started_at) AS s,
+ argMax(conclusion, run_started_at) AS c
+ FROM runs
+ GROUP BY head_sha, workflow_name
+ )
+ GROUP BY head_sha
+)
+SELECT count() AS open_prs_failing_ci
+FROM prs
+INNER JOIN ci ON prs.head_sha = ci.head_sha
+WHERE prs.state = 'open' AND ci.failing > 0
+```
+
+Drafts and bots stay included here, matching the product's failing-CI card (`ci_cards` only excludes them from the stuck count); add `AND NOT prs.is_draft` only if the user explicitly wants non-draft PRs, and say the number then diverges from the dashboard.
+A `pending`-heavy result can be sync staleness, not real in-flight CI; treat pending as unsettled, never as failure.
+
+## Job-level recipes (optional table)
+
+`<prefix>github_workflow_jobs` may not be synced; check `engineering-analytics-sources` output or probe with a `LIMIT 1`.
+Durations and queue times are honest SQL (`started_at - created_at` is queue wait, `completed_at - started_at` is run time; all string timestamps, parse them).
+**Do not** recompute dollar cost from labels: the runner-tier price ladder lives in product code and drifts; use the `engineering-analytics-pr-cost` / `engineering-analytics-workflow-runner-costs` MCP tools for cost figures.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index a6f361cfccf4..a07b83b8ec05 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -2510,7 +2510,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-flaky-tests": {
"description": "Backend tests ranked by flakiness signal over a window (date_from default -7d, maximum 30 days), from the per-test CI spans. A test qualifies by passing on an automatic retry at least min_rerun_passes times (default 1) OR failing on at least min_failed_prs distinct pull requests (default 3). Use this for \"which tests are flaky right now\" and to pick quarantine candidates. Read the counts as absolute signal, never rates — fast passing runs are not emitted, so there is no honest denominator. rerun_passed_count only flows from CI lanes running with retries enabled; in other lanes a flake surfaces as a plain failure, which failed_pr_count catches. xfailed_count > 0 means the test is already quarantined but still failing. nodeid is a best-effort reconstruction (no '.py' suffix, the file/class boundary folded into '/'), so convert before using it as a pytest selector.",
@@ -2524,7 +2525,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-pr-cost": {
"description": "Estimated CI dollar cost of one pull request, summed over the jobs of all its workflow runs, with breakdowns per workflow (by_workflow) and per run (by_run). Reach for this instead of summing runner minutes by hand: the estimate already classifies runners (billable self-hosted Linux vs free GitHub-hosted), applies the per-vCPU price ladder, and excludes non-Linux and provider-hosted jobs. jobs_available is false when the job-level source isn't synced yet — every figure is then zero/null, so check it before trusting a $0.00. estimated_cost_usd is null (not zero) when nothing was costable, and unsettled_jobs counts billable jobs still running that are left out of the estimate.",
@@ -2538,10 +2540,11 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-sources": {
- "description": "The team's connected GitHub data warehouse sources, oldest first, each with its id, repo (owner/name), and table prefix. Call this first when a team may have more than one GitHub source, then pass a chosen id as source_id to the pull-requests, workflow-health, ci-cards, or pr-lifecycle tools to read that specific source. With a single source you can skip it — the other tools default to the oldest connected source.",
+ "description": "The team's connected GitHub data warehouse sources, oldest first, each with its id, repo (owner/name), and table prefix. Call this first when a team may have more than one GitHub source, then pass a chosen id as source_id to the pull-requests, workflow-health, ci-cards, or pr-lifecycle tools to read that specific source. With a single source you can skip it — the other tools default to the oldest connected source. The prefix also names the underlying warehouse tables (prefix + github_pull_requests / github_workflow_runs / github_workflow_jobs), which you can query directly with SQL or save as SQL insights and subscriptions when the named tools don't fit (timestamps land as strings; parse with parseDateTimeBestEffort).",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "List connected GitHub sources",
@@ -2552,7 +2555,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-jobs": {
"description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced yet.",
@@ -2566,7 +2570,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-runner-costs": {
"description": "One workflow's estimated CI cost broken down by runner tier over a window (date_from default -30d), highest spend first. Each row is a tier (provider + runner_label) with its job_count, billable_minutes, and estimated_cost_usd. Use this for \"which runner tier drives this workflow's CI bill\" and to spot oversized runners. Billable self-hosted Linux tiers carry a cost; github-hosted and non-Linux rows are null. Returns an empty list when the job-level source isn't synced yet.",
@@ -2580,7 +2585,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"error-tracking-alerts-create": {
"description": "Create an error tracking alert that fires when an issue is created, reopened, or starts spiking. An alert is a HogFunction with `type=internal_destination` whose `filters.events` references one of the three error-tracking lifecycle events. The events themselves are the trigger — there is no threshold or evaluation window to configure.\n\nTrigger events:\n- `$error_tracking_issue_created` — fires once when a new issue first appears.\n- `$error_tracking_issue_reopened` — fires when a previously resolved issue starts emitting again.\n- `$error_tracking_issue_spiking` — fires when the spike detector flags abnormal volume on an\n issue. The spike threshold is configured separately via the spike detection config endpoint\n and applies to all issues in the project.\n\n\nRecipe — deliver an error tracking alert to Slack or a webhook:\n\n1. Confirm the trigger and channel with the user. Picking `created` for a noisy project will\n flood the channel; `spiking` is usually the safer default. Do not assume.\n\n\n2. Pick the integration. For Slack, call `integrations-list` with `kind=slack` to find the\n integration id, then `integrations-channels-retrieve` for that integration to list channels.\n For a webhook, the user provides the destination URL directly. Confirm the channel name or\n webhook URL with the user before creating the alert — never wire a new alert to a production\n channel without explicit confirmation.\n\n\n3. Dedupe. Call `error-tracking-alerts-list` and check whether an alert for the same trigger\n event already exists. Skip creation if one is present and enabled — call\n `error-tracking-alerts-partial-update` to adjust an existing alert instead of creating a\n duplicate. Several alerts on the same event for the same channel produce duplicate\n notifications.\n\n\n4. Create. Use `type=internal_destination`, the integration's `template_id`\n (`template-slack`, `template-webhook`, `template-discord`, `template-microsoft-teams`,\n `template-linear`, `template-github`, or `template-gitlab`), and:\n\n filters = {\n \"events\": [{\"id\": \"$error_tracking_issue_created\", \"type\": \"events\"}]\n }\n\n Optional per-issue scoping (`created`/`reopened` only): add a `filters.properties` clause\n on `$exception_issue_id` — for example\n `[{\"key\": \"$exception_issue_id\", \"value\": \"<issue_uuid>\", \"operator\": \"exact\", \"type\": \"event\"}]`\n to alert only on a specific known-flaky issue. `$error_tracking_issue_spiking` events carry\n no exception properties, so spiking alerts cannot be scoped per issue. PostHog's \"alerts\n configured\" recommendation only checks `filters.events`, so adding property filters does\n not affect it.\n\n\n5. Slack message body. Mirror the shape the in-product alert wizard produces so agent-created\n and UI-created alerts look identical. The canonical payloads for every integration are in\n the `authoring-error-tracking-alerts` skill references.\n\n For `$error_tracking_issue_created` (Slack):\n\n inputs = {\n \"slack_workspace\": {\"value\": <slack_integration_id_int>},\n \"channel\": {\"value\": \"<channel_id>\"},\n \"text\": {\"value\": \"New issue created: {event.properties.name}\"},\n \"blocks\": {\"value\": [\n {\"type\": \"header\", \"text\": {\"type\": \"plain_text\",\n \"text\": \"🔴 {event.properties.name}\"}},\n {\"type\": \"section\", \"text\": {\"type\": \"plain_text\", \"text\": \"New issue created\"}},\n {\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\",\n \"text\": \"```{substring(event.properties.description, 1, 150)}```\"}},\n {\"type\": \"context\", \"elements\": [\n {\"type\": \"plain_text\", \"text\": \"Status: {event.properties.status}\"},\n {\"type\": \"mrkdwn\", \"text\": \"Project: <{project.url}|{project.name}>\"},\n {\"type\": \"mrkdwn\", \"text\": \"Alert: <{source.url}|{source.name}>\"}\n ]},\n {\"type\": \"divider\"},\n {\"type\": \"actions\", \"elements\": [\n {\"type\": \"button\", \"text\": {\"type\": \"plain_text\", \"text\": \"View Issue\"},\n \"url\": \"{project.url}/error_tracking/{event.distinct_id}?fingerprint={event.properties.fingerprint}&timestamp={event.properties.exception_timestamp}&utm_source=alert&utm_campaign=error_tracking_alert&utm_medium=slack\"}\n ]}\n ]}\n }\n\n For `$error_tracking_issue_reopened`, use the same blocks with the header swapped to\n `🔄 {event.properties.name}`, the section text to `Issue reopened`, and `text` to\n `Issue reopened: {event.properties.name}`.\n\n For `$error_tracking_issue_spiking` (Slack), use the same shape but swap the header to\n `📈 Issue spiking`, drop the `fingerprint`/`timestamp` params from the button URL (spiking\n events do not carry them), and add a context line referencing\n `{event.properties.current_bucket_value}` and `{event.properties.computed_baseline}`. The\n exact block layout is in the `authoring-error-tracking-alerts` skill references.\n\n\n6. Webhook body. The webhook template only requires `url`:\n\n inputs = {\"url\": {\"value\": \"<destination_url>\"}}\n\n Webhooks must be `https://` URLs.\n\n\nEvent property reference — common across all three events: `event.properties.name` (issue title), `event.properties.description` (truncated body), `event.distinct_id` (issue id used in the deep link). `created`/`reopened` additionally expose `event.properties.status`, `event.properties.fingerprint`, `event.properties.exception_timestamp`, and the originating exception's properties (e.g. `$exception_types`, `$exception_issue_id`). Spiking events instead expose `event.properties.current_bucket_value` and `event.properties.computed_baseline` — no status, fingerprint, or exception properties. Project context is available as `{project.url}` (already includes `/project/<team_id>`), `{project.name}`, and the alert's own metadata as `{source.url}` and `{source.name}`.",
@@ -6011,7 +6017,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"project-get": {
"description": "Retrieve a project and its settings. Omit the ID to get the caller's active project.",
@@ -6137,7 +6144,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"query-apm-spans": {
"description": "Query trace spans with filtering by service name, status code, date range, and structured attribute filters. Supports cursor-based pagination. Returns spans with uuid, trace_id, span_id, parent_span_id, name, kind, service_name, status_code, timestamp, end_time, duration_nano, is_root_span, matched_filter, and attributes (the span-level OTel attribute map, e.g. db.statement, http.url).\n\nUse 'apm-attributes-list' and 'apm-attribute-values-list' to discover available attributes before building filters. Use 'apm-services-list' to discover available services.\n\n# Return shape\n\nResults are **grouped by trace**, not a flat list of matching spans. For each trace that contains at least one span matching your filters, the response includes spans from that trace (up to `prefetchSpans` per trace, root span first). Two fields tell you which spans actually matched:\n\n- `matched_filter` — `1` if **this span** satisfies your `filterGroup`/`serviceNames`/`statusCodes`, `0` if it's only included because it shares a trace with a match (e.g. a prefetched sibling or the trace's root). When you filter by a child span's name, the matching child has `matched_filter: 1` and its root/siblings have `matched_filter: 0`.\n- `is_root_span` — `true` for the trace's entry span.\n\nTo collapse each matching trace to a **single row — its root span**, set `rootSpans: true` — see below. (The row is the trace's entry span, which may itself carry `matched_filter: 0` when the match was on a child.) To inspect a single trace's full tree, take a `trace_id` from the results and call `apm-trace-get`.\n\nCRITICAL: Be minimalist. Only include filters and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\nAll parameters must be nested inside a `query` object.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters via the `query.filterGroup` field to narrow results. Only include property filters when they are essential to directly answer the user's question.\n\nWhen using a property filter, you should:\n\n- **Choose the right type.** Span property types are:\n - `span` — filters built-in span fields (trace_id, span_id, duration, name, kind, status_code, is_root_span).\n - `span_attribute` — filters span-level attributes (e.g. \"http.method\", \"http.status_code\").\n - `span_resource_attribute` — filters resource-level attributes (e.g. k8s labels, deployment info).\n- **Use `apm-attributes-list` to discover available attribute keys** before building filters.\n- **Use `apm-attribute-values-list` to discover valid values** for a specific attribute key.\n- **Find the suitable operator for the value type** (see supported operators below).\n\nSupported operators:\n\n- String: `exact`, `is_not`, `icontains`, `not_icontains`, `regex`, `not_regex`\n- Numeric: `exact`, `gt`, `lt`\n- Existence (no value needed): `is_set`, `is_not_set`\n\nThe `value` field accepts a string, number, or array of strings depending on the operator. Omit `value` for `is_set`/`is_not_set`.\n\n## Time period\n\nUse the `query.dateRange` field to control the time window. If the question doesn't mention time, the default is the last hour (`-1h`). Examples of relative dates: `-1h`, `-6h`, `-1d`, `-7d`, `-30d`.\n\n# Parameters\n\nAll parameters go inside `query`.\n\n## query.serviceNames\n\nFilter by service names. Use `apm-services-list` to discover available services.\n\n## query.statusCodes\n\nFilter by OTel span status codes (list of integers: `0` Unset, `1` OK, `2` Error) — **not** HTTP status codes. Use `[2]` to select error spans.\n\n## query.orderBy\n\nSort by timestamp: `latest` (default) or `earliest`.\n\n## query.filterGroup\n\nA list of property filters to narrow results. Each filter specifies `key`, `operator`, `type` (span/span_attribute/span_resource_attribute), and optionally `value`. See the \"Property filters\" section above.\n\n## query.dateRange\n\nDate range to filter results. Defaults to the last hour (`-1h`).\n\n- `date_from`: Start of the range. Accepts ISO 8601 timestamps or relative formats: `-1h`, `-6h`, `-1d`, `-7d`, `-30d`.\n- `date_to`: End of the range. Same format. Omit or null for \"now\".\n\n## query.traceId\n\nFilter to a specific trace ID (hex string). Use this when you already know the trace ID.\n\n## query.rootSpans\n\nSet `true` to return **only root spans** — one entry span per matching trace, which collapses each trace to a single row. Useful for \"list the traces matching X\" without sifting through `matched_filter`. Leave unset (or `false`) to get all spans of matching traces, where you read `matched_filter` to find the ones that matched. The frontend leaves this unset.\n\n## query.flatSpans\n\nSet `true` to return **the matching spans themselves, one row per span** (root and child), rather than collapsing to traces. This is the way to search by a child-span attribute (e.g. `code.filepath`) — the result is the matching child spans directly, not the traces that contain them. Streams under `ORDER BY … LIMIT`, so it stays bounded on hot child attributes where the whole-trace grouping would not. Distinct from `rootSpans` (which scopes whole-trace selection); `prefetchSpans` is ignored. Defaults to false.\n\n## query.limit\n\nMaximum number of results (1-1000). Defaults to 100.\n\n## query.after\n\nCursor for pagination. Use the `nextCursor` value from the previous response.\n\n## query.prefetchSpans\n\nNumber of spans to return per matching trace (1-100), root span first. Useful to preview trace structure without a separate `apm-trace-get`. With the default (1) you get one span per trace (the root); raise it to also pull the matching children and their siblings (check `matched_filter` to tell them apart). Ignored when `rootSpans: true`, which always returns just the root.\n\n## query.excludeAttributes\n\nSet `true` to drop the per-span `attributes` map from results (the map stays present but empty). The attribute map holds multi-KB values like `db.statement`, so excluding it keeps large result sets compact — set it when you only need span structure/timing (`name`, `service_name`, `duration_nano`, `parent_span_id`) and not the OTel attributes. Defaults to false.\n\n# Examples\n\n## List recent error spans\n\n```json\n{\n \"query\": {\n \"statusCodes\": [2]\n }\n}\n```\n\n## Search spans from a specific service\n\n```json\n{\n \"query\": {\n \"serviceNames\": [\"api-gateway\"],\n \"dateRange\": { \"date_from\": \"-1d\" }\n }\n}\n```\n\n## Filter by a span attribute\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"http.method\", \"operator\": \"exact\", \"type\": \"span_attribute\", \"value\": \"POST\" }],\n \"dateRange\": { \"date_from\": \"-6h\" }\n }\n}\n```\n\n## Find slow spans\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"duration\", \"operator\": \"gt\", \"type\": \"span\", \"value\": \"1000000000\" }],\n \"dateRange\": { \"date_from\": \"-1d\" }\n }\n}\n```\n\n## Combine service and attribute filters\n\n```json\n{\n \"query\": {\n \"serviceNames\": [\"web-server\"],\n \"filterGroup\": [{ \"key\": \"http.status_code\", \"operator\": \"gt\", \"type\": \"span_attribute\", \"value\": \"399\" }],\n \"dateRange\": { \"date_from\": \"-12h\" }\n }\n}\n```\n\n## Check if a resource attribute exists\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"k8s.pod.name\", \"operator\": \"is_set\", \"type\": \"span_resource_attribute\" }]\n }\n}\n```\n\n# Reminders\n\n- Ensure that any property filters are directly relevant to the user's question. Avoid unnecessary filtering.\n- Use `apm-attributes-list` and `apm-attribute-values-list` to discover attributes before guessing filter keys/values.\n- Use `apm-services-list` to discover available services before filtering by service name.\n- Duration values are in nanoseconds (1 second = 1,000,000,000 nanoseconds).",
@@ -8733,7 +8741,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"workflows-create": {
"description": "Create a workflow. It is created as a draft and does NOT run until enabled: test it with workflows-test-run first, then enable (workflows-enable) only with the user's explicit approval — enabling is a one-way door, since live workflows can't be edited over MCP. Provide an actions array with exactly one type='trigger' (config.type: event|webhook|manual|batch|tracking_pixel) plus action nodes (function/function_email/function_sms, delay, conditional_branch, wait_until_condition, ...) connected by edges. Read the building-workflows skill for node shapes before composing: a node that mismatches the per-type schema saves but breaks the visual editor. Two traps that save but break: (1) a conditional_branch condition needs a 'filters' wrapper — {filters:{properties:[...]}}, not {properties:[...]} on the condition; omitting it passes save but the editor flags it and the branch won't evaluate your condition. (2) Never hand-author bytecode anywhere; send properties/hash and the server compiles it. A 'batch' trigger broadcasts to an audience (config.filters.properties: person-property conditions and/or cohort references), one run per matching person, and does NOT fire on enable: dispatch with workflows-run-batch or attach a schedule with workflows-schedule-create. Behavioral targeting ('did event X at least N times over the last M days') is unsupported; reject it and explain why.",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index e3af3e30366b..d2a81e7a9e10 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -2554,7 +2554,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-flaky-tests": {
"description": "Backend tests ranked by flakiness signal over a window (date_from default -7d, maximum 30 days), from the per-test CI spans. A test qualifies by passing on an automatic retry at least min_rerun_passes times (default 1) OR failing on at least min_failed_prs distinct pull requests (default 3). Use this for \"which tests are flaky right now\" and to pick quarantine candidates. Read the counts as absolute signal, never rates — fast passing runs are not emitted, so there is no honest denominator. rerun_passed_count only flows from CI lanes running with retries enabled; in other lanes a flake surfaces as a plain failure, which failed_pr_count catches. xfailed_count > 0 means the test is already quarantined but still failing. nodeid is a best-effort reconstruction (no '.py' suffix, the file/class boundary folded into '/'), so convert before using it as a pytest selector.",
@@ -2568,7 +2569,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-pr-cost": {
"description": "Estimated CI dollar cost of one pull request, summed over the jobs of all its workflow runs, with breakdowns per workflow (by_workflow) and per run (by_run). Reach for this instead of summing runner minutes by hand: the estimate already classifies runners (billable self-hosted Linux vs free GitHub-hosted), applies the per-vCPU price ladder, and excludes non-Linux and provider-hosted jobs. jobs_available is false when the job-level source isn't synced yet — every figure is then zero/null, so check it before trusting a $0.00. estimated_cost_usd is null (not zero) when nothing was costable, and unsettled_jobs counts billable jobs still running that are left out of the estimate.",
@@ -2582,10 +2584,11 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-sources": {
- "description": "The team's connected GitHub data warehouse sources, oldest first, each with its id, repo (owner/name), and table prefix. Call this first when a team may have more than one GitHub source, then pass a chosen id as source_id to the pull-requests, workflow-health, ci-cards, or pr-lifecycle tools to read that specific source. With a single source you can skip it — the other tools default to the oldest connected source.",
+ "description": "The team's connected GitHub data warehouse sources, oldest first, each with its id, repo (owner/name), and table prefix. Call this first when a team may have more than one GitHub source, then pass a chosen id as source_id to the pull-requests, workflow-health, ci-cards, or pr-lifecycle tools to read that specific source. With a single source you can skip it — the other tools default to the oldest connected source. The prefix also names the underlying warehouse tables (prefix + github_pull_requests / github_workflow_runs / github_workflow_jobs), which you can query directly with SQL or save as SQL insights and subscriptions when the named tools don't fit (timestamps land as strings; parse with parseDateTimeBestEffort).",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "List connected GitHub sources",
@@ -2596,7 +2599,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-jobs": {
"description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced yet.",
@@ -2610,7 +2614,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-runner-costs": {
"description": "One workflow's estimated CI cost broken down by runner tier over a window (date_from default -30d), highest spend first. Each row is a tier (provider + runner_label) with its job_count, billable_minutes, and estimated_cost_usd. Use this for \"which runner tier drives this workflow's CI bill\" and to spot oversized runners. Billable self-hosted Linux tiers carry a cost; github-hosted and non-Linux rows are null. Returns an empty list when the job-level source isn't synced yet.",
@@ -2624,7 +2629,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"error-tracking-alerts-create": {
"description": "Create an error tracking alert that fires when an issue is created, reopened, or starts spiking. An alert is a HogFunction with `type=internal_destination` whose `filters.events` references one of the three error-tracking lifecycle events. The events themselves are the trigger — there is no threshold or evaluation window to configure.\n\nTrigger events:\n- `$error_tracking_issue_created` — fires once when a new issue first appears.\n- `$error_tracking_issue_reopened` — fires when a previously resolved issue starts emitting again.\n- `$error_tracking_issue_spiking` — fires when the spike detector flags abnormal volume on an\n issue. The spike threshold is configured separately via the spike detection config endpoint\n and applies to all issues in the project.\n\n\nRecipe — deliver an error tracking alert to Slack or a webhook:\n\n1. Confirm the trigger and channel with the user. Picking `created` for a noisy project will\n flood the channel; `spiking` is usually the safer default. Do not assume.\n\n\n2. Pick the integration. For Slack, call `integrations-list` with `kind=slack` to find the\n integration id, then `integrations-channels-retrieve` for that integration to list channels.\n For a webhook, the user provides the destination URL directly. Confirm the channel name or\n webhook URL with the user before creating the alert — never wire a new alert to a production\n channel without explicit confirmation.\n\n\n3. Dedupe. Call `error-tracking-alerts-list` and check whether an alert for the same trigger\n event already exists. Skip creation if one is present and enabled — call\n `error-tracking-alerts-partial-update` to adjust an existing alert instead of creating a\n duplicate. Several alerts on the same event for the same channel produce duplicate\n notifications.\n\n\n4. Create. Use `type=internal_destination`, the integration's `template_id`\n (`template-slack`, `template-webhook`, `template-discord`, `template-microsoft-teams`,\n `template-linear`, `template-github`, or `template-gitlab`), and:\n\n filters = {\n \"events\": [{\"id\": \"$error_tracking_issue_created\", \"type\": \"events\"}]\n }\n\n Optional per-issue scoping (`created`/`reopened` only): add a `filters.properties` clause\n on `$exception_issue_id` — for example\n `[{\"key\": \"$exception_issue_id\", \"value\": \"<issue_uuid>\", \"operator\": \"exact\", \"type\": \"event\"}]`\n to alert only on a specific known-flaky issue. `$error_tracking_issue_spiking` events carry\n no exception properties, so spiking alerts cannot be scoped per issue. PostHog's \"alerts\n configured\" recommendation only checks `filters.events`, so adding property filters does\n not affect it.\n\n\n5. Slack message body. Mirror the shape the in-product alert wizard produces so agent-created\n and UI-created alerts look identical. The canonical payloads for every integration are in\n the `authoring-error-tracking-alerts` skill references.\n\n For `$error_tracking_issue_created` (Slack):\n\n inputs = {\n \"slack_workspace\": {\"value\": <slack_integration_id_int>},\n \"channel\": {\"value\": \"<channel_id>\"},\n \"text\": {\"value\": \"New issue created: {event.properties.name}\"},\n \"blocks\": {\"value\": [\n {\"type\": \"header\", \"text\": {\"type\": \"plain_text\",\n \"text\": \"🔴 {event.properties.name}\"}},\n {\"type\": \"section\", \"text\": {\"type\": \"plain_text\", \"text\": \"New issue created\"}},\n {\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\",\n \"text\": \"```{substring(event.properties.description, 1, 150)}```\"}},\n {\"type\": \"context\", \"elements\": [\n {\"type\": \"plain_text\", \"text\": \"Status: {event.properties.status}\"},\n {\"type\": \"mrkdwn\", \"text\": \"Project: <{project.url}|{project.name}>\"},\n {\"type\": \"mrkdwn\", \"text\": \"Alert: <{source.url}|{source.name}>\"}\n ]},\n {\"type\": \"divider\"},\n {\"type\": \"actions\", \"elements\": [\n {\"type\": \"button\", \"text\": {\"type\": \"plain_text\", \"text\": \"View Issue\"},\n \"url\": \"{project.url}/error_tracking/{event.distinct_id}?fingerprint={event.properties.fingerprint}&timestamp={event.properties.exception_timestamp}&utm_source=alert&utm_campaign=error_tracking_alert&utm_medium=slack\"}\n ]}\n ]}\n }\n\n For `$error_tracking_issue_reopened`, use the same blocks with the header swapped to\n `🔄 {event.properties.name}`, the section text to `Issue reopened`, and `text` to\n `Issue reopened: {event.properties.name}`.\n\n For `$error_tracking_issue_spiking` (Slack), use the same shape but swap the header to\n `📈 Issue spiking`, drop the `fingerprint`/`timestamp` params from the button URL (spiking\n events do not carry them), and add a context line referencing\n `{event.properties.current_bucket_value}` and `{event.properties.computed_baseline}`. The\n exact block layout is in the `authoring-error-tracking-alerts` skill references.\n\n\n6. Webhook body. The webhook template only requires `url`:\n\n inputs = {\"url\": {\"value\": \"<destination_url>\"}}\n\n Webhooks must be `https://` URLs.\n\n\nEvent property reference — common across all three events: `event.properties.name` (issue title), `event.properties.description` (truncated body), `event.distinct_id` (issue id used in the deep link). `created`/`reopened` additionally expose `event.properties.status`, `event.properties.fingerprint`, `event.properties.exception_timestamp`, and the originating exception's properties (e.g. `$exception_types`, `$exception_issue_id`). Spiking events instead expose `event.properties.current_bucket_value` and `event.properties.computed_baseline` — no status, fingerprint, or exception properties. Project context is available as `{project.url}` (already includes `/project/<team_id>`), `{project.name}`, and the alert's own metadata as `{source.url}` and `{source.name}`.",
@@ -6462,7 +6468,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"project-get": {
"description": "Retrieve a project and its settings. Omit the ID to get the caller's active project.",
@@ -6602,7 +6609,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"query-apm-spans": {
"description": "Query trace spans with filtering by service name, status code, date range, and structured attribute filters. Supports cursor-based pagination. Returns spans with uuid, trace_id, span_id, parent_span_id, name, kind, service_name, status_code, timestamp, end_time, duration_nano, is_root_span, matched_filter, and attributes (the span-level OTel attribute map, e.g. db.statement, http.url).\n\nUse 'apm-attributes-list' and 'apm-attribute-values-list' to discover available attributes before building filters. Use 'apm-services-list' to discover available services.\n\n# Return shape\n\nResults are **grouped by trace**, not a flat list of matching spans. For each trace that contains at least one span matching your filters, the response includes spans from that trace (up to `prefetchSpans` per trace, root span first). Two fields tell you which spans actually matched:\n\n- `matched_filter` — `1` if **this span** satisfies your `filterGroup`/`serviceNames`/`statusCodes`, `0` if it's only included because it shares a trace with a match (e.g. a prefetched sibling or the trace's root). When you filter by a child span's name, the matching child has `matched_filter: 1` and its root/siblings have `matched_filter: 0`.\n- `is_root_span` — `true` for the trace's entry span.\n\nTo collapse each matching trace to a **single row — its root span**, set `rootSpans: true` — see below. (The row is the trace's entry span, which may itself carry `matched_filter: 0` when the match was on a child.) To inspect a single trace's full tree, take a `trace_id` from the results and call `apm-trace-get`.\n\nCRITICAL: Be minimalist. Only include filters and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\nAll parameters must be nested inside a `query` object.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters via the `query.filterGroup` field to narrow results. Only include property filters when they are essential to directly answer the user's question.\n\nWhen using a property filter, you should:\n\n- **Choose the right type.** Span property types are:\n - `span` — filters built-in span fields (trace_id, span_id, duration, name, kind, status_code, is_root_span).\n - `span_attribute` — filters span-level attributes (e.g. \"http.method\", \"http.status_code\").\n - `span_resource_attribute` — filters resource-level attributes (e.g. k8s labels, deployment info).\n- **Use `apm-attributes-list` to discover available attribute keys** before building filters.\n- **Use `apm-attribute-values-list` to discover valid values** for a specific attribute key.\n- **Find the suitable operator for the value type** (see supported operators below).\n\nSupported operators:\n\n- String: `exact`, `is_not`, `icontains`, `not_icontains`, `regex`, `not_regex`\n- Numeric: `exact`, `gt`, `lt`\n- Existence (no value needed): `is_set`, `is_not_set`\n\nThe `value` field accepts a string, number, or array of strings depending on the operator. Omit `value` for `is_set`/`is_not_set`.\n\n## Time period\n\nUse the `query.dateRange` field to control the time window. If the question doesn't mention time, the default is the last hour (`-1h`). Examples of relative dates: `-1h`, `-6h`, `-1d`, `-7d`, `-30d`.\n\n# Parameters\n\nAll parameters go inside `query`.\n\n## query.serviceNames\n\nFilter by service names. Use `apm-services-list` to discover available services.\n\n## query.statusCodes\n\nFilter by OTel span status codes (list of integers: `0` Unset, `1` OK, `2` Error) — **not** HTTP status codes. Use `[2]` to select error spans.\n\n## query.orderBy\n\nSort by timestamp: `latest` (default) or `earliest`.\n\n## query.filterGroup\n\nA list of property filters to narrow results. Each filter specifies `key`, `operator`, `type` (span/span_attribute/span_resource_attribute), and optionally `value`. See the \"Property filters\" section above.\n\n## query.dateRange\n\nDate range to filter results. Defaults to the last hour (`-1h`).\n\n- `date_from`: Start of the range. Accepts ISO 8601 timestamps or relative formats: `-1h`, `-6h`, `-1d`, `-7d`, `-30d`.\n- `date_to`: End of the range. Same format. Omit or null for \"now\".\n\n## query.traceId\n\nFilter to a specific trace ID (hex string). Use this when you already know the trace ID.\n\n## query.rootSpans\n\nSet `true` to return **only root spans** — one entry span per matching trace, which collapses each trace to a single row. Useful for \"list the traces matching X\" without sifting through `matched_filter`. Leave unset (or `false`) to get all spans of matching traces, where you read `matched_filter` to find the ones that matched. The frontend leaves this unset.\n\n## query.flatSpans\n\nSet `true` to return **the matching spans themselves, one row per span** (root and child), rather than collapsing to traces. This is the way to search by a child-span attribute (e.g. `code.filepath`) — the result is the matching child spans directly, not the traces that contain them. Streams under `ORDER BY … LIMIT`, so it stays bounded on hot child attributes where the whole-trace grouping would not. Distinct from `rootSpans` (which scopes whole-trace selection); `prefetchSpans` is ignored. Defaults to false.\n\n## query.limit\n\nMaximum number of results (1-1000). Defaults to 100.\n\n## query.after\n\nCursor for pagination. Use the `nextCursor` value from the previous response.\n\n## query.prefetchSpans\n\nNumber of spans to return per matching trace (1-100), root span first. Useful to preview trace structure without a separate `apm-trace-get`. With the default (1) you get one span per trace (the root); raise it to also pull the matching children and their siblings (check `matched_filter` to tell them apart). Ignored when `rootSpans: true`, which always returns just the root.\n\n## query.excludeAttributes\n\nSet `true` to drop the per-span `attributes` map from results (the map stays present but empty). The attribute map holds multi-KB values like `db.statement`, so excluding it keeps large result sets compact — set it when you only need span structure/timing (`name`, `service_name`, `duration_nano`, `parent_span_id`) and not the OTel attributes. Defaults to false.\n\n# Examples\n\n## List recent error spans\n\n```json\n{\n \"query\": {\n \"statusCodes\": [2]\n }\n}\n```\n\n## Search spans from a specific service\n\n```json\n{\n \"query\": {\n \"serviceNames\": [\"api-gateway\"],\n \"dateRange\": { \"date_from\": \"-1d\" }\n }\n}\n```\n\n## Filter by a span attribute\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"http.method\", \"operator\": \"exact\", \"type\": \"span_attribute\", \"value\": \"POST\" }],\n \"dateRange\": { \"date_from\": \"-6h\" }\n }\n}\n```\n\n## Find slow spans\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"duration\", \"operator\": \"gt\", \"type\": \"span\", \"value\": \"1000000000\" }],\n \"dateRange\": { \"date_from\": \"-1d\" }\n }\n}\n```\n\n## Combine service and attribute filters\n\n```json\n{\n \"query\": {\n \"serviceNames\": [\"web-server\"],\n \"filterGroup\": [{ \"key\": \"http.status_code\", \"operator\": \"gt\", \"type\": \"span_attribute\", \"value\": \"399\" }],\n \"dateRange\": { \"date_from\": \"-12h\" }\n }\n}\n```\n\n## Check if a resource attribute exists\n\n```json\n{\n \"query\": {\n \"filterGroup\": [{ \"key\": \"k8s.pod.name\", \"operator\": \"is_set\", \"type\": \"span_resource_attribute\" }]\n }\n}\n```\n\n# Reminders\n\n- Ensure that any property filters are directly relevant to the user's question. Avoid unnecessary filtering.\n- Use `apm-attributes-list` and `apm-attribute-values-list` to discover attributes before guessing filter keys/values.\n- Use `apm-services-list` to discover available services before filtering by service name.\n- Duration values are in nanoseconds (1 second = 1,000,000,000 nanoseconds).",
@@ -9272,7 +9280,8 @@
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true
- }
+ },
+ "feature_flag": "engineering-analytics"
},
"workflows-archive": {
"description": "Archive a draft or disabled workflow.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-ci-failure-logs.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-ci-failure-logs.json
deleted file mode 100644
index 85d2e2b42fbc..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-ci-failure-logs.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "pr_number": {
- "description": "Pull request number whose CI failure logs to fetch.",
- "type": "number"
- },
- "repo": {
- "description": "'owner/name' repository the pull request belongs to.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "required": ["pr_number", "repo"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-flaky-tests.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-flaky-tests.json
deleted file mode 100644
index 1aa034ffcab2..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-flaky-tests.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "date_from": {
- "description": "Window start: relative ('-7d', '-30d') or ISO8601. Defaults to -7d; the window may span at most 30 days.",
- "type": "string"
- },
- "date_to": {
- "description": "Window end: relative or ISO8601. Defaults to now.",
- "type": "string"
- },
- "limit": {
- "description": "Maximum number of tests to return (1-200). Defaults to 50.",
- "type": "number"
- },
- "min_failed_prs": {
- "description": "A test qualifies once it failed on at least this many distinct pull requests in the window (OR-ed with min_rerun_passes). Minimum 1. Defaults to 3.",
- "type": "number"
- },
- "min_rerun_passes": {
- "description": "A test qualifies once it passed on retry at least this many times in the window (OR-ed with min_failed_prs). Minimum 1. Defaults to 1.",
- "type": "number"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-pr-cost.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-pr-cost.json
deleted file mode 100644
index be6895e52414..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-pr-cost.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "pr_number": {
- "description": "Pull request number to estimate cost for.",
- "type": "number"
- },
- "repo": {
- "description": "'owner/name' repository the pull request belongs to.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "required": ["pr_number", "repo"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-sources.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-sources.json
deleted file mode 100644
index 7b7ea9186078..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-sources.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {},
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-jobs.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-jobs.json
deleted file mode 100644
index cb09c5ad0e8a..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-jobs.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "run_attempt": {
- "description": "Which re-run attempt to scope jobs to. Omit to use the run's latest attempt; pass an explicit attempt to avoid mixing jobs across a re-run's attempts.",
- "type": "number"
- },
- "run_id": {
- "description": "Workflow run id to list jobs for.",
- "type": "number"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "required": ["run_id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-runner-costs.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-runner-costs.json
deleted file mode 100644
index 52b142ac266d..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/engineering-analytics-workflow-runner-costs.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "branch": {
- "description": "Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.",
- "type": "string"
- },
- "date_from": {
- "description": "Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.",
- "type": "string"
- },
- "date_to": {
- "description": "Window end: relative or ISO8601. Defaults to now.",
- "type": "string"
- },
- "repo": {
- "description": "'owner/name' repository the workflow belongs to.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- },
- "workflow_name": {
- "description": "Workflow name to break down cost for.",
- "type": "string"
- }
- },
- "required": ["repo", "workflow_name"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/pr-lifecycle.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/pr-lifecycle.json
deleted file mode 100644
index a1098de706fb..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/pr-lifecycle.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "pr_number": {
- "description": "Pull request number to inspect.",
- "type": "number"
- },
- "repo": {
- "description": "'owner/name' repository the pull request belongs to.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "required": ["pr_number", "repo"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/pull-requests.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/pull-requests.json
deleted file mode 100644
index 15ca9f8818e6..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/pull-requests.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "author": {
- "description": "Optional GitHub login to scope the list to one author's pull requests.",
- "type": "string"
- },
- "date_from": {
- "description": "Recency floor for merged/closed PRs — relative ('-30d', '-8w') or ISO8601. Open PRs are always included regardless of age. Defaults to -30d.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json
deleted file mode 100644
index f8132cf55a22..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "branch": {
- "description": "Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.",
- "type": "string"
- },
- "date_from": {
- "description": "Window start — relative ('-24h', '-7d') or ISO8601. Defaults to -24h.",
- "type": "string"
- },
- "date_to": {
- "description": "Window end — relative or ISO8601. Defaults to now.",
- "type": "string"
- },
- "source_id": {
- "description": "Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.",
- "type": "string"
- }
- },
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index d3b4db4c5fab..805a3060690a 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -777,9 +777,10 @@ describe('Tool Filtering - Feature Flags', () => {
'metrics',
'mcp-sql-schema-discovery',
'endpoints-ai-materialization-fix',
+ 'engineering-analytics',
])
)
- expect(flags).toHaveLength(21)
+ expect(flags).toHaveLength(22)
})
// Exercise the real predicate (toolPassesFlagGate) over hand-rolled entries