/ 目录 / 演练场 / Sentry MCP
● 官方 getsentry 🔑 需要你的密钥

Sentry MCP

作者 getsentry · getsentry/sentry-mcp

Sentry 官方 MCP——让 Claude 拉取实时错误、追踪记录和发版信息,使调试建立在生产数据之上,而非猜测。

sentry-mcp 将 Claude 连接到你的 Sentry 组织。它以 MCP 工具的形式暴露 issue、事件、发版记录、面包屑时间线、性能追踪和项目元数据。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,端到端调试生产错误

👤 处理值班告警的开发者 ⏱ ~20 min intermediate

何时使用: Sentry 告警触发;你现在需要根本原因。

前置条件
  • Sentry auth token — 用户设置 → Auth Tokens → 创建,赋予 'project:read'、'event:read'、'org:read'
  • Token 已写入环境变量 — 设置 SENTRY_AUTH_TOKEN 和 SENTRY_HOST(sentry.io 或自托管地址)
步骤
  1. 找到 issue
    Use sentry-mcp. Find the most-firing issue in project 'web' from the last 6 hours.✓ 已复制
    → Issue 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.✓ 已复制
    → Release 标签 + 提交列表
  4. 提出修复方案
    Looking at the stack and the commits — which commit likely caused this? Draft a fix in the relevant file.✓ 已复制
    → 具体的文件 + 行号;完整的修复补丁

结果: 从告警到候选修复方案只需几分钟,且有完整证据链。

注意事项
  • Source map 缺失——堆栈帧无意义 — 验证发版流程中是否上传了 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).✓ 已复制
    → 新 issue 列表及触发次数
  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.4 秒
  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

从回归问题自动创建工程 ticket

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

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
search_issues project, query, statsPeriod? 按 Sentry 查询语法过滤 issue 1 Sentry API call
get_issue issue_id 快速查看单个 issue 的顶层信息 1 API call
get_event event_id or 'latest' 拉取某次具体发生的完整上下文 1 API call
list_releases project, version? 跨发版对比分析 1 API call
get_trace trace_id 性能问题排查 1 API call

成本与限制

运行它的成本

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 未授权

Token 已过期或 scope 不正确——使用所列 read scope 重新生成

验证: curl -H 'Authorization: Bearer $SENTRY_AUTH_TOKEN' $SENTRY_HOST/api/0/projects/
堆栈帧只显示混淆代码

验证发版流程中是否上传了 source map;没有 source map,Claude 无法对帧进行推理

验证: Sentry UI → Release → Artifacts
已知 issue 返回 404

该 issue 所在项目未在 token 覆盖范围内——将 token 范围扩展到该项目

自托管 Sentry——连接被拒绝

显式设置 SENTRY_HOST 为带协议前缀的实例 URL

验证: curl $SENTRY_HOST/api/0/

替代方案

Sentry MCP 对比其他方案

替代方案何时用它替代权衡
Datadog MCP你的团队使用 Datadog APM/错误追踪覆盖面不同;以 APM 为核心,issue 聚焦度较低
Honeycomb MCP你们是以事件为核心的可观测性团队,而非依赖堆栈帧没有原生 issue 分组;以追踪为中心

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills