不離開 Claude 即可端對端偵錯正式環境錯誤
何時使用: Sentry 警報觸發;你需要立即找出根本原因。
前置條件
- Sentry 認證 token — 使用者設定 → Auth Tokens → 建立,勾選「project:read」、「event:read」、「org:read」
- Token 在環境變數中 — 設定 SENTRY_AUTH_TOKEN 及 SENTRY_HOST(sentry.io 或自架版本)
步驟
-
找到議題Use sentry-mcp. Find the most-firing issue in project 'web' from the last 6 hours.✓ 已複製→ 議題 ID + 發生次數 + 首次/最後出現時間
-
拉取完整脈絡Get the latest event for that issue — stack trace, breadcrumbs, request data.✓ 已複製→ 完整事件酬載,含框架及使用者操作軌跡
-
關聯至部署What release was running when this first appeared? List the commits in that release.✓ 已複製→ 發布標籤 + 提交清單
-
提出修正方案Looking at the stack and the commits — which commit likely caused this? Draft a fix in the relevant file.✓ 已複製→ 指出具體檔案與行號;提供具體修補方案
結果: 從警報到候選修正方案,幾分鐘內完成,並附有完整的證據鏈。
注意事項
- 缺少 source map——堆疊框架無法使用 — 確認 Sentry 發布中有上傳 source map;否則壓縮後的框架對 Claude 毫無用處