Skip to content

AI-powered incident response connects Claude Code, Codex or Cursor to Sentry, Grafana, Datadog and PagerDuty through read-only MCP servers. The agent correlates alerts, deploys and errors into a sourced timeline, tests hypotheses, and drafts the mitigation, status updates and post-mortem. People keep the decisions: the incident commander approves every production change, and a monitoring query declares recovery.

It is 02:47. PagerDuty has paged you about checkout errors, Grafana, Datadog and Sentry are open in six tabs, and your product manager is already asking for an ETA in the incident channel. The fix may take two minutes; working out what broke is what takes the time. This page is for the on-call developer who runs that incident and the tech lead who owns the incident process. It shows where the agent works in each phase, the prompts to paste, and the gates that let you trust its output without reading every line of it.

  • A phase-by-phase split of what the agent does and what a named person decides, from page to post-mortem.
  • Read-only MCP setup for Sentry, Grafana, Datadog and PagerDuty in Claude Code, Codex and Cursor, with the switch that makes each server read-only.
  • Six copy-paste prompts: correlate, test the hypothesis, prepare the mitigation, check recovery, draft the status update, and draft the post-mortem.
  • A decision table for rollback, feature flag or fix forward, and the recovery check that closes the incident.
  • A post-mortem routine that turns each contributing factor into a test, an alert rule or an eval.

Where does the agent help in an incident, and where does it stop?

Section titled “Where does the agent help in an incident, and where does it stop?”

The agent is the incident’s analyst and scribe. It never operates production. Each phase has an output you can check without trusting the agent’s prose.

PhaseThe agent doesA person decidesThe evidence you check
DetectNothing: monitoring pages a humanOn-call engineer opens the incidentAlert ID in the incident tool
CorrelateBuilds a UTC timeline from alerts, errors and deploys—Every line cites a query, alert ID, issue ID or commit SHA
DiagnoseRanks hypotheses with evidence and counter-evidenceIncident commander picks one to act onCited sources re-opened by a second run
MitigatePrepares the runbook step, revert or flag changeIncident commander approves; the pipeline executesDeploy or flag system audit log
RecoverRuns the recovery query against thresholds set earlierCommander declares recoverySLO query result, attached to the incident
CommunicateDrafts each status updateComms lead or commander posts itThe posted message, by a named person
LearnDrafts the post-mortem and the regression testsService owners merge the post-mortem pull requestTests and evals that fail on the old behaviour

Two neighbouring pages cover the edges of this workflow. To lock the triage agent down under its own service account, with a tool allowlist and an injection drill, follow scoped AI incident triage. When an agent caused the incident, start with when an agent causes an incident: containment there begins with revoking the agent’s identity.

Connect read-only incident sources before the next page

Section titled “Connect read-only incident sources before the next page”

Set this up on a quiet afternoon, not during the incident. MCP configuration differs only in the command or file; the servers, URLs and read-only switches are the same in every agent. The full install guide, including OAuth scopes and context cost, is on observability MCP servers.

ServerOfficial package or URL (checked 2026-09-26)What makes it read-only
Sentryhttps://mcp.sentry.dev/mcp (OAuth); stdio @sentry/mcp-server 0.42.0 for self-hostedNarrow the exposed tools with ?skills= in the URL, for example ?skills=inspect,seer (Sentry MCP README, checked 2026-09-26). seer starts Seer analysis runs; use ?skills=inspect for strict read-only access
GrafanaPyPI mcp-grafana 1.6.3, run with uvx--disable-write and a Viewer-role service account
Datadoghttps://mcp.datadoghq.com/v1/mcp (US1; EU uses mcp.datadoghq.eu)No read-only switch in its README; log in as a user whose role fits
PagerDutyPyPI pagerduty-mcp 1.1.0, run with uvx (repository deprecated 2026; still read-only by default). The maintained path is PagerDuty’s hosted remote MCP server with OAuth; see its knowledge baseRead-only by default; never add --enable-write-tools for triage

Run in a terminal at the service repository’s root. -s project writes .mcp.json, so the setup goes through review, and single quotes keep each ${VAR} unexpanded until launch:

Terminal window
claude mcp add -s project --transport http sentry 'https://mcp.sentry.dev/mcp?skills=inspect,seer'
claude mcp add -s project grafana \
-e GRAFANA_URL=https://yourstack.grafana.net \
-e 'GRAFANA_SERVICE_ACCOUNT_TOKEN=${GRAFANA_SERVICE_ACCOUNT_TOKEN}' \
-- uvx mcp-grafana --disable-write
claude mcp add -s project --transport http datadog https://mcp.datadoghq.com/v1/mcp
claude mcp add -s project pagerduty \
-e 'PAGERDUTY_USER_API_KEY=${PAGERDUTY_USER_API_KEY}' \
-- uvx pagerduty-mcp

