Analyze root cause

From monte-carlo-data/mc-agent-toolkit · View interactive version

Analyze root cause is an AI agent skill from the GitHub repository monte-carlo-data/mc-agent-toolkit. Investigate data incidents and find root causes using Monte Carlo's observability data. Guides the agent through systematic investigation: alert lookup, lineage tracing, ETL checks, query analysis, and data profiling. Activates when a user asks about data issues, incidents, alerts, or why data looks

How to use this skill

Skill file

Monte Carlo Root Cause Analysis Skill

This skill helps investigate data incidents — freshness delays, volume anomalies, schema changes, field metric drift, and ETL failures — by guiding the agent through a systematic investigation using Monte Carlo's MCP tools. It combines observability metadata with optional direct data querying to find the root cause.

Monte Carlo tool routing (required): For Monte Carlo operations such as get_alerts, search

and get_asset, use the tool ID your client exposes on the connection for the intended account.

Proceed when there is one suitable connection and no evidence of an account or source mismatch. If

the choice is ambiguous, ask which connection to use before making a Monte Carlo call; if you

can't get an answer, leave the call pending. Use the selected connection throughout. If it is

unavailable or lacks the operation, follow this skill's fallback where it has one, or report what

is missing.

<!-- plugin-only:start -->

With the Agent Toolkit plugin: When using the toolkit plugin or its installer, prefer the

connection it provides or configures (normally named monte-carlo-mcp) when it is suitable for the

intended account. If you know that connection is missing, confirm the intended alternative before

using another one.

<!-- plugin-only:end -->

Reference files live next to this skill file. Use the Read tool (not MCP resources) to access them:

When to activate this skill

Activate when the user:

When NOT to activate this skill

Do not activate when the user is:

Prerequisites

Required: Monte Carlo MCP server (integrations.getmontecarlo.com/mcp) must be configured and authenticated.

Optional but recommended:

MCP Tools Used

From Monte Carlo MCP server

| Tool | Purpose |

|------|---------|

| get_alerts | Fetch incident/alert details |

| search | Find tables by name or keyword |

| get_asset | Table metadata and fields |

| get_asset_lineage | Table-level upstream/downstream lineage |

| get_field_lineage | Field-level lineage (trace bad data to source column) |

| get_table_freshness | Table update/freshness history |

| get_table_size_history | Row count and size history |

| get_queries | Read/write query history for a table, or the queries an ETL job ran |

| get_query_changes | Detect SQL text modifications |

| get_query_rca | Root cause analysis for failed/futile/missed queries |

| get_etl_issues | ETL pipeline issues — pass platform ("airflow", "dbt", or "databricks") |

| get_etl_jobs | Find ETL jobs that write to specific tables — pass platform param |

| get_github_prs | Recent GitHub PRs from the account's MC GitHub integration |

| get_jobs_performance | Job runtime stats, failure rates, 7-day trends |

| get_change_timeline | Unified timeline: query changes + volume + ETL failures |

| alert_assessment | Optional ~2-min triage of an incident — returns HIGH/MEDIUM/LOW confidence and impact. Useful when you want a quick read before deciding to escalate to TSA. |

| run_troubleshooting_agent | Starts the Troubleshooting Agent (TSA) on an incident. Async by default; idempotent (returns existing results unless force_rerun=True). Auto-invoked at Step 1.5 when an incident UUID is present. |

| get_troubleshooting_agent_results | Polls TSA results for an incident (status is not_found / running / success / failed). Use to check on the async run started at Step 1.5. |

