Skip to content

monte-carlo-data/mc-agent-toolkit / skills/remediation

monte-carlo-remediation

Unverified

Investigate and remediate data quality alerts using Monte Carlo MCP tools. Runs root cause analysis, assesses blast radius, discovers available tools (MCP/CLI/API), proposes and executes fixes, or escalates with full context when uncertain.

FileKindSize
README.mdmarkdown5.6 KB
SKILL.mdskill md21.6 KB
references/patterns.mdmarkdown10.7 KB
references/safety.mdmarkdown7.9 KB
references/tool-discovery.mdmarkdown7.5 KB

references/tool-discovery.md

View on GitHub
# Tool Discovery at Runtime

This reference explains how to discover what remediation tools are available to you at runtime. You have three categories of tools to check: MCP servers, CLI tools (via shell access), and APIs (via `curl` or language-specific clients). Check all three before deciding what's possible.

## Category 1: MCP servers

Each MCP-capable client lists the tools of every connected MCP server, and each client spells their IDs its own way: the server's name plus the operation, joined with a client-specific prefix or separator. Identify a server by its name and by what its tools describe, not by the spelling of the IDs. For example:

- an Airflow server with a `trigger_dag_run` operation
- a dbt Cloud server with a `trigger_run` operation
- a GitHub server with a `create_pull_request` operation

Go through your available tools, group them by the server they belong to, and call each with the tool ID your client exposes. Monte Carlo's own operations (`get_alerts`, `search`, …) come from your Monte Carlo connection; the routing note at the top of the skill says which connection to use.

## Category 2: CLI tools

You have shell access. Many remediation actions can be done via CLI tools that may already be installed:

| CLI Tool | Capability | Example Commands |
| -------- | ---------- | ---------------- |
| `gh` | GitHub operations | `gh pr create`, `gh issue create`, `gh api` |
| `git` | Code changes | `git checkout -b fix/...`, `git commit`, `git push` |
| `dbt` | dbt operations | `dbt run --select <model>`, `dbt test`, `dbt retry` |
| `airflow` | Airflow operations | `airflow dags trigger <dag_id>`, `airflow tasks run` |
| `montecarlo` | Monte Carlo CLI | `montecarlo monitors apply`, `montecarlo collectors test-connection` |
| `curl` | Any HTTP API | Call REST APIs directly for any service with an API |
| `snowsql` / `bq` / `databricks` | Warehouse CLIs | Execute SQL queries, check table state |

**Check availability** by running `which <tool>` or `<tool> --version` before using a CLI tool.

## Category 3: APIs (via curl or HTTP)

If neither an MCP server nor a CLI tool is available for a service, you can often call its REST API directly using `curl`. This is the most flexible option — any service with an API is reachable.

Examples:
```
# Trigger an Airflow DAG via REST API
curl -X POST "https://airflow.example.com/api/v1/dags/<dag_id>/dagRuns" \
  -H "Authorization: Bearer $AIRFLOW_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"conf": {}}'

# Trigger a dbt Cloud job via REST API
curl -X POST "https://cloud.getdbt.com/api/v2/accounts/<account_id>/jobs/<job_id>/run/" \
  -H "Authorization: Token $DBT_CLOUD_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cause": "Triggered by remediation skill"}'
```

**Note:** API calls require credentials. If you don't have the right tokens or environment variables, ask the user — don't guess at authentication.

## Discovery procedure

### Step 1: Check MCP servers

Group your available tools by MCP server, as described above. Common MCP servers relevant to remediation:

| Server Name Pattern | Capability |
| ------------------- | ---------- |
| `*airflow*` | Pipeline orchestration — trigger DAG runs, retry failed tasks |
| `*dagster*` | Pipeline orchestration — launch runs, check status |
| `*prefect*` | Pipeline orchestration — create flow runs, check status |
| `*dbt*` | dbt operations — trigger job runs, get status, list jobs |
| `*github*` | Code changes — create PRs, issues, branches |
| `*gitlab*` | Code changes — create merge requests, issues |
| `*snowflake*` | Warehouse access — execute queries, get table info |
| `*bigquery*` | Warehouse access — execute queries, get table info |
| `*databricks*` | Warehouse access + orchestration — queries, trigger jobs |
| `*fivetran*` | Ingestion — trigger connector sync, check status |
| `*jira*` | Issue tracking — create issues, update status |