Run /mcp inside a session to complete the OAuth logins and confirm every server shows as connected.

Read-only belongs to the credential, not the prompt. A token that cannot write survives an agent that has been talked into trying; a line saying “do not change anything” does not. Name servers in plain language (“Using the Grafana and Sentry MCP servers, …”). In Claude Code, @server:protocol://resource mentions reference MCP resources, not tools (checked on 2.1.283).

How do you correlate alerts into one timeline?

Section titled “How do you correlate alerts into one timeline?”

Start the agent the moment you acknowledge the page. The first output you want is a timeline in which every line points at its source, because that is the only form you can check in two minutes.

Interactively, start in plan mode so the agent can query but cannot edit files: claude --permission-mode plan, then paste the prompt. To post the timeline to the incident record from a script, run it headless with only the MCP servers allowed:

Terminal window
claude -p "$(cat prompts/correlate.md) Incident: $INCIDENT_ID" \
--allowedTools "mcp__sentry mcp__grafana mcp__datadog mcp__pagerduty" \
--permission-mode dontAsk \
--output-format stream-json --verbose > "timeline-$INCIDENT_ID.jsonl"

dontAsk denies every tool call that would prompt instead of waiting for an answer nobody will give (Claude Code 2.1.283). Servers added with -s project need a one-time approval before they load, so a fresh machine or CI runner can start this run with no MCP tools and return a timeline with no tool calls. Approve the project servers once in an interactive session (or add them with -s user on the machine that runs the script), then confirm with claude mcp list before you rely on the headless run.

A useful reply is short and checkable. For example (illustrative):

02:30 payment-service v2.3.1 deployed [commit 9f3c2e1]
02:44 DB connection wait p95 150 ms -> 4.2 s [grafana: query A]
02:45 5xx rate 0.2% -> 15% [datadog monitor 81234]
02:47 ConnectionTimeoutError spike, first seen in v2.3.1 [sentry PAY-4F2]
02:47 PagerDuty incident triggered [pagerduty Q2X9]
Downstream: checkout-web 502s follow payment-service 5xx.
H1 connection pool too small after v2.3.1 (pool config changed in 9f3c2e1).
Against: none found.
H2 database saturation. Against: DB CPU flat at 35% [grafana: query B].

How do you test the leading hypothesis before anyone mitigates?

Section titled “How do you test the leading hypothesis before anyone mitigates?”

A timeline suggests a cause; it does not prove one. Before anyone touches production, ask the agent to try to break its own best hypothesis and to name what would confirm it.

“Smallest reversible action” is deliberate. It steers the answer toward a flag or a revert, both of which you can undo, and away from a speculative code change written under pressure.

Should you roll back, turn off a flag, or fix forward?

Section titled “Should you roll back, turn off a flag, or fix forward?”

Pick the mitigation before anyone writes code. The agent’s job is to prepare the option the incident commander chooses and to state the recovery threshold in advance.

SituationMitigationWhat the agent prepares
A deploy in the window and a clean previous releaseRoll back through the pipelineThe revert pull request and the rollback runbook step
The change sits behind a feature flagTurn the flag offThe exact flag, its current targeting and the expected metric change
Rollback is unsafe (a migration ran, data shape changed)Fix forwardA minimal patch with a failing-then-passing test
No change correlates (capacity, dependency outage)Scale, fail over or shed load per runbookThe runbook step and the numbers that justify it

A rollback path you have never exercised fails at 03:00. Rehearsed rollback with human production authority covers building it, and production approval as a system boundary covers who may press the button.

Mitigation is the phase to slow down. With v2.1.283 or later (both release channels on 2026-10-12), auto mode is the starting mode for interactive sessions, so start this one in Manual to get a prompt for every action:

Terminal window
claude --permission-mode manual

Never use --dangerously-skip-permissions or bypassPermissions during an incident. The agent opens a pull request; the pipeline deploys it.

How do you declare recovery without trusting the agent’s summary?

Section titled “How do you declare recovery without trusting the agent’s summary?”

Recovery is a query result compared against the thresholds written before the deploy. Setting the bar after seeing the numbers is how a partial fix gets called done. The agent runs the check and reports pass or fail; the incident commander declares recovery.

