/ 目錄 / 演練場 / Sentry MCP
● 官方 getsentry 🔑 需要你的金鑰

Sentry MCP

作者 getsentry · getsentry/sentry-mcp

Sentry 官方 MCP——讓 Claude 存取即時錯誤、追蹤記錄和發布資訊,讓偵錯建立在正式環境資料上,而非憑空猜測。

sentry-mcp 將 Claude 連接至你的 Sentry 組織。它將議題、事件、發布、麵包屑時間軸、效能追蹤和專案元資料作為 MCP 工具暴露出來。Claude 能將堆疊追蹤與引發問題的部署相關聯、將相關錯誤分組,並提出基於實際堆疊框架的修正方案。

為什麼要用

核心特性

即時演示

實際使用效果

sentry-mcp-getsentry.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "sentry-mcp-getsentry": {
      "command": "npx",
      "args": [
        "-y",
        "@sentry/mcp-server"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "sentry-mcp-getsentry": {
      "command": "npx",
      "args": [
        "-y",
        "@sentry/mcp-server"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "sentry-mcp-getsentry": {
      "command": "npx",
      "args": [
        "-y",
        "@sentry/mcp-server"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "sentry-mcp-getsentry": {
      "command": "npx",
      "args": [
        "-y",
        "@sentry/mcp-server"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "sentry-mcp-getsentry",
      "command": "npx",
      "args": [
        "-y",
        "@sentry/mcp-server"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "sentry-mcp-getsentry": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@sentry/mcp-server"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add sentry-mcp-getsentry -- npx -y @sentry/mcp-server

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: Sentry MCP

不離開 Claude 即可端對端偵錯正式環境錯誤

👤 處理 on-call 警報的開發者 ⏱ ~20 min intermediate

何時使用: Sentry 警報觸發;你需要立即找出根本原因。

前置條件
  • Sentry 認證 token — 使用者設定 → Auth Tokens → 建立,勾選「project:read」、「event:read」、「org:read」
  • Token 在環境變數中 — 設定 SENTRY_AUTH_TOKEN 及 SENTRY_HOST(sentry.io 或自架版本)
步驟
  1. 找到議題
    Use sentry-mcp. Find the most-firing issue in project 'web' from the last 6 hours.✓ 已複製
    → 議題 ID + 發生次數 + 首次/最後出現時間
  2. 拉取完整脈絡
    Get the latest event for that issue — stack trace, breadcrumbs, request data.✓ 已複製
    → 完整事件酬載,含框架及使用者操作軌跡
  3. 關聯至部署
    What release was running when this first appeared? List the commits in that release.✓ 已複製
    → 發布標籤 + 提交清單
  4. 提出修正方案
    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 毫無用處
搭配使用: github

推廣發布前的預檢

👤 發布工程師、部署把關人員 ⏱ ~15 min intermediate

何時使用: 即將將金絲雀發布推廣至 100%。

步驟
  1. 比較發布健康狀況
    Use sentry-mcp. Compare crash-free rate of release 1.4.0 vs 1.3.9 over their respective canary windows.✓ 已複製
    → 各版本無崩潰率、採用率、迴歸數量
  2. 檢查新錯誤
    List any issues unique to 1.4.0 (not seen in 1.3.9 or earlier).✓ 已複製
    → 新議題清單含發生次數
  3. 給出建議
    Given crash-free is X% and N net-new errors, recommend ship/halt with reason.✓ 已複製
    → 附有閾值說明的明確建議

結果: 以資料驅動的推廣或暫停決策,而非憑直覺。

注意事項
  • 採用率太低,統計上不具意義 — Claude 應將低採用率視窗標記為結果不明確——而非假裝了解

使用交易追蹤調查效能迴歸

👤 追查延遲的後端工程師 ⏱ ~25 min advanced

何時使用: 最後一次部署後,/checkout 的 p95 延遲暴增。

步驟
  1. 拉取近期慢速追蹤
    Use sentry-mcp. Get a trace for transaction 'POST /checkout' with duration > 2s from the last hour.✓ 已複製
    → 含 span 分解的追蹤記錄
  2. 找出新 span
    Compare span list to a similar trace from last week. Which spans are new or longer?✓ 已複製
    → 差異:新 DB 查詢「SELECT cart_items」,平均 1.4s
  3. 連結至程式碼
    What commit added that query? Suggest an index or a query rewrite.✓ 已複製
    → 提交記錄 + 具體修正建議

結果: 找出效能迴歸的根本原因,並附有程式碼層級的修正建議。

注意事項
  • 追蹤取樣率太低——沒有捕捉到慢速追蹤 — 暫時提高取樣率,或要求 Claude 改用統計端點
搭配使用: github

組合

與其他 MCP 搭配,撬動十倍槓桿

sentry-mcp-getsentry + github

從 Sentry 堆疊框架直接到 PR 草稿

Pull issue X from Sentry, find the offending commit via GitHub, draft a fix as a new branch + PR.✓ 已複製
sentry-mcp-getsentry + linear

從迴歸自動建立工程票

For each new release-blocking issue in Sentry, create a Linear ticket with the stack + suggested owner.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
search_issues project, query, statsPeriod? 以 Sentry 查詢篩選議題 1 次 Sentry API 呼叫
get_issue issue_id 初步查看單一議題 1 次 API 呼叫
get_event event_id 或 'latest' 拉取包含完整脈絡的特定事件發生記錄 1 次 API 呼叫
list_releases project, version? 跨發布比較 1 次 API 呼叫
get_trace trace_id 效能調查 1 次 API 呼叫

成本與限制

運行它的成本

API 配額
標準 Sentry API 速率限制——突發可能觸發 429
每次呼叫 Token 數
事件酬載可達 5–20k token——請選擇性地拉取
費用
Sentry 開發者方案免費;付費方案有更高速率限制
提示
先用 search_issues 縮小範圍;只對候選項目呼叫 get_event——而非整個結果清單

安全

權限、密鑰、影響範圍

最小權限: project:read event:read org:read
憑證儲存: SENTRY_AUTH_TOKEN 環境變數(使用範圍限定於專案的 token)
資料出站: 所有呼叫至你的 Sentry 主機(sentry.io 或自架版本)
切勿授予: 對聊天驅動的 agent 授予 project:write 或 org:write

故障排查

常見錯誤與修復

401 Unauthorized

Token 已過期或範圍錯誤——以列出的讀取範圍重新生成

驗證: curl -H 'Authorization: Bearer $SENTRY_AUTH_TOKEN' $SENTRY_HOST/api/0/projects/
堆疊追蹤只顯示壓縮後的框架

確認發布流水線中有上傳 source map;沒有 source map,Claude 無法對框架進行推理

驗證: Sentry 介面 → 發布 → Artifacts
已知議題回傳 404

議題所在的專案不在 token 涵蓋範圍內——重新設定 token 範圍至該專案

自架 Sentry——連線被拒

明確將 SENTRY_HOST 設定為包含通訊協定的實例 URL

驗證: curl $SENTRY_HOST/api/0/

替代方案

Sentry MCP 對比其他方案

替代方案何時用它替代權衡
Datadog MCP你的團隊使用 Datadog APM/錯誤追蹤不同的覆蓋範圍;APM 優先,議題功能較弱
Honeycomb MCP你是以事件而非堆疊追蹤為核心的可觀測性優先團隊沒有一流的議題分組功能;以追蹤為中心

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills