npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yqg/pe-cake-mcp

v1.0.0

Published

pe-cake-mcp

Downloads

5

Readme

Sentry MCP SSE 服务器

基于 FastMCP 框架构建的模型上下文协议(MCP)服务器,专为自托管 Sentry 实例设计,使用 Server-Sent Events (SSE) 技术实现实时通信。该服务器通过 MCP 协议提供全面的 Sentry 问题、项目、事件管理工具。

功能特性

  • 🚀 FastMCP 框架:基于 FastMCP TypeScript 框架构建,性能卓越
  • 🌊 Server-Sent Events (SSE):使用 SSE 技术实现实时流式数据传输
  • 🔧 完整的 Sentry 集成:全面支持自托管 Sentry 实例
  • TypeScript 支持:使用 TypeScript 编写,提供完整的类型安全
  • 🛡️ 错误处理:强大的错误处理机制,包含详细的 Sentry API 错误报告

可用工具

问题管理

  • get_sentry_issue:获取特定问题的详细信息,包括最新事件的堆栈跟踪
  • list_sentry_issues:列出项目问题,支持按查询条件或状态过滤
  • update_sentry_issue_status:更新问题状态(已解决/已忽略/未解决)
  • create_sentry_issue_comment:为 Sentry 问题添加评论

项目和事件管理

  • list_sentry_projects:列出 Sentry 组织中的所有项目
  • get_sentry_event_details:获取特定事件的详细信息

前置要求

  • Node.js 18+
  • 访问自托管 Sentry 实例的权限
  • 具有适当权限的 Sentry API 令牌
  • Sentry 组织标识符

安装

  1. 克隆仓库:
git clone <repository-url>
cd packages/sentry-mcp-sse
  1. 安装依赖:
npm install
  1. 构建项目:
npm run build

配置

设置以下环境变量:

export SENTRY_URL="https://your-sentry-instance.com"
export SENTRY_AUTH_TOKEN="your-sentry-api-token"
export SENTRY_ORG_SLUG="your-organization-slug"

环境变量说明

  • SENTRY_URL(必需):自托管 Sentry 实例的基础 URL
  • SENTRY_AUTH_TOKEN(必需):Sentry API 认证令牌
  • SENTRY_ORG_SLUG(必需):Sentry 组织标识符。如果未提供,服务器将尝试从令牌中推断

使用方法

开发模式

npm run start

服务器将在 http://localhost:8000/mcp 启动

生产模式

NODE_ENV=production npm run start

服务器将在 http://localhost:80/mcp 启动

使用自定义环境变量

SENTRY_URL="https://sentry.example.com" \
SENTRY_AUTH_TOKEN="your_token_here" \
SENTRY_ORG_SLUG="your-org" \
npm run start

API 端点

域名

https://analyzer-mcp-test.yangqianguan.com

ci 流水线

https://cicd.fintopia.tech/default/clusters/default/devops/cn-web-mcpp6646/pipelines/cn-web-mcp-ci/activity

健康检查

  • GET /healthCheck - 返回服务器健康状态

MCP 协议

  • POST /mcp - MCP 协议主端点,用于工具执行

工具使用示例

获取问题详情

{
  "name": "get_sentry_issue",
  "arguments": {
    "issue_id_or_url": "123456"
  }
}

列出项目问题

{
  "name": "list_sentry_issues",
  "arguments": {
    "project_slug": "my-web-app",
    "query": "is:unresolved environment:production",
    "status": "unresolved"
  }
}

更新问题状态

{
  "name": "update_sentry_issue_status",
  "arguments": {
    "issue_id": "123456",
    "status": "resolved"
  }
}

添加问题评论

{
  "name": "create_sentry_issue_comment",
  "arguments": {
    "issue_id": "123456",
    "comment_text": "问题已被调查并修复。"
  }
}

开发