Credits: alert_assessment and run_troubleshooting_agent consume Monte Carlo credits the same way the Troubleshooting Agent does when launched from the Monte Carlo UI. Each fresh run_troubleshooting_agent call is a billable run; reuse via the built-in idempotency (don't pass force_rerun=True unless the user explicitly asks for a fresh analysis).

Optional external MCP tools

| Tool | Purpose |

|------|---------|

| Database MCP (Snowflake, BigQuery, etc.) | Run SQL queries for data profiling |

| GitHub MCP | Search for recent PRs (alternative to MC's get_github_prs — useful if the account has no MC GitHub integration) |


Workflow

Step 1: Understand the problem (intake)

If the user provides an alert or incident ID:

  1. Call get_alerts with the alert ID to fetch details.
  2. Identify: affected table(s), issue type (freshness, volume, schema, field metric), when it started.
  3. Proceed to Step 2.

If the user describes a problem WITHOUT an incident ID:

Read references/intake-no-incident.md for the full intake flow. In short:

  1. Ask clarifying questions: what table? what looks wrong? when did it start?
  2. Search for the table: search(query="table_name")
  3. Search for related alerts: get_alerts with a recent time range. Pass ISO 8601

timestamps computed from the current date — e.g. created_after="2026-07-03T00:00:00Z",

created_before="2026-07-10T00:00:00Z" for a 7-day window (use the actual current date).

  1. Check table health: get_table_freshness, get_table_size_history
  2. Narrow down the issue type and proceed to Step 2.

Step 1.5: Auto-invoke TSA (when applicable)

When intake produces a Monte Carlo incident UUID, kick off the Troubleshooting Agent (TSA) before continuing to Step 2. TSA runs the same root-cause analysis the Monte Carlo UI uses; running it here in parallel with the manual investigation usually beats running either path alone.

Skip TSA when any of these is true:

  1. No incident UUID. run_troubleshooting_agent requires a UUID. The no-incident intake path (references/intake-no-incident.md) does not feed TSA. If that path later identifies a matching alert, return to Step 1 with the alert's incident UUID — Step 1.5 then applies normally.
  2. Narrow scoped check. The user wants a single fact, not an investigation. Examples: "is analytics.orders stale right now?", "what's the row count of X?", "show me the schema of Y", "did this query run today?". Answer the question with the relevant tool and stop. TSA is overkill for these.
  3. Explicit user opt-out. The user says "skip TSA", "don't run TSA", "manual only", "just do it yourself", or similar. Honor the opt-out and proceed to Step 2 without invoking TSA.

Default invocation (async, parallel):

run_troubleshooting_agent(incident_id="<uuid>", async_mode=True)

Tell the user what you started: "I've kicked off the Troubleshooting Agent on this incident — it usually finishes in 4–8 minutes. While it runs, I'll continue investigating manually so we have findings either way."

Step 2: Map the blast radius

TSA in parallel: if you started TSA at Step 1.5, it is running in the background while you do this step. Do not block on it.

  1. Call get_asset_lineage(mcons=[table_mcon], direction="UPSTREAM") — what feeds this table?
  2. Call get_asset_lineage(mcons=[table_mcon], direction="DOWNSTREAM") — what does this table feed?
  3. If the issue involves specific fields, call get_field_lineage to trace which upstream fields feed the affected columns.

Report to the user: "This table is fed by X upstream sources and feeds Y downstream consumers. Here's what could be impacted."

Ask for direction: Before diving deeper, ask the user what they'd like to investigate first. They may already have a hunch ("I think it's the Airflow job" or "check if someone changed the SQL"). Follow their lead — don't run all investigation paths blindly. If they have no preference, proceed with the most likely path based on the issue type.

Step 3: Investigate based on issue type

Read the appropriate reference file and follow its investigation playbook:

| Issue Type | Reference |

|-----------|-----------|

| Table not updating on schedule | references/freshness-investigation.md |

| Unexpected row count changes | references/volume-investigation.md |

| Columns added, removed, or type-changed | references/schema-investigation.md |

| Airflow/dbt/Databricks pipeline failures | references/etl-failure-investigation.md |

| SQL modifications causing data changes | references/query-change-investigation.md |

| Field-level metric drift (null rate, mean, etc.) | references/field-anomaly-investigation.md |

| Agent-monitor alert (agent evaluation, metric, trajectory, or validation) | Hand off — read and follow ../troubleshoot-agent-traces/SKILL.md instead of continuing here |

Step 4: Check for upstream causes

Data issues often originate upstream. Walk the lineage chain:

  1. For each direct upstream table from Step 2:
  1. Use get_field_lineage to trace the specific field that has bad data back to its source.
  2. Check what upstream field values correlate with the anomaly (if DB connector is available — see Step 5).

TSA poll #1. If you started TSA at Step 1.5 and it has not yet returned success, call get_troubleshooting_agent_results(incident_id=...) once here (~30s after Step 1.5). If status is success, hold the result for Step 7. If still running, keep going — you'll poll again before Step 7. Don't block on it.

Step 5: Profile data (if database MCP is available)

If the user has a database MCP server connected (Snowflake, BigQuery, Redshift, Databricks, etc.), read references/data-exploration.md for SQL investigation patterns including:

If no database MCP is available: Tell the user: "I can't query the warehouse directly — for deeper data investigation, connect a database MCP server. I can still analyze using Monte Carlo's metadata and the tools available." Continue the investigation with MC tools only.

Step 6: Check for code changes

Call get_github_prs with a time range around when the issue started to find recent PRs from the account's Monte Carlo GitHub integration. Look for PRs that modified dbt models, SQL files, or pipeline configs affecting the impacted table.

If the account has no GitHub integration (tool returns empty), or the user has a local GitHub MCP server they prefer, use that instead.

Also call get_query_changes with the affected table MCONs to detect SQL text modifications, and get_change_timeline for a unified view of all changes (query modifications + volume shifts + ETL failures) in one call.

Step 7: Synthesize and present

TSA poll #2. If you started TSA at Step 1.5 and don't yet have results, call get_troubleshooting_agent_results(incident_id=...) one more time (~60–90s after poll #1). Stop on success or failed; if still running after this poll, present the manual findings now and tell the user TSA is still working ("TSA is still running on this incident — I'll fold its findings in once it completes if you'd like, or you can ask me to check back in a minute").

Read references/common-root-causes.md to match findings against known patterns. Present:

  1. Root cause — what happened and when, with evidence from tools
  2. Evidence chain — which tools confirmed each piece of the story
  3. Impact — what downstream tables/consumers are affected (from Step 2)
  4. Recommended fix — specific action to resolve the issue
  5. Prevention — suggest monitoring to catch this earlier next time

Merging TSA findings:


Important rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.