How do you keep stakeholders updated during the incident?

Section titled “How do you keep stakeholders updated during the incident?”

The agent drafts; a named person posts. A bot that posts on its own sooner or later tells customers something the commander has not agreed to.

For Slack, the official Slack MCP server ships inside plugins: /plugin install slack@claude-plugins-official in Claude Code and codex plugin add slack@openai-curated in Codex (both checked 2026-09-26). On Claude Team and Enterprise plans the Slack path is Claude Tag, which acts as the organization’s shared identity, so check what access your admin gave it before inviting it to an incident channel. Codex also works from Slack: mention @ChatGPT, and with Cloud delegation enabled ChatGPT sends repository work to a Codex Cloud task (OpenAI docs, checked 2026-10-12).

How do you turn the post-mortem into tests and evals?

Section titled “How do you turn the post-mortem into tests and evals?”

The post-mortem pays off only when each contributing factor becomes a check that fails if the problem comes back. The agent reconstructs the timeline from the same queries it ran live, so the draft starts from evidence, not from memory. Tag each contributing factor with a class from the failure taxonomy, so repeat causes show up across incidents.

A service owner reviews the post-mortem as a pull request, and it merges only with its tests in the same change or linked issues for each action item. When the cause was an agent-written change, the eval case goes into your continuous evals suite, so the same mistake fails a build instead of paging someone.

How do you know the agent’s incident work is trustworthy?

Section titled “How do you know the agent’s incident work is trustworthy?”

You check the agent’s output with gates, not by rereading it:

  • Sources, then audit. Every timeline line carries a source, and a second run re-opens each one and marks it VERIFIED, CONTRADICTED or UNSOURCED. The audit prompt is on scoped AI incident triage. A hypothesis that rests on an unsourced line does not reach the commander.
  • The tool-call log. The Claude Code stream-json output and the Codex JSONL stream record every MCP call. A timeline with no calls behind it is invented.
  • Credentials, not instructions. Viewer roles, --disable-write, Sentry’s skill list (inspect alone for strict read-only) and PagerDuty’s default read-only mode decide what the agent can touch.
  • Pre-declared thresholds. Recovery passes or fails against numbers written into the pull request before deploy.
  • Normal delivery gates. The revert or fix goes through review, CI and the deploy pipeline like any change. See how to review an agent’s pull request.
  • Named sign-off. The incident commander approves mitigation and declares recovery; service owners merge the post-mortem.

To judge the practice over a quarter, track three things per incident: minutes from page to a first sourced timeline, the share of timeline lines the audit marks VERIFIED, and post-mortem action items closed with a check attached. The agent’s own runs, costs and tool calls belong on your agent observability dashboard.

Roll the workflow out in the same order as the table at the top: read-only correlation first, then drafted updates and post-mortems, and prepared mitigations only after the team has seen the timelines hold up in several real incidents.

What breaks in AI-powered incident response, and how do you recover?

Section titled “What breaks in AI-powered incident response, and how do you recover?”

The agent reports metrics it never queried. Symptom: a confident timeline with no tool calls behind it. Recovery: check /mcp (Claude Code), codex mcp list or Cursor’s MCP settings; most failures are an expired OAuth token or a missing scope. Re-run with the servers named explicitly, and reject any line without a source. The full triage is on MCP connection issues.

A stdio server exits at start. Symptom: Grafana or PagerDuty never connects. Recovery: both are Python packages, so they run with uvx, not npx; install uv on the machine. The npm package @leval/mcp-grafana is a community port, not Grafana’s server.

The Datadog server returns 401 or the wrong data. Symptom: authentication fails, or queries hit an empty org. Recovery: match the MCP host to the site in your Datadog URL; app.datadoghq.eu means mcp.datadoghq.eu.

The agent silences, acknowledges or resolves. Symptom: pages stop while users still see errors. Recovery: remove write access at the source (--disable-write, no --enable-write-tools, no Sentry triage skill) and resume paging from the incident tool.

Log text steers the agent. Symptom: the agent proposes an action that came from a log line or a ticket. Recovery: treat channel text, logs and traces as data; keep write tools out of reach, and run the injection drill from scoped AI incident triage before the agent joins a live incident.

Updates flood the channel. Symptom: people stop reading. Recovery: post only on a state change or at the agreed interval, cap each update at five lines, and let a person post.

The post-mortem blames the model. Symptom: “the AI made a mistake” as the root cause. Recovery: end the causal chain at the control that should have caught the change, such as a missing test, a permission or a review route, and follow when an agent causes an incident.