### Step 2: Check CLI tools

For any capability not covered by MCP, check if a relevant CLI tool is available. The most common:

- `gh` — covers GitHub operations (PRs, issues, API calls) without needing a GitHub MCP
- `dbt` — covers dbt operations (run, test, retry) without needing a dbt Cloud MCP
- `git` — always available for code changes
- `curl` — always available for calling any REST API

### Step 3: Assess coverage

For the current remediation task, determine:

1. **Can I investigate?** — Monte Carlo MCP is always needed. If it's not connected, you cannot proceed.
2. **Can I execute the fix?** — Check MCP servers first, then CLI tools, then API access.

### Step 4: Report capabilities

Present what you found to the user before proceeding:

> "For this remediation, I can:
> - ✅ Investigate the issue (Monte Carlo MCP)
> - ✅ Restart the Airflow DAG (Airflow MCP connected)
> - ✅ Create a code fix (`gh` CLI available — no GitHub MCP needed)
> - ❌ Rerun the dbt job (no dbt Cloud MCP or `dbt` CLI found)"

## Graceful degradation

When no tool (MCP, CLI, or API) is available for a needed action:

### Priority 1: Provide actionable instructions

Give the user the exact commands or steps to execute themselves:

```
# If no Airflow tool is available but you identified the DAG:
"The DAG `etl_orders_daily` needs to be triggered. Run:
  airflow dags trigger etl_orders_daily
Or via the Airflow UI: navigate to DAGs → etl_orders_daily → Trigger DAG"

# If no dbt tool is available:
"dbt model `stg_orders` needs to be rebuilt. Run:
  dbt run --select stg_orders+
Or via dbt Cloud UI: Jobs → Daily Transform → Run Now"

# If no GitHub tool is available:
"File `models/staging/stg_orders.sql` needs line 14 changed from
  `user_id` to `customer_id`. Create a branch and PR with this change."
```

### Priority 2: Present findings and ask for next steps

Tell the user what you found, what the fix is, and ask how they'd like to proceed. They may run the commands themselves, notify their team, or take a different approach.

### Priority 3: Document on the alert

Always, regardless of what other tools are available:

```
createOrUpdateAlertComment(
  alert_id="<alert_uuid>",
  comment="## Remediation Plan\n\n**Root cause:** [summary]\n**Required action:** [specific fix]\n**Manual steps:**\n1. [step]\n2. [step]\n\n**Investigated by:** AI agent via remediation skill"
)
```

## Tool-specific notes

### Airflow

**MCP tools:** `trigger_dag_run`, `get_dag_runs`, `get_task_instances`, `clear_task_instances`
**CLI:** `airflow dags trigger <dag_id>`, `airflow tasks run <dag_id> <task_id> <execution_date>`
**API:** `POST /api/v1/dags/<dag_id>/dagRuns`

**Caution:** `trigger_dag_run` starts a NEW run. If the issue was a failed task in an existing run, `clear_task_instances` (retry) may be more appropriate than starting fresh.

### dbt

**MCP tools:** `trigger_run` / `trigger_job`, `get_run`, `list_jobs`, `cancel_run`
**CLI:** `dbt run --select <model>`, `dbt retry`, `dbt test --select <model>`
**API:** `POST /api/v2/accounts/<id>/jobs/<id>/run/`

**Note:** dbt Cloud jobs often include multiple models. Triggering a job reruns ALL models in that job, not just the failed one. The `dbt` CLI with `--select` gives more granular control.

### GitHub

**MCP tools:** `create_pull_request`, `create_issue`, `create_or_update_file`, `create_branch`
**CLI:** `gh pr create`, `gh issue create`, `gh api`
**Git:** `git checkout -b`, `git commit`, `git push`

The `gh` CLI is often the most practical option — it doesn't require a GitHub MCP server and supports the full GitHub API via `gh api`.

**Best practice:** For code fixes, create a branch → make the change → open a PR. Don't push directly to main.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall