Skip to main content
Glama
Sentry MCP

Sentry MCP

Official
by getsentry

sentry-mcp

Sentry 的 MCP 服务主要为“人在回路”(human-in-the-loop) 的编码代理而设计。我们的工具选择和优先级侧重于开发人员的工作流程和调试用例,而不是提供一个适用于所有 Sentry 功能的通用 MCP 服务器。

此远程 MCP 服务器充当上游 Sentry API 的中间件,针对 Cursor、Claude Code 等编码助手及类似的开发工具进行了优化。它基于 Cloudflare 在远程 MCP 方面的工作。

入门指南

您可以通过访问生产环境中部署的服务来了解所需的一切信息:

https://mcp.sentry.dev

如果您希望做出贡献、了解其工作原理或为自托管的 Sentry 运行此服务,请继续阅读下文。

Claude Code 插件

安装为 Claude Code 插件以实现自动子代理委派:

claude plugin marketplace add getsentry/sentry-mcp
claude plugin install sentry-mcp@sentry-mcp

这提供了一个 sentry-mcp 子代理,当您询问有关 Sentry 错误、问题、追踪或性能的信息时,Claude 会自动将其委派给该代理。

对于前瞻性的工具变体和功能:

claude plugin install sentry-mcp@sentry-mcp-experimental

Stdio 与远程模式

虽然此存储库专注于充当 MCP 服务,但我们也支持 stdio 传输。这目前仍在开发中,但它是使 MCP 适配自托管 Sentry 安装的最简单方法。

注意: AI 驱动的搜索工具(search_events、search_issues 等)需要 LLM 提供商(OpenAI 或 Anthropic)。这些工具使用自然语言处理将查询转换为 Sentry 的查询语法。如果没有配置提供商,这些特定工具将不可用,但所有其他工具将正常运行。

要使用 stdio 传输,您需要在 Sentry 中创建一个具有必要作用域的用户身份验证令牌。截至撰写本文时,所需作用域为:

org:read
project:read
project:write
team:read
team:write
event:write

启动传输:

npx @sentry/mcp-server@latest --access-token=sentry-user-token

需要连接到自托管部署?运行命令时添加 --host(仅主机名,例如 --host=sentry.example.com)。

某些功能(如 Seer)在自托管实例上可能不可用。您可以禁用特定技能以防止暴露不支持的工具:

npx @sentry/mcp-server@latest --access-token=TOKEN --host=sentry.example.com --disable-skills=seer

环境变量

SENTRY_ACCESS_TOKEN=         # Required: Your Sentry auth token

# LLM Provider Configuration (required for AI-powered search tools)
EMBEDDED_AGENT_PROVIDER=     # Required: 'openai' or 'anthropic'
OPENAI_API_KEY=              # Required if using OpenAI
ANTHROPIC_API_KEY=           # Required if using Anthropic

# Optional overrides
SENTRY_HOST=                 # For self-hosted deployments
MCP_DISABLE_SKILLS=          # Disable specific skills (comma-separated, e.g. 'seer')

重要: 请务必设置 EMBEDDED_AGENT_PROVIDER 以明确指定您的 LLM 提供商。仅基于 API 密钥的自动检测已被弃用,并将在未来的版本中移除。有关详细的配置选项,请参阅 docs/embedded-agents.md。

MCP 配置示例

{
  "mcpServers": {
    "sentry": {
      "command": "npx",
      "args": ["@sentry/mcp-server"],
      "env": {
        "SENTRY_ACCESS_TOKEN": "your-token",
        "EMBEDDED_AGENT_PROVIDER": "openai",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

如果您不设置 host 变量,CLI 会自动指向 Sentry SaaS 服务。仅在操作自托管 Sentry 时设置此覆盖项。

对于不支持 Seer 的自托管实例:

{
  "mcpServers": {
    "sentry": {
      "command": "npx",
      "args": ["@sentry/mcp-server"],
      "env": {
        "SENTRY_ACCESS_TOKEN": "your-token",
        "SENTRY_HOST": "sentry.example.com",
        "MCP_DISABLE_SKILLS": "seer"
      }
    }
  }
}

MCP Inspector

MCP 包含一个 Inspector,可用于轻松测试该服务:

pnpm inspector

输入 MCP 服务器 URL (http://localhost:5173) 并点击连接。这应该会为您触发身份验证流程。

注意:如果您在 127.0.0.1 上访问 inspector 时遇到 OAuth 流程问题,请尝试通过访问 http://localhost:6274 使用 localhost。

Related MCP server: Sentry MCP Server

本地开发

要贡献更改,您需要设置本地环境:

  1. 设置环境和代理技能:

    make setup-env  # Creates .env files and installs shared agent skills

    这也运行 npx @sentry/dotagents install 以将共享技能从 getsentry/skills 安装到 .agents/skills/ 中(符号链接到 .claude/skills 和 .cursor/skills)。如果您以后需要更新技能,请直接运行:

    npx @sentry/dotagents install
  2. 在 Sentry 中创建 OAuth 应用(设置 => API => 应用程序):

    • 主页 URL: http://localhost:5173

    • 授权重定向 URI: http://localhost:5173/oauth/callback

    • 记下您的客户端 ID 并生成客户端密钥

  3. 配置您的凭据:

    • 编辑根目录下的 .env 并添加您的 OPENAI_API_KEY

    • 编辑 packages/mcp-cloudflare/.env 并添加:

      • SENTRY_CLIENT_ID=your_development_sentry_client_id

      • SENTRY_CLIENT_SECRET=your_development_sentry_client_secret

      • COOKIE_SECRET=my-super-secret-cookie

  4. 启动开发服务器:

    pnpm dev

验证

在本地运行服务器以使其在 http://localhost:5173 可用

pnpm dev

要测试本地服务器,请在 Inspector 中输入 http://localhost:5173/mcp 并点击连接。按照提示操作后,您将能够“列出工具”(List Tools)。

测试

包含三个测试套件:单元测试、评估和手动测试。

单元测试可以使用以下命令运行:

pnpm test

评估需要在项目根目录中有一个包含某些配置的 .env 文件:

# .env (in project root)
OPENAI_API_KEY=  # Also required for AI-powered search tools in production

注意:根目录的 .env 文件为所有包提供默认值。各个包可以在开发过程中拥有自己的 .env 文件来覆盖这些默认值。

完成后,您可以使用以下命令运行它们:

pnpm eval

手动测试(测试 MCP 更改的首选方式):

# Test with local dev server (default: http://localhost:5173)
pnpm -w run cli "who am I?"

# Test agent mode (use_sentry tool only)
pnpm -w run cli --agent "who am I?"

# Test against production
pnpm -w run cli --mcp-host=https://mcp.sentry.dev "query"

# Test with local stdio mode (requires SENTRY_ACCESS_TOKEN)
pnpm -w run cli --access-token=TOKEN "query"

注意:CLI 默认为 http://localhost:5173。使用 --mcp-host 覆盖或设置 MCP_URL 环境变量。

综合测试手册:

  • Stdio 测试: 请参阅 docs/testing-stdio.md 以获取构建、运行和测试 stdio 实现(IDE、MCP Inspector)的完整指南

  • 远程测试: 请参阅 docs/testing-remote.md 以获取测试远程服务器(OAuth、Web UI、CLI 客户端)的完整指南

开发说明

自动化代码审查

此存储库使用自动化代码审查工具(如 Cursor BugBot)来帮助识别拉取请求中的潜在问题。这些工具提供有用的反馈和建议,但我们不建议将这些检查设为强制要求,因为其准确性仍在不断发展,可能会产生误报。

自动化审查应被视为:

  • ✅ 代码审查期间可考虑的有益建议

  • ✅ 讨论和改进的起点

  • ❌ 合并 PR 的非阻塞性要求

  • ❌ 不能替代人工代码审查

在处理自动化反馈时,请关注潜在的问题,而不是严格遵循每一条建议。

贡献者文档

想要贡献或探索完整的文档地图?请参阅 CLAUDE.md(也可用作 AGENTS.md)以获取贡献者工作流程和完整的文档索引。docs/ 文件夹包含按主题划分的指南和工具集成的 .md 文件。

Available Tools

7 tools
create_projectBInspect

Create a new project in Sentry, giving you access to a new SENTRY_DSN.

Use this tool when you need to:

  • Create a new project in a Sentry organization

Inputs: name (required), teamSlug (required), organizationSlug, platform.

create_teamBInspect

Create a new team in Sentry.

Use this tool when you need to:

  • Create a new team in a Sentry organization

Inputs: name (required), organizationSlug.

get_error_detailsAInspect

Retrieve error details from Sentry for a specific Issue ID, including the stacktrace and error message. Either issueId or issueUrl MUST be provided.

Use this tool when you need to:

  • Investigate a specific production error

  • Access detailed error information and stacktraces from Sentry

Inputs: issueId, issueUrl, organizationSlug.

list_organizationsBInspect

List all organizations that the user has access to in Sentry.

Use this tool when you need to:

  • View all organizations in Sentry

Inputs: no named parameters.

list_projectsBInspect

Retrieve a list of projects in Sentry.

Use this tool when you need to:

  • View all projects in a Sentry organization

Inputs: organizationSlug.

list_teamsAInspect

List all teams in an organization in Sentry.

Use this tool when you need to:

  • View all teams in a Sentry organization

Inputs: organizationSlug.

search_errors_in_fileAInspect

Search for errors recently occurring in a specific file. This is a suffix based search, so only using the filename or the direct parent folder of the file. The parent folder is preferred when the filename is in a subfolder or a common filename.

Use this tool when you need to:

  • Search for production errors in a specific file

  • Analyze error patterns and frequencies

  • Find recent or frequently occurring errors.

Inputs: filename (required), organizationSlug, sortBy.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as create_project vs. list_projects, but get_error_details and search_errors_in_file could potentially overlap in error investigation scenarios, which might cause slight confusion. Overall, the boundaries are clear with only minor ambiguity.

    Naming Consistency5/5

    All tools follow a consistent verb_noun naming pattern using snake_case, such as create_project, list_organizations, and search_errors_in_file. This uniformity makes the tool set predictable and easy to understand.

    Tool Count4/5

    With 7 tools, the count is reasonable for a Sentry-focused server, covering core operations like project, team, and error management. However, it feels slightly thin as it lacks update or delete operations, which are common in such domains.

    Completeness3/5

    The tool set covers creation and listing for projects, teams, and organizations, plus error retrieval and search, but it has notable gaps. Missing update/delete tools for projects and teams, and no error resolution or comment features, limit full lifecycle coverage for Sentry's domain.

    Maintenance

    ActivityActive
    ResponsivenessSyncing

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that retrieves and analyzes Sentry.io issues, allowing users to inspect error reports, stacktraces, and debugging information from their Sentry account.
      2
      23
      -
    • A
      license
      B
      quality
      F
      maintenance
      A Model Context Protocol server that enables AI assistants to interact with Sentry for error tracking and monitoring, allowing retrieval and analysis of error data, project management, and performance monitoring through the Sentry API.
      11
      21
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      A TypeScript implementation of a Model Context Protocol server that connects to Sentry error tracking service, allowing AI models to query and analyze error reports and events.
      17 npm
      MIT