可用脚本

  • npm run build - 构建 TypeScript 项目
  • npm run watch - 开发监视模式
  • npm run start - 以开发模式启动服务器
  • npm run inspector - 使用 MCP 检查器启动
  • npm run prepare - 准备项目发布

项目结构

src/
├── server.ts          # 主服务器实现

build/                 # 编译后的 JavaScript 输出
package.json          # 项目配置
tsconfig.json         # TypeScript 配置
README.md             # 本文件

错误处理

服务器为常见场景提供全面的错误处理:

  • 认证错误:无效的 API 令牌或权限不足
  • 资源未找到:无效的问题 ID、项目标识符或事件 ID
  • API 错误:Sentry API 限流、服务器错误或连接问题
  • 验证错误:无效的输入参数或格式错误的请求

所有错误都包含详细的消息,并在可用时提供状态码和响应数据。

Sentry API 兼容性

该服务器专为自托管 Sentry 实例设计,支持:

  • Sentry API v0 端点
  • Bearer 令牌认证
  • 组织范围的操作
  • 项目级问题和事件管理
  • 问题状态管理和评论功能

贡献

  1. Fork 仓库
  2. 创建功能分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add some amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 创建 Pull Request

使用示例

智能修复 Sentry 错误

使用 gitlab_ai_fix_sentry_error 工具可以自动分析和修复 Sentry 错误:

{
  "tool": "gitlab_ai_fix_sentry_error",
  "parameters": {
    "gitlab_project_id": "1041",
    "sentry_issue_data": "{\"sentry_issue_id\":\"371156\",\"title\":\"TypeError: Cannot read properties of undefined (reading '0')\",\"issue_context\":{\"title\":\"TypeError: Cannot read properties of undefined (reading '0')\",\"errorMessage\":\"Cannot read properties of undefined (reading '0')\",\"filePath\":\"src/pages/sql/components/sql-main/components/result-content.vue\",\"lineNumber\":159,\"projectSlug\":\"adhoc\"}}",
    "fix_strategy": "conservative",
    "auto_create_mr": true
  }
}

支持的数据格式

工具支持两种 Sentry 数据格式:

1. 解析后的诊断数据(推荐)

{
  "sentry_issue_id": "371156",
  "title": "TypeError: Cannot read properties of undefined (reading '0')",
  "issue_context": {
    "title": "TypeError: Cannot read properties of undefined (reading '0')",
    "errorMessage": "Cannot read properties of undefined (reading '0')",
    "filePath": "src/pages/sql/components/sql-main/components/result-content.vue",
    "lineNumber": 159,
    "projectSlug": "adhoc"
  }
}

2. 原始 Sentry API 数据

{
  "id": "371156",
  "title": "TypeError: Cannot read properties of undefined",
  "latest_event": {
    "entries": [
      {
        "type": "exception",
        "data": {
          "values": [
            {
              "stacktrace": {
                "frames": [
                  {
                    "filename": "src/components/result-content.vue",
                    "lineno": 159,
                    "in_app": true
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
}

工作流程

  1. 数据解析 - 自动识别数据格式并提取错误信息
  2. 仓库克隆 - 克隆 GitLab 项目到临时目录
  3. 代码分析 - 读取错误文件并获取上下文
  4. AI 诊断 - 使用 OpenAI 分析错误原因
  5. 生成修复 - AI 生成具体的代码修复方案
  6. 应用修复 - 自动应用修复到代码文件
  7. 代码审查 - AI 审查修复后的代码质量
  8. 提交推送 - 创建新分支并推送到 GitLab
  9. 创建 MR - 自动创建包含详细信息的合并请求

修复策略

  • conservative(保守):最小化改动,只修复核心问题
  • aggressive(积极):可以进行较大重构来彻底解决问题
  • minimal(最小):只做必要的最小修改

许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

支持

如需此 MCP 服务器的支持:

  1. 查看 FastMCP 文档
  2. 查阅您版本的 Sentry API 文档
  3. 在此仓库中创建 issue

相